/*
- * Copyright (c) 2007, 2008, 2009, 2010 Zmanda, Inc. All Rights Reserved.
+ * Copyright (c) 2007-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
}
pself->block++;
+ g_mutex_lock(pself->device_mutex);
+ pself->bytes_written += size;
+ g_mutex_unlock(pself->device_mutex);
return TRUE;
}
case RESULT_SUCCESS:
*size_req = size;
pself->block++;
+ g_mutex_lock(pself->device_mutex);
+ pself->bytes_read += size;
+ g_mutex_unlock(pself->device_mutex);
return size;
case RESULT_SMALL_BUFFER: {
gsize new_size;
}
case RESULT_NO_DATA:
pself->is_eof = TRUE;
+ g_mutex_lock(pself->device_mutex);
pself->in_file = FALSE;
+ g_mutex_unlock(pself->device_mutex);
device_set_error(pself,
stralloc(_("EOF")),
DEVICE_STATUS_SUCCESS);
}
d_self->access_mode = mode;
+ g_mutex_lock(d_self->device_mutex);
d_self->in_file = FALSE;
+ g_mutex_unlock(d_self->device_mutex);
if (IS_WRITABLE_ACCESS_MODE(mode)) {
if (self->write_open_errno != 0) {
amfree(amanda_header);
/* arrange the file numbers correctly */
- d_self->in_file = TRUE;
d_self->block = 0;
if (d_self->file >= 0)
d_self->file ++;
+ g_mutex_lock(d_self->device_mutex);
+ d_self->in_file = TRUE;
+ d_self->bytes_written = 0;
+ g_mutex_unlock(d_self->device_mutex);
return TRUE;
}
return FALSE;
}
+ g_mutex_lock(d_self->device_mutex);
d_self->in_file = FALSE;
+ g_mutex_unlock(d_self->device_mutex);
return TRUE;
}
difference --;
}
- d_self->in_file = FALSE;
d_self->is_eof = FALSE;
d_self->block = 0;
+ g_mutex_lock(d_self->device_mutex);
+ d_self->in_file = FALSE;
+ d_self->bytes_read = 0;
+ g_mutex_unlock(d_self->device_mutex);
reseek:
if (difference > 0) {
return NULL;
}
+ g_mutex_lock(d_self->device_mutex);
d_self->in_file = TRUE;
+ g_mutex_unlock(d_self->device_mutex);
d_self->file = file;
return rval;
}
/* Polish off this file, if relevant. */
+ g_mutex_lock(d_self->device_mutex);
if (d_self->in_file && IS_WRITABLE_ACCESS_MODE(d_self->access_mode)) {
- if (!device_finish_file(d_self))
+ g_mutex_unlock(d_self->device_mutex);
+ if (!device_finish_file(d_self)) {
goto finish_error;
+ }
+ } else {
+ g_mutex_unlock(d_self->device_mutex);
}
/* Straighten out the filemarks. We already wrote one in finish_file, and