Merge tag 'upstream/3.3.3'
[debian/amanda] / xfer-src / xfer-element.c
index dd94e3ca126faafa4ca3ffd055c5fdae49e08ec5..d23779f79ad72c99409c5995f7b736a4835a7d58 100644 (file)
@@ -1,10 +1,11 @@
 /*
  * 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
- * by the Free Software Foundation.
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
@@ -238,11 +239,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);