X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=xfer-src%2Fxfer.h;h=3d6773a02f969d3684ce91f64282c177747d3389;hb=911bfb4415195b5c0a98b8c957caa8968313fd81;hp=fb769d42457199db252a42efbc0c0c3ce4e97b18;hpb=fd48f3e498442f0cbff5f3606c7c403d0566150e;p=debian%2Famanda diff --git a/xfer-src/xfer.h b/xfer-src/xfer.h index fb769d4..3d6773a 100644 --- a/xfer-src/xfer.h +++ b/xfer-src/xfer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008,2009 Zmanda, Inc. All Rights Reserved. + * Copyright (c) 2008, 2009, 2010 Zmanda, Inc. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published @@ -86,6 +86,10 @@ struct Xfer { /* Number of active elements remaining (a.k.a. the number of * XMSG_DONE messages to expect) */ gint num_active_elements; + + /* Used to coordinate handing off file descriptors among elements of this + * xfer */ + GMutex *fd_mutex; }; typedef struct Xfer Xfer; @@ -154,8 +158,10 @@ char *xfer_repr(Xfer *xfer); * correctly). * * @param xfer: the Xfer object + * @param offset: the offset to start the transfer from (must be 0) + * @param size: the Xfer object: the number of bytes to transfer. */ -void xfer_start(Xfer *xfer); +void xfer_start(Xfer *xfer, gint64 offset, gint64 size); /* Abort a running transfer. This essentially tells the source to stop * producing data and allows the remainder of the transfer to "drain". Thus @@ -215,4 +221,16 @@ xfer_status wait_until_xfer_running(Xfer *xfer); void xfer_cancel_with_error(struct XferElement *elt, const char *fmt, ...) G_GNUC_PRINTF(2,3); +/* Return the fd in *FDP and set *FDP to NEWFD, all in one step. The operation + * is atomic with respect to all other such operations in this transfer, making + * this a good way to "move" a file descriptor from one element to another. If + * xfer is NULL, the operation proceeds with no locking. + * + * @param xfer: the xfer within which this fd is used + * @param fdp: pointer to the file descriptor to swap + * @param newfd: the new value for *FDP + * @returns: the previous contents of *fdp (may be -1) + */ +gint xfer_atomic_swap_fd(Xfer *xfer, gint *fdp, gint newfd); + #endif /* XFER_H */