]> git.evergreen-ils.org Git - OpenSRF.git/commit
Perl pipe reading overhaul : data size header
authorBill Erickson <berick@esilibrary.com>
Mon, 13 Feb 2012 21:53:59 +0000 (16:53 -0500)
committerMike Rylander <mrylander@gmail.com>
Mon, 20 Feb 2012 19:37:20 +0000 (14:37 -0500)
commit08ee4f993fe773e37233b139961cbcdae2fe93b8
tree1b25a568412914083be6d0f548fb1f67c6e9dd1b
parent04558f38c1c1d314acb978a37193dacb4a6eba31
Perl pipe reading overhaul : data size header

The lockfile mechanism for preventing premature end of reads on child
processes suffers from one serious flaw:  if the data to write exceeds
the pipe buffer size, the parent will block on syswrite and the service
will lock up.  It's also not as effecient (for the normal case) as the
code was without the lockfile, becasue the writes and reads are
serialized.

This commit replaces the lockfile mechanism with a protocol header in
the data.  The first X (currently 12) bytes of data written to the child
process will contain the full length of the data to be written (minus
the header size).  The child now reads the data in parallel with the parent as
data is available.  If the child reads all available data (in the pipe)
but not all of the expected data, the child will go back into a select()
wait pending more data from the parent.  The process continues until all
data is read.

This same mechanism is already used to commicate status info from child
processes to the parent.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
src/perl/lib/OpenSRF/Server.pm
src/perl/lib/OpenSRF/System.pm