]> xenbits.xensource.com Git - people/sstabellini/xen-unstable.git/.git/commitdiff
vchan-socket-proxy: Handle closing shared input/output_fd
authorJason Andryuk <jandryuk@gmail.com>
Thu, 11 Jun 2020 03:29:36 +0000 (23:29 -0400)
committerWei Liu <wl@xen.org>
Fri, 26 Jun 2020 12:00:05 +0000 (12:00 +0000)
input_fd & output_fd may be the same FD.  In that case, mark both as -1
when closing one.  That avoids a dangling FD reference.

Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
Acked-by: Wei Liu <wl@xen.org>
Reviewed-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Release-acked-by: Paul Durrant <paul@xen.org>
tools/libvchan/vchan-socket-proxy.c

index 3552783ec25f445dc2fd2af4846744705fa714d9..e1d959c6d15ce84e71bafcb512743d1c65f1dc07 100644 (file)
@@ -349,6 +349,8 @@ int data_loop(struct vchan_proxy_state *state)
                     libxenvchan_wait(state->ctrl);
                 }
                 close(state->input_fd);
+                if (state->input_fd == state->output_fd)
+                    state->output_fd = -1;
                 state->input_fd = -1;
                 /* TODO: maybe signal the vchan client somehow? */
                 break;