xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Vasiliy G Tolstov <v.tolstov@selfip.ru>
To: Ian Campbell <Ian.Campbell@citrix.com>
Cc: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: Re: use xs_watch from userspace and use epoll instead of select
Date: Fri, 03 Jun 2011 16:17:59 +0400	[thread overview]
Message-ID: <1307103479.15777.5.camel@vase> (raw)
In-Reply-To: <1307103239.775.382.camel@zakaz.uk.xensource.com>

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@selfip.ru>
Selfip.Ru

  reply	other threads:[~2011-06-03 12:17 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-03 12:04 use xs_watch from userspace and use epoll instead of select Vasiliy G Tolstov
2011-06-03 12:13 ` Ian Campbell
2011-06-03 12:17   ` Vasiliy G Tolstov [this message]
2011-06-03 16:07     ` Vasiliy G Tolstov
2011-06-06  8:41       ` Ian Campbell
2011-06-06  8:58         ` Vasiliy G Tolstov
2011-06-06  9:48           ` Ian Campbell
2011-06-06 10:05             ` Vasiliy G Tolstov
2011-06-06 11:00               ` Ian Campbell
2011-06-06 11:18                 ` Vasiliy G Tolstov
2011-06-06 11:26                   ` Ian Campbell

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=1307103479.15777.5.camel@vase \
    --to=v.tolstov@selfip.ru \
    --cc=Ian.Campbell@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).