Skip to contentSkip to conversation

ms-queuedaemon: Do not spin if client input is delayed/truncated

PATCH In review Ian Jackson 2 participants 2 messages Oct 20, 2015 – Oct 21, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ms-queuedaemon: Do not spin if client input is delayed/truncated

chan-read-data would spin if `read' returns early because of nonblocking mode.

Check whether the return value is the empty string (which can only happen on eof or nonblocking lack of data, and we checked eof just before), and if so, simply return. The fileevent remains set up so we will be called again when more data arrives.

(Deployment/testing note: this change is currently live in Cambridge, as I cowboyed it directly into ~osstest/daemons-testing.git, on observing this misbehaviour.)

---
 tcl/daemonlib.tcl |    3 +++
 1 file changed, 3 insertions(+)
tcl/daemonlib.tcl +3 -0
index 55bc385..972b5e2 100644
@@ -166,6 +166,9 @@ proc chan-read-data {chan} {
 		chan-destroy $chan
 		return
 	    }
+            if {![string length $got]} {
+		return
+	    }
 	    append data $got
 	    incr len -[string length $got]
 	}
Signature · 1 line
1.7.10.4
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Ian Jackson

chan-read-data would spin if `read' returns early because of nonblocking mode.

Check whether the return value is the empty string (which can only happen on eof or nonblocking lack of data, and we checked eof just before), and if so, simply return. The fileevent remains set up so we will be called again when more data arrives.

Quoted 5 lines

(Deployment/testing note: this change is currently live in Cambridge, as I cowboyed it directly into ~osstest/daemons-testing.git, on observing this misbehaviour.)