All of lore.kernel.org
 help / color / mirror / Atom feed
From: Samuel Thibault <samuel.thibault@eu.citrix.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH] fs-back: terminate thread when domain gets destroyed
Date: Tue, 11 Mar 2008 13:49:50 +0000	[thread overview]
Message-ID: <20080311134950.GC5831@implementation.uk.xensource.com> (raw)

fs-back: terminate thread when domain gets destroyed
by periodically checking that the frontend xenstore nodes still exist

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>

diff -r 86e64b684fb2 tools/fs-back/fs-backend.c
--- a/tools/fs-back/fs-backend.c	Wed Mar 05 11:10:29 2008 +0000
+++ b/tools/fs-back/fs-backend.c	Tue Mar 11 13:47:40 2008 +0000
@@ -49,6 +49,7 @@ static void handle_aio_events(struct mou
     struct aiocb evtchn_cb;
     const struct aiocb * cb_list[mount->nr_entries];
     int request_ids[mount->nr_entries];
+    struct timespec timeout = { .tv_sec = 1, .tv_nsec = 0 };
 
     /* Prepare the AIO control block for evtchn */ 
     fd = xc_evtchn_fd(mount->evth); 
@@ -76,9 +77,11 @@ wait_again:
 
     /* Block till an AIO requset finishes, or we get an event */ 
     while(1) {
-	int ret = aio_suspend(cb_list, count, NULL);
+	int ret = aio_suspend(cb_list, count, &timeout);
 	if (!ret)
 	    break;
+        if (errno == EAGAIN)
+            return;
 	assert(errno == EINTR);
     }
     for(i=0; i<count; i++)
@@ -127,6 +130,9 @@ void* handle_mount(void *data)
 {
     int more, notify;
     struct mount *mount = (struct mount *)data;
+    char *state;
+    char node[1024];
+    sprintf(node, "%s/state", mount->frontend);
     
     printf("Starting a thread for mount: %d\n", mount->mount_id);
     allocate_request_array(mount);
@@ -172,14 +178,21 @@ moretodo:
 
             nr_consumed++;
         }
-        printf("Backend consumed: %d requests\n", nr_consumed);
+        if (nr_consumed)
+            printf("Backend consumed: %d requests\n", nr_consumed);
         RING_FINAL_CHECK_FOR_REQUESTS(&mount->ring, more);
         if(more) goto moretodo;
 
         RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(&mount->ring, notify);
-        printf("Pushed responces and notify=%d\n", notify);
+        //printf("Pushed responces and notify=%d\n", notify);
         if(notify)
             xc_evtchn_notify(mount->evth, mount->local_evtchn);
+
+        state = xs_read(xsh, XBT_NULL, node, NULL);
+        if (!state)
+            /* domain destroyed */
+            break;
+        free(state);
     }
  
     printf("Destroying thread for mount: %d\n", mount->mount_id);

             reply	other threads:[~2008-03-11 13:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-11 13:49 Samuel Thibault [this message]
2008-03-11 16:27 ` [PATCH] fs-back: terminate thread when domain gets destroyed Samuel Thibault

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080311134950.GC5831@implementation.uk.xensource.com \
    --to=samuel.thibault@eu.citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.