X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=device-src%2Frait-device.c;h=dda81fb1c9b3d9c12c0f75a1037ddc76ac287afb;hb=refs%2Ftags%2Fupstream%2F3.3.1;hp=e8e8f2e658e89b17cc93c3e0b130cfdce0b0289b;hpb=cd0b924f27312d57bd42f6c4fae2b795139e2d0b;p=debian%2Famanda diff --git a/device-src/rait-device.c b/device-src/rait-device.c index e8e8f2e..dda81fb 100644 --- a/device-src/rait-device.c +++ b/device-src/rait-device.c @@ -28,7 +28,7 @@ #include "glib-util.h" #include "device.h" #include "fileheader.h" -#include "semaphore.h" +#include "amsemaphore.h" /* Just a note about the failure mode of different operations: - Recovers from a failure (enters degraded mode) @@ -115,7 +115,7 @@ typedef struct RaitDevicePrivate_s { /* value of this semaphore is the number of threaded operations * in progress */ - semaphore_t *threads_sem; + amsemaphore_t *threads_sem; #endif } RaitDevicePrivate; @@ -286,7 +286,7 @@ rait_device_finalize(GObject *obj_self) } if (PRIVATE(self)->threads_sem) - semaphore_free(PRIVATE(self)->threads_sem); + amsemaphore_free(PRIVATE(self)->threads_sem); #endif amfree(self->private); } @@ -426,7 +426,7 @@ static gpointer rait_thread_pool_func(gpointer data) { inf->data = NULL; /* indicate that we're finished; will not block */ - semaphore_down(inf->private->threads_sem); + amsemaphore_down(inf->private->threads_sem); } } g_mutex_unlock(inf->mutex); @@ -437,7 +437,7 @@ static void do_thread_pool_op(RaitDevice *self, GFunc func, GPtrArray * ops) { guint i; if (PRIVATE(self)->threads_sem == NULL) - PRIVATE(self)->threads_sem = semaphore_new_with_value(0); + PRIVATE(self)->threads_sem = amsemaphore_new_with_value(0); if (PRIVATE(self)->threads == NULL) PRIVATE(self)->threads = g_array_sized_new(FALSE, TRUE, @@ -449,7 +449,7 @@ static void do_thread_pool_op(RaitDevice *self, GFunc func, GPtrArray * ops) { g_array_set_size(PRIVATE(self)->threads, ops->len); /* the semaphore will hit zero when each thread has decremented it */ - semaphore_force_set(PRIVATE(self)->threads_sem, ops->len); + amsemaphore_force_set(PRIVATE(self)->threads_sem, ops->len); for (i = 0; i < ops->len; i++) { ThreadInfo *inf = &g_array_index(PRIVATE(self)->threads, ThreadInfo, i); @@ -469,7 +469,7 @@ static void do_thread_pool_op(RaitDevice *self, GFunc func, GPtrArray * ops) { } /* wait until semaphore hits zero */ - semaphore_wait_empty(PRIVATE(self)->threads_sem); + amsemaphore_wait_empty(PRIVATE(self)->threads_sem); } #else /* USE_INTERNAL_THREADPOOL */ @@ -1134,6 +1134,7 @@ static DeviceStatusFlags rait_device_read_label(Device * dself) { if (first_success->volume_header != NULL) { dself->volume_header = dumpfile_copy(first_success->volume_header); } + dself->header_block_size = first_success->header_block_size; } g_ptr_array_free_full(ops); @@ -1300,6 +1301,12 @@ rait_device_start (Device * dself, DeviceAccessMode mode, char * label, } } + if (total_status == DEVICE_STATUS_SUCCESS) { + StartOp * op = g_ptr_array_index(ops, 0); + Device *child = op->base.child; + dself->header_block_size = child->header_block_size; + } + amfree(label_from_device); g_ptr_array_free_full(ops); @@ -1309,7 +1316,6 @@ rait_device_start (Device * dself, DeviceAccessMode mode, char * label, device_set_error(dself, failure_errmsgs, total_status); return FALSE; } - amfree(failure_errmsgs); return TRUE; }