X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=device-src%2Fxfer-dest-taper-directtcp.c;fp=device-src%2Fxfer-dest-taper-directtcp.c;h=91738d012c725d4f40c25c524553463d8d4da422;hb=109540caa4e37a3663b3dcfb9a205b9609e3f561;hp=6d9d12d23cfc8d965b568b7780fedc4f0887e214;hpb=4c9eba1feb11adf189bceb4001c425e641f0b56a;p=debian%2Famanda diff --git a/device-src/xfer-dest-taper-directtcp.c b/device-src/xfer-dest-taper-directtcp.c index 6d9d12d..91738d0 100644 --- a/device-src/xfer-dest-taper-directtcp.c +++ b/device-src/xfer-dest-taper-directtcp.c @@ -1,6 +1,6 @@ /* * Amanda, The Advanced Maryland Automatic Network Disk Archiver - * Copyright (c) 2009, 2010 Zmanda, Inc. All Rights Reserved. + * Copyright (c) 2009-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 @@ -74,6 +74,7 @@ typedef struct XferDestTaperDirectTCP { * corresponding condition variable. */ volatile gboolean paused; GCond *paused_cond; + GCond *abort_accept_cond; /* condition to trigger to abort an accept */ } XferDestTaperDirectTCP; @@ -108,6 +109,7 @@ worker_thread( XferElement *elt = (XferElement *)data; XferDestTaperDirectTCP *self = (XferDestTaperDirectTCP *)data; GTimer *timer = g_timer_new(); + int result; /* This thread's job is to accept() an incoming connection, then call * write_from_connection for each part, and then close the connection */ @@ -124,12 +126,18 @@ worker_thread( /* first, accept a new connection from the device */ DBG(2, "accepting DirectTCP connection on device %s", self->device->device_name); - if (!device_accept(self->device, &self->conn, NULL, NULL)) { + result = device_accept_with_cond(self->device, &self->conn, + self->state_mutex, + self->abort_accept_cond); + if (result == 2) { xfer_cancel_with_error(XFER_ELEMENT(self), "accepting DirectTCP connection: %s", device_error_or_status(self->device)); g_mutex_unlock(self->state_mutex); return NULL; + } else if (result == 1) { + g_mutex_unlock(self->state_mutex); + return NULL; } DBG(2, "connection accepted; sending XMSG_READY"); @@ -327,6 +335,7 @@ cancel_impl( * longer paused */ g_mutex_lock(self->state_mutex); g_cond_broadcast(self->paused_cond); + g_cond_broadcast(self->abort_accept_cond); g_mutex_unlock(self->state_mutex); return rv; @@ -418,6 +427,7 @@ instance_init( self->conn = NULL; self->state_mutex = g_mutex_new(); self->paused_cond = g_cond_new(); + self->abort_accept_cond = g_cond_new(); } static void @@ -440,6 +450,7 @@ finalize_impl( g_mutex_free(self->state_mutex); g_cond_free(self->paused_cond); + g_cond_free(self->abort_accept_cond); if (self->part_header) dumpfile_free(self->part_header);