(play): Increment send_eof instead of setting it, decrement it instead
of clearing it. Fixes a race condition: when we got EOF on input_fd and a failed doexecute() in the same iteration of the loop, only one EOF cookie was sent, leaving the client hung.
This commit is contained in:
parent
0b058415a1
commit
51846ec38f
1 changed files with 3 additions and 3 deletions
|
@ -258,7 +258,7 @@ play(int sock)
|
||||||
|
|
||||||
if (send_eof
|
if (send_eof
|
||||||
&& ring_putm(&inbuf, EOF_COOKIE, sizeof(EOF_COOKIE) - 1) >= 0)
|
&& ring_putm(&inbuf, EOF_COOKIE, sizeof(EOF_COOKIE) - 1) >= 0)
|
||||||
send_eof = 0;
|
send_eof--;
|
||||||
if (send_intr
|
if (send_intr
|
||||||
&& ring_putm(&inbuf, INTR_COOKIE, sizeof(INTR_COOKIE) - 1) >= 0)
|
&& ring_putm(&inbuf, INTR_COOKIE, sizeof(INTR_COOKIE) - 1) >= 0)
|
||||||
send_intr = 0;
|
send_intr = 0;
|
||||||
|
@ -275,7 +275,7 @@ play(int sock)
|
||||||
}
|
}
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
/* EOF on input */
|
/* EOF on input */
|
||||||
send_eof = 1;
|
send_eof++;
|
||||||
if (input_fd) {
|
if (input_fd) {
|
||||||
/* execute done, switch back to fd 0 */
|
/* execute done, switch back to fd 0 */
|
||||||
if (input_fd > 0)
|
if (input_fd > 0)
|
||||||
|
@ -311,7 +311,7 @@ play(int sock)
|
||||||
if (input_fd < 0) {
|
if (input_fd < 0) {
|
||||||
/* execute failed */
|
/* execute failed */
|
||||||
input_fd = 0;
|
input_fd = 0;
|
||||||
send_eof = 1;
|
send_eof++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue