io: Make queue_io_read() safe for reentry
authorDavid Disseldorp <ddiss@suse.de>
Sun, 31 Jul 2011 01:14:54 +0000 (03:14 +0200)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Fri, 5 Aug 2011 04:27:18 +0000 (14:27 +1000)
commite097b7f8ff1a9992de1d11474dac4969e30cd679
tree7a2ac7622b939ce578be29b2cf86474dd8fb1519
parentfea64f65b54fa9e41e6c0b7428615edb1328cfb6
io: Make queue_io_read() safe for reentry

queue_io_read() may be reentered via the queue callback, recoverd is
particularly guilty of this.

queue_io_read() is not safe for reentry if more than one packet is
received and partial chunks follow - data read off the pipe on re-entry
is assumed to be the start-of-packet four byte length. This leads to a
wrongly aligned stream and the notorious "Invalid packet of length 0"
errors.

This change fixes queue_io_read() to be safe under reentry, only a
single packet is processed per call.

https://bugzilla.samba.org/show_bug.cgi?id=8319

(This used to be ctdb commit 9ea41d2fab612772f861270c8a59c01c43bd3a4c)
ctdb/common/ctdb_io.c