qrexec: handle buffered writes correctly

In case when we have a buffered write, always append to the
buffer, even if the pipe happens to be writable now. If not,
in case of certain tight race we might end up writing buffered data in
wrong order.
This commit is contained in:
Rafal Wojtczuk 2011-03-17 16:53:29 +01:00
джерело 4087b1d052
коміт af7fefa73f

@ -60,6 +60,12 @@ int write_stdin(int fd, int clid, char *data, int len,
struct buffer *buffer)
{
int ret;
if (buffer_len(buffer)) {
buffer_append(buffer, data, len);
return WRITE_STDIN_BUFFERED;
}
ret = write(fd, data, len);
if (ret == len)
return WRITE_STDIN_OK;