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-devel

Re: [Xen-devel] use xs_watch from userspace and use epoll instead of sel

To: Ian Campbell <Ian.Campbell@xxxxxxxxxx>
Subject: Re: [Xen-devel] use xs_watch from userspace and use epoll instead of select
From: Vasiliy G Tolstov <v.tolstov@xxxxxxxxx>
Date: Fri, 03 Jun 2011 16:17:59 +0400
Cc: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Fri, 03 Jun 2011 05:18:45 -0700
Dkim-signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=selfip.ru; s=dk; h=Content-Transfer-Encoding:Mime-Version:Message-ID:Date:Content-Type:References:In-Reply-To:Cc:To:Reply-To:From:Subject; bh=9hCY9vd8M2372kuN2r08fpLfjy4c5o5b548vFkMX3rY=; b=AyT0pwt6gDS+4UFZcYLlRNC6vIQVfG60wLN5w8k1Zu7D+YFt1R/gXEYI3bM6dEuZzSKOF+BKf/CfRqpBLk3gL4pRNeRlhL/hjwINFpCANwsyBh7BkukWyL2vu8IPUR9d;
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <1307103239.775.382.camel@xxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: Selfip.Ru
References: <1307102689.15777.3.camel@vase> <1307103239.775.382.camel@xxxxxxxxxxxxxxxxxxxxxx>
Reply-to: v.tolstov@xxxxxxxxx
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
On Fri, 2011-06-03 at 13:13 +0100, Ian Campbell wrote:
> On Fri, 2011-06-03 at 13:04 +0100, Vasiliy G Tolstov wrote:
> > Hello. I have some examples of usage xs_watch in userspace that contains
> > loop with select function usage. If i use epoll, no events returned from
> > epoll_wait...
> > Does it matter to use select from fd that used for watch?
> > epoll fd added with ev.events = (EPOLLIN | EPOLLPRI | EPOLLONESHOT);
> 
> I think you need to provide an example of the code which doesn't work.
> 
> Ian.
> 

This is not work:
  if ((err = xs_watch(stats->xs, "data/xenmgm", "xenmgm")) != 0) {
    log_error("failed to create xenstore watch on path: %s, error: %s",
"data/xenmgm", strerror(err));
  }
  fd = xs_fileno(stats->xs);
  xen_events = malloc(sizeof(struct epoll_event));
  memset(xen_events, 0, sizeof(struct epoll_event));
  if ((epfd = epoll_create(1)) < 0) {
    log_error("%s", "failed epoll_create");
    return -1;
  }
  ev.data.fd = fd;
  ev.events = (EPOLLIN | EPOLLPRI | EPOLLONESHOT);
  if ((err = epoll_ctl(epfd, EPOLL_CTL_ADD, fd, &ev)) < 0) {
    log_error("%s", "failed add event via epoll_ctl");
    return err;
  }
  if ((err = pthread_create(&(stats->xen_in_tid), &attr,
&stats_in_tfunc, mod->data)) != 0) {
    log_error("failed to create thread: %s", strerror(err));
    return err;
  }
  if ((err = pthread_detach(stats->xen_in_tid)) != 0) {
    log_error("failed to detach thread: %s", strerror(err));
    return err;
  }


in stats_in_tfunc i'm use this, but looping2 never happening
 for (;;) {
    log_debug("%s", "looping1");
    if ((nr_events = epoll_wait(epfd, xen_events, 10, -1)) < 0) {
      log_error("%s", "failed epoll_wait");
      return NULL;
    }
    log_debug("%s", "looping1");
}



-- 
Vasiliy G Tolstov <v.tolstov@xxxxxxxxx>
Selfip.Ru


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