X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=src%2Fproto.c;h=cda731e5aa2d7c8d122212b617c08cfac09c5edc;hp=2ca24c29c009212b3bf5f852991bbf27f07a2328;hb=f4d996fd26762053d68f46de5790aae893f03d38;hpb=33b638109ed66ea360b53b80b1f407b3a5f5ec39 diff --git a/src/proto.c b/src/proto.c index 2ca24c2..cda731e 100644 --- a/src/proto.c +++ b/src/proto.c @@ -848,9 +848,6 @@ guestfs___send_file (guestfs_h *g, const char *filename) if (fd == -1) { perrorf (g, "open: %s", filename); send_file_cancellation (g); - /* Daemon sees cancellation and won't reply, so caller can - * just return here. - */ return -1; } @@ -1034,6 +1031,34 @@ guestfs___recv (guestfs_h *g, const char *fn, return 0; } +/* Same as guestfs___recv, but it discards the reply message. */ +int +guestfs___recv_discard (guestfs_h *g, const char *fn) +{ + void *buf; + uint32_t size; + int r; + + again: + r = guestfs___recv_from_daemon (g, &size, &buf); + if (r == -1) + return -1; + + /* This can happen if a cancellation happens right at the end + * of us sending a FileIn parameter to the daemon. Discard. The + * daemon should send us an error message next. + */ + if (size == GUESTFS_CANCEL_FLAG) + goto again; + + if (size == GUESTFS_LAUNCH_FLAG) { + error (g, "%s: received unexpected launch flag from daemon when expecting reply", fn); + return -1; + } + + return 0; +} + /* Receive a file. */ /* Returns -1 = error, 0 = EOF, > 0 = more data */