--- a/embperl.c
+++ b/embperl.c
@@ -89,6 +89,15 @@ make_embedded_interpreter(char const *pr
 	perl_destruct(my_perl);
 	perl_free(my_perl);
 	my_perl = NULL;
+#ifdef PERL_SET_CONTEXT
+	PERL_SET_CONTEXT(NULL);
+#endif
+/* The next line should NOT be necessary, but perl 5.10 appears to have
+   a bug as described at http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=516913
+*/
+#ifdef PERL_SET_INTERP
+	PERL_SET_INTERP(NULL);
+#endif
 #else
 	syslog(LOG_WARNING, "Cannot destroy and recreate a Perl interpreter safely on this platform.  Filter rules will NOT be reread.");
 	return 0;
