Small fix to AnyEvent::DBI, does not close correctly on DESTROY/kill_child

Jerry Lundström jerry.lundstrom at
Mon Aug 26 14:55:46 CEST 2013

Hi Marc,

I'm using AnyEvent::DBI and was getting some strange behavior (corrupt SQLite databases after a select(?)) and noticed that the spawned process did not always exit correctly, it sill existed even after the AnyEvent::DBI object was gone. After trashing the module with a lot of debug output I saw that the TERM signal was most likely ignored in the serve_fh and resulted in the process still waiting for input after the object was gone. Checked the code where the TERM signal was sent and saw that it only closes the socket, no specific shutdown. Added shutdown (both read/write) and it seems to have solved this issue.

Heres the patch:

diff -ur AnyEvent-DBI-2.3.orig/ AnyEvent-DBI-2.3/
--- AnyEvent-DBI-2.3.orig/	2013-08-26 14:34:45.780104460 +0200
+++ AnyEvent-DBI-2.3/	2013-08-26 14:35:37.349725147 +0200
@@ -442,6 +442,7 @@
       kill TERM => $pid;

+   shutdown $self->{fh}, 2;
    close delete $self->{fh};


Jerry Lundström - Software Engineer
.SE - The Internet Infrastructure Foundation

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 495 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <>

More information about the anyevent mailing list