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>