X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=src%2Fproto.c;fp=src%2Fproto.c;h=2ca24c29c009212b3bf5f852991bbf27f07a2328;hp=1be7e054d8e41c886cc43a897dfff910b5321443;hb=c7368ce167d6dbfd3e69ba208301c5af3f17a8a1;hpb=7fb25f53f836172376c25b405b5f88f4ec37eed8 diff --git a/src/proto.c b/src/proto.c index 1be7e05..2ca24c2 100644 --- a/src/proto.c +++ b/src/proto.c @@ -449,8 +449,19 @@ guestfs___send_to_daemon (guestfs_h *g, const void *v_buf, size_t n) } if (FD_ISSET (g->sock, &rset2)) { r = check_for_daemon_cancellation_or_eof (g, g->sock); - if (r < 0) - return r; + if (r == -1) + return r; + if (r == -2) { + /* Daemon sent cancel message. But to maintain + * synchronization we must write out the remainder of the + * write buffer before we return (RHBZ#576879). + */ + if (xwrite (g->sock, buf, n) == -1) { + perrorf (g, "write"); + return -1; + } + return -2; /* cancelled */ + } } if (FD_ISSET (g->sock, &wset2)) { r = write (g->sock, buf, n);