[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH 27/31] libxl: provide libxl__datacopier_*
On Tue, 2012-04-10 at 20:08 +0100, Ian Jackson wrote: > General facility for ao operations to shovel data between fds. > > This will be used by the bootloader machinery. > > Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> [...] > +static void datacopier_writable(libxl__egc *egc, libxl__ev_fd *ev, > + int fd, short events, short revents); > + > +static void datacopier_check_state(libxl__egc *egc, libxl__datacopier_state > *dc) > +{ > + STATE_AO_GC(dc); > + int rc; > + > + if (dc->used) { > + if (!libxl__ev_fd_isregistered(&dc->towrite)) { > + rc = libxl__ev_fd_register(gc, &dc->towrite, datacopier_writable, > + dc->writefd, POLLOUT); > + if (rc) { > + LOG(ERROR, "unable to establish write event on %s" > + " during copy of %s", dc->writewhat, dc->copywhat); > + datacopier_callback(egc, dc, -1, 0); > + return; > + } > + } > + } else if (!libxl__ev_fd_isregistered(&dc->toread)) { > + /* we have had eof */ > + libxl__datacopier_kill(dc); > + dc->callback(egc, dc, 0, 0); This looks like an open coded datacopier_callback(). [...] > @@ -1455,6 +1456,45 @@ int libxl__carefd_close(libxl__carefd*); > int libxl__carefd_fd(const libxl__carefd*); > > > +/*----- datacopier: copies data from one fd to another -----*/ > + > +typedef struct libxl__datacopier_state libxl__datacopier_state; > +typedef struct libxl__datacopier_buf libxl__datacopier_buf; > + > +/* onwrite==1 means failure happened when writing, logged, errno is valid > + * onwrite==0 means failure happened when reading > + * errno==0 means we got eof and all data was written > + * errno!=0 means we had a read error, logged ITYM errnoval in every case here rather than actual errno ? > + * onwrite==-1 means some other internal failure, errnoval not valid, logged > + * in all cases copier is killed before calling this callback */ > +typedef void libxl__datacopier_callback(libxl__egc *egc, > + libxl__datacopier_state *dc, int onwrite, int errnoval); > + Ian. _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |