X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=xfer-src%2Fxfer-element.c;fp=xfer-src%2Fxfer-element.c;h=37e3377de8cea3bee41eca649318a71608bec55d;hb=949b8910a5e23c4285d0b1aedacfc82a14dc97a5;hp=dd94e3ca126faafa4ca3ffd055c5fdae49e08ec5;hpb=c6f0a88c567f8536c498f554285aed1f8150da18;p=debian%2Famanda diff --git a/xfer-src/xfer-element.c b/xfer-src/xfer-element.c index dd94e3c..37e3377 100644 --- a/xfer-src/xfer-element.c +++ b/xfer-src/xfer-element.c @@ -1,6 +1,6 @@ /* * Amanda, The Advanced Maryland Automatic Network Disk Archiver - * Copyright (c) 2008, 2009, 2010 Zmanda, Inc. All Rights Reserved. + * Copyright (c) 2008-2012 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 @@ -238,11 +238,15 @@ xfer_element_pull_buffer( XferElement *elt, size_t *size) { + xfer_status status; /* Make sure that the xfer is running before calling upstream's * pull_buffer method; this avoids a race condition where upstream * hasn't finished its xfer_element_start yet, and isn't ready for * a pull */ - if (elt->xfer->status == XFER_START) + g_mutex_lock(elt->xfer->status_mutex); + status = elt->xfer->status; + g_mutex_unlock(elt->xfer->status_mutex); + if (status == XFER_START) wait_until_xfer_running(elt->xfer); return XFER_ELEMENT_GET_CLASS(elt)->pull_buffer(elt, size);