summaryrefslogtreecommitdiffstats
path: root/src/server/image.c
diff options
context:
space:
mode:
authorSimon Rettberg2019-08-07 17:11:51 +0200
committerSimon Rettberg2019-08-07 17:11:51 +0200
commitbe7d7d95850c30a154aaa56e95d6a7f36793409d (patch)
tree53bcae440652076d53cb01bfb7ee73fc2d868283 /src/server/image.c
parent[SERVER] Lock-free queue for altservers check thread (diff)
downloaddnbd3-be7d7d95850c30a154aaa56e95d6a7f36793409d.tar.gz
dnbd3-be7d7d95850c30a154aaa56e95d6a7f36793409d.tar.xz
dnbd3-be7d7d95850c30a154aaa56e95d6a7f36793409d.zip
[SERVER] Better lock debugging: Always check lock order
Lock order is predefined in locks.h. Immediately bail out if a lock with lower priority is obtained while the same thread already holds one with higher priority.
Diffstat (limited to 'src/server/image.c')
-rw-r--r--src/server/image.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/server/image.c b/src/server/image.c
index 1f12eda..4a65ed3 100644
--- a/src/server/image.c
+++ b/src/server/image.c
@@ -59,9 +59,9 @@ static bool image_checkRandomBlocks(const int count, int fdImage, const int64_t
void image_serverStartup()
{
srand( (unsigned int)time( NULL ) );
- mutex_init( &imageListLock );
- mutex_init( &remoteCloneLock );
- mutex_init( &reloadLock );
+ mutex_init( &imageListLock, LOCK_IMAGE_LIST );
+ mutex_init( &remoteCloneLock, LOCK_REMOTE_CLONE );
+ mutex_init( &reloadLock, LOCK_RELOAD );
}
/**
@@ -347,7 +347,7 @@ dnbd3_image_t* image_get(char *name, uint16_t revision, bool checkIfWorking)
img->rid = candidate->rid;
img->users = 1;
img->working = false;
- mutex_init( &img->lock );
+ mutex_init( &img->lock, LOCK_IMAGE );
if ( candidate->crc32 != NULL ) {
const size_t mb = IMGSIZE_TO_HASHBLOCKS( candidate->virtualFilesize ) * sizeof(uint32_t);
img->crc32 = malloc( mb );
@@ -869,7 +869,7 @@ static bool image_load(char *base, char *path, int withUplink)
image->working = (image->cache_map == NULL );
timing_get( &image->nextCompletenessEstimate );
image->completenessEstimate = -1;
- mutex_init( &image->lock );
+ mutex_init( &image->lock, LOCK_IMAGE );
int32_t offset;
if ( stat( path, &st ) == 0 ) {
// Negatively offset atime by file modification time