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

Jerry Lundström jerry.lundstrom at iis.se
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/DBI.pm AnyEvent-DBI-2.3/DBI.pm
--- AnyEvent-DBI-2.3.orig/DBI.pm	2013-08-26 14:34:45.780104460 +0200
+++ AnyEvent-DBI-2.3/DBI.pm	2013-08-26 14:35:37.349725147 +0200
@@ -442,6 +442,7 @@
       kill TERM => $pid;
    }

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

/Jerry

--
Jerry Lundström - Software Engineer
.SE - The Internet Infrastructure Foundation
http://www.iis.se/

-------------- 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: <http://lists.schmorp.de/pipermail/anyevent/attachments/20130826/94287968/attachment.sig>


More information about the anyevent mailing list