X-Git-Url: https://git.gag.com/?p=debian%2Famanda;a=blobdiff_plain;f=xfer-src%2Fxfer.h;h=a1f378cb76155c772422df46a9604dcabd508bf9;hp=fb769d42457199db252a42efbc0c0c3ce4e97b18;hb=b116e9366c7b2ea2c2eb53b0a13df4090e176235;hpb=fd48f3e498442f0cbff5f3606c7c403d0566150e diff --git a/xfer-src/xfer.h b/xfer-src/xfer.h index fb769d4..a1f378c 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; @@ -215,4 +219,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 */