X-Git-Url: https://git.gag.com/?p=debian%2Famanda;a=blobdiff_plain;f=xfer-src%2Fxfer.c;h=5f7a6fbe27a2e35716a01f4bbdf1f8ca35a03925;hp=55dbd08729da71c4b783a6db3b81e237218ed352;hb=b116e9366c7b2ea2c2eb53b0a13df4090e176235;hpb=fd48f3e498442f0cbff5f3606c7c403d0566150e diff --git a/xfer-src/xfer.c b/xfer-src/xfer.c index 55dbd08..5f7a6fb 100644 --- a/xfer-src/xfer.c +++ b/xfer-src/xfer.c @@ -18,9 +18,9 @@ * Sunnyvale, CA 94085, USA, or: http://www.zmanda.com */ +#include "amanda.h" #include "amxfer.h" #include "element-glue.h" -#include "amanda.h" #include "arglist.h" /* XMsgSource objects are GSource "subclasses" which manage @@ -56,6 +56,7 @@ xfer_new( xfer->status = XFER_INIT; xfer->status_mutex = g_mutex_new(); xfer->status_cond = g_cond_new(); + xfer->fd_mutex = g_mutex_new(); xfer->refcount = 1; xfer->repr = NULL; @@ -116,6 +117,7 @@ xfer_unref( g_mutex_free(xfer->status_mutex); g_cond_free(xfer->status_cond); + g_mutex_free(xfer->fd_mutex); /* Free our references to the elements, and also set the 'xfer' * attribute of each to NULL, making them "unattached" (although @@ -698,3 +700,17 @@ xfer_cancel_with_error( xfer_cancel(elt->xfer); } +gint +xfer_atomic_swap_fd(Xfer *xfer, gint *fdp, gint newfd) +{ + gint rv; + + if (xfer) + g_mutex_lock(xfer->fd_mutex); + rv = *fdp; + *fdp = newfd; + if (xfer) + g_mutex_unlock(xfer->fd_mutex); + + return rv; +}