commit - 05594ba5c50d7a7b10882b9504d75bdd5df348a3
commit + fecfd5bc4d412263e1178f9b6edf69709ea6e273
blob - 02c4cb511fe756c9101538c93243233f34941dd2
blob + ff9cd1e8a402bfed028e0aa1db7d6cf94c159eb4
--- lib/serve.c
+++ lib/serve.c
if (err)
break;
if (n == 0) {
- if (curstate != STATE_EXPECT_MORE_WANT &&
+ if (curstate != STATE_EXPECT_WANT &&
+ curstate != STATE_EXPECT_MORE_WANT &&
curstate != STATE_EXPECT_HAVE &&
curstate != STATE_EXPECT_DONE) {
err = got_error_msg(GOT_ERR_BAD_PACKET,
"unexpected flush packet received");
goto done;
}
+
+ if (curstate == STATE_EXPECT_WANT) {
+ ssize_t r;
+ /*
+ * If the client does not want to fetch
+ * anything we should receive a flush
+ * packet followed by EOF.
+ */
+ r = read(infd, buf, sizeof(buf));
+ if (r == -1) {
+ err = got_error_from_errno("read");
+ goto done;
+ }
+ if (r == 0) /* EOF */
+ goto done;
+
+ /* Zero-length field followed by payload. */
+ err = got_error_msg(GOT_ERR_BAD_PACKET,
+ "unexpected flush packet received");
+ goto done;
+ }
+
err = forward_flushpkt(&ibuf);
if (err)
goto done;