From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Campbell Subject: Re: [PATCH 08/23] libxl: events: Provide libxl__xswait_* Date: Thu, 19 Dec 2013 13:05:30 +0000 Message-ID: <1387458330.9925.67.camel@kazak.uk.xensource.com> References: <1387305337-15355-1-git-send-email-ian.jackson@eu.citrix.com> <1387305337-15355-9-git-send-email-ian.jackson@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1387305337-15355-9-git-send-email-ian.jackson@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Jackson Cc: Shriram Rajagopalan , George Dunlap , xen-devel@lists.xensource.com, Stefano Stabellini List-Id: xen-devel@lists.xenproject.org On Tue, 2013-12-17 at 18:35 +0000, Ian Jackson wrote: > +/*----- xswait: wait for a xenstore node to be suitable -----*/ > + > +typedef struct libxl__xswait_state libxl__xswait_state; > + > +/* > + * rc describes the circumstances of this callback: > + * > + * rc==0 > + * > + * The xenstore path (may have) changed. It has been read for > + * you. The result is in data (allocated from the ao gc). > + * data may be NULL, which means that the xenstore read gave > + * ENOENT. > + * > + * If you are satisfied, you MUST call libxl__xswait_stop. > + * Otherwise, xswait will continue waiting and watching and > + * will call you back later. > + * > + * rc==ETIMEDOUT Isn't rc actual a libxl error and hence ERROR_TIMEDOUT? > + * > + * The specified timeout was reached. > + * This has NOT been logged (except to the debug log). > + * xswait will not continue (but calling libxl__xswait_stop is OK). > + * > + * rc!=0 also != E{,RROR_}TIMEDOUT > + * > + * Some other error occurred. > + * This HAS been logged. > + * xswait will not continue (but calling libxl__xswait_stop is OK). > + * > + */ > +typedef void libxl__xswait_callback(libxl__egc *egc, > + libxl__xswait_state *xswa, int rc, const char *data); > + > +struct libxl__xswait_state { > + /* caller must fill these in, and they must all remain valid */ > + libxl__ao *ao; > + const char *what; /* for error msgs: noun phrase, what we're waiting for */ > + const char *path; > + int timeout_ms; /* as for poll(2) */ > + libxl__xswait_callback *callback; > + /* remaining fields are private to xswait */ > + libxl__ev_time time_ev; > + libxl__ev_xswatch watch_ev; > +}; > + > +void libxl__xswait_init(libxl__xswait_state*); > +void libxl__xswait_stop(libxl__gc*, libxl__xswait_state*); /*idempotent*/ > +bool libxl__xswait_inuse(const libxl__xswait_state *ss); > + > +int libxl__xswait_start(libxl__gc*, libxl__xswait_state*); > + > /* > *----- spawn ----- > *