Hello Xen Folks, Why do have the structure xs_handle declared and defined in file Xs.c and not to a header file? Was there an intention not to modify the structure externally? If I end up copying this structure to my Application, I also need to have the list.h header file which I believe is again not exported from Xen. Any idea how to do this cleanly without duplicating the list.h header or anything else. My intent of having this structure is to modify the fd and "pthread_cond_t watch_condvar;" from this structure externally to suit my application. Shakil _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
Ian Campbell
2013-Aug-30 09:59 UTC
Re: Why xs_handle is not part of header rather xs.c file
On Thu, 2013-08-29 at 13:16 -0700, Shakil k wrote:> Hello Xen Folks, > > > Why do have the structure xs_handle declared and defined in file Xs.c > and not to a header file? > Was there an intention not to modify the structure externally?Yes, there is nothing in there which an application should require direct access too therefore it is deliberately an opaque handle.> My intent of having this structure is to modify the fd and > "pthread_cond_t watch_condvar;" > from this structure externally to suit my application.This sounds wrong to me. Why do you (think you) need to do this? Ian.
On Fri, Aug 30, 2013 at 2:59 AM, Ian Campbell <Ian.Campbell@citrix.com>wrote:> On Thu, 2013-08-29 at 13:16 -0700, Shakil k wrote: > > Hello Xen Folks, > > > > > > Why do have the structure xs_handle declared and defined in file Xs.c > > and not to a header file? > > Was there an intention not to modify the structure externally? > > Yes, there is nothing in there which an application should require > direct access too therefore it is deliberately an opaque handle. > > > My intent of having this structure is to modify the fd and > > "pthread_cond_t watch_condvar;" > > from this structure externally to suit my application. > > This sounds wrong to me. Why do you (think you) need to do this? > > The reason being for watch functionality we have n number of timesto watch for. However it doesn''t have a timeout. What if my program waiting for watch and the data is never delivered as the client died or crashed. So I would like to register a signal handler in my top level watch of application and on timeout a signal will be generated which will modify the fd and also condvar_signal(&xs->watch_condvar); so that my application can do watch based on timeout as well as iteration. Shakil> Ian. > >_______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
Ian Campbell
2013-Sep-02 08:29 UTC
Re: Why xs_handle is not part of header rather xs.c file
On Fri, 2013-08-30 at 09:58 -0700, Shakil k wrote:> > The reason being for watch functionality we have n number of times to watch for. However > it doesn''t have a timeout. What if my program waiting for watch and the data is never delivered > as the client died or crashed.You use xs_fileno() to get an fd which you can then use select(2) or poll(2) with a timeout on. Ian.
On Mon, Sep 2, 2013 at 1:29 AM, Ian Campbell <Ian.Campbell@citrix.com>wrote:> On Fri, 2013-08-30 at 09:58 -0700, Shakil k wrote: > > > > > The reason being for watch functionality we have n number of > times to watch for. However > > it doesn''t have a timeout. What if my program waiting for watch > and the data is never delivered > > as the client died or crashed. > > You use xs_fileno() to get an fd which you can then use select(2) or > poll(2) with a timeout on.Ian.>This doesn''t work, as per the below code. I can never see the data coming to select if I do xenstore-watch on the node from other terminal on the same dom0. Do we need to do xs_watch before calling select? and why so? struct xs_handle *xen_handle; xs_transaction_t xen_transact; int xen_fd; int xenstore_initialized = 0; int xenstore_watch(const char *path, struct timeval *Timeout) { int status = 0; fd_set set; fd_set set1; int error; char **vec; unsigned int num_strings; static int watch_counter=0; static int counter=0; //INIT xen_handle = xs_daemon_open(); xen_fd = xs_fileno(xen_handle); FD_ZERO(&set); FD_SET(xen_fd, &set); FD_ZERO(&set1); FD_SET(xen_fd, &set1); if ( select(xen_fd + 1, &set, &set1, NULL, Timeout) != -1) { printf("Data is availabale after select\n"); } return 0; } _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel