[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH] tools/xenstore: don't close connection in xs_talkv()



In case of some errors xs_talkv() will close the connection to
Xenstore. This is annoying as it is not clear to the caller in which
error case the connection is still available.

Drop that implicit closing to make the interface behave in a sane and
predictable way.

Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
---
 tools/xenstore/xs.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/tools/xenstore/xs.c b/tools/xenstore/xs.c
index aa1d24b8b9..bbf3e00bed 100644
--- a/tools/xenstore/xs.c
+++ b/tools/xenstore/xs.c
@@ -524,12 +524,14 @@ static void *xs_talkv(struct xs_handle *h, 
xs_transaction_t t,
                        goto fail;
 
        ret = read_reply(h, &msg.type, len);
-       if (!ret)
-               goto fail;
 
        mutex_unlock(&h->request_mutex);
 
        sigaction(SIGPIPE, &oldact, NULL);
+
+       if (!ret)
+               return NULL;
+
        if (msg.type == XS_ERROR) {
                saved_errno = get_error(ret);
                free(ret);
@@ -539,19 +541,15 @@ static void *xs_talkv(struct xs_handle *h, 
xs_transaction_t t,
 
        if (msg.type != type) {
                free(ret);
-               saved_errno = EBADF;
-               goto close_fd;
+               errno = EBADF;
+               return NULL;
        }
        return ret;
 
 fail:
-       /* We're in a bad state, so close fd. */
        saved_errno = errno;
        mutex_unlock(&h->request_mutex);
        sigaction(SIGPIPE, &oldact, NULL);
-close_fd:
-       close(h->fd);
-       h->fd = -1;
        errno = saved_errno;
        return NULL;
 }
-- 
2.16.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.