WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] Echo request and transaction identifiers in xenstored

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Echo request and transaction identifiers in xenstored
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 11 Oct 2005 11:46:10 +0000
Delivery-date: Tue, 11 Oct 2005 11:43:42 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 5cca372aec0554f150e54d0ab30c30a06a2ad4b5
# Parent  e43ffb31de480e558a1ccc7a12fbd9e2554ac83d
Echo request and transaction identifiers in xenstored
replies (and set to zero for async watch events).

Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>

diff -r e43ffb31de48 -r 5cca372aec05 tools/xenstore/xenstored_core.c
--- a/tools/xenstore/xenstored_core.c   Tue Oct 11 10:59:15 2005
+++ b/tools/xenstore/xenstored_core.c   Tue Oct 11 11:39:03 2005
@@ -539,6 +539,9 @@
        struct buffered_data *data;
 
        data = talloc(ctx, struct buffered_data);
+       if (data == NULL)
+               return NULL;
+       
        data->inhdr = true;
        data->used = 0;
        data->buffer = NULL;
@@ -583,15 +586,24 @@
 {
        struct buffered_data *bdata;
 
-       /* When data gets freed, we want list entry is destroyed (so
-        * list entry is a child). */
+       /* Message is a child of the connection context for auto-cleanup. */
        bdata = new_buffer(conn);
        bdata->buffer = talloc_array(bdata, char, len);
 
+       /* Echo request header in reply unless this is an async watch event. */
+       if (type != XS_WATCH_EVENT) {
+               memcpy(&bdata->hdr.msg, &conn->in->hdr.msg,
+                      sizeof(struct xsd_sockmsg));
+       } else {
+               memset(&bdata->hdr.msg, 0, sizeof(struct xsd_sockmsg));
+       }
+
+       /* Update relevant header fields and fill in the message body. */
        bdata->hdr.msg.type = type;
        bdata->hdr.msg.len = len;
        memcpy(bdata->buffer, data, len);
 
+       /* Queue for later transmission. */
        list_add_tail(&bdata->list, &conn->out_list);
 }
 
@@ -1144,36 +1156,25 @@
 
 static void consider_message(struct connection *conn)
 {
-       /*
-        * 'volatile' qualifier prevents register allocation which fixes:
-        *   warning: variable 'xxx' might be clobbered by 'longjmp' or 'vfork'
-        */
-       struct buffered_data *volatile in = NULL;
-       enum xsd_sockmsg_type volatile type = conn->in->hdr.msg.type;
        jmp_buf talloc_fail;
+
+       if (verbose)
+               xprintf("Got message %s len %i from %p\n",
+                       sockmsg_string(conn->in->hdr.msg.type),
+                       conn->in->hdr.msg.len, conn);
 
        /* For simplicity, we kill the connection on OOM. */
        talloc_set_fail_handler(out_of_mem, &talloc_fail);
        if (setjmp(talloc_fail)) {
-               /* Free in before conn, in case it needs something. */
-               talloc_free(in);
                talloc_free(conn);
                goto end;
        }
 
-       if (verbose)
-               xprintf("Got message %s len %i from %p\n",
-                       sockmsg_string(type), conn->in->hdr.msg.len, conn);
-
-       /* Careful: process_message may free connection.  We detach
-        * "in" beforehand and allocate the new buffer to avoid
-        * touching conn after process_message.
-        */
-       in = talloc_steal(talloc_autofree_context(), conn->in);
+       process_message(conn, conn->in);
+
+       talloc_free(conn->in);
        conn->in = new_buffer(conn);
-       process_message(conn, in);
-
-       talloc_free(in);
+
 end:
        talloc_set_fail_handler(NULL, NULL);
        if (talloc_total_blocks(NULL)
@@ -1242,12 +1243,7 @@
 
 struct connection *new_connection(connwritefn_t *write, connreadfn_t *read)
 {
-       /*
-        * 'volatile' qualifier prevents register allocation which fixes:
-        *   warning: variable 'xxx' might be clobbered by 'longjmp' or 'vfork'
-        */
-       struct connection *volatile new;
-       jmp_buf talloc_fail;
+       struct connection *new;
 
        new = talloc(talloc_autofree_context(), struct connection);
        if (!new)
@@ -1262,13 +1258,11 @@
        INIT_LIST_HEAD(&new->watches);
        INIT_LIST_HEAD(&new->transaction_list);
 
-       talloc_set_fail_handler(out_of_mem, &talloc_fail);
-       if (setjmp(talloc_fail)) {
+       new->in = new_buffer(new);
+       if (new->in == NULL) {
                talloc_free(new);
                return NULL;
        }
-       new->in = new_buffer(new);
-       talloc_set_fail_handler(NULL, NULL);
 
        list_add_tail(&new->list, &connections);
        talloc_set_destructor(new, destroy_conn);

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Echo request and transaction identifiers in xenstored, Xen patchbot -unstable <=