diff options
| author | Simon Rettberg | 2015-11-23 11:11:59 +0100 |
|---|---|---|
| committer | Simon Rettberg | 2015-11-23 11:11:59 +0100 |
| commit | 7e0668d1e4f78a0c7ff8689b197e2c104ce569e4 (patch) | |
| tree | d013004c6183bb3d946f7a22a528a0571872725b /src/server/altservers.c | |
| parent | [FUSE] Refactoring (diff) | |
| download | dnbd3-7e0668d1e4f78a0c7ff8689b197e2c104ce569e4.tar.gz dnbd3-7e0668d1e4f78a0c7ff8689b197e2c104ce569e4.tar.xz dnbd3-7e0668d1e4f78a0c7ff8689b197e2c104ce569e4.zip | |
[SERVER] Fix race condition potentially leading to use after release
Diffstat (limited to 'src/server/altservers.c')
| -rw-r--r-- | src/server/altservers.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/server/altservers.c b/src/server/altservers.c index 8eb07ec..7a2aaf7 100644 --- a/src/server/altservers.c +++ b/src/server/altservers.c @@ -379,9 +379,9 @@ static void *altservers_main(void *data UNUSED) } // Work your way through the queue for (itLink = 0; itLink < SERVER_MAX_PENDING_ALT_CHECKS; ++itLink) { - dnbd3_connection_t * const uplink = pending[itLink]; - if ( uplink == NULL ) continue; // Check once before locking, as a mutex is expensive + if ( pending[itLink] == NULL ) continue; // Check once before locking, as a mutex is expensive pthread_mutex_lock( &pendingLockConsume ); + dnbd3_connection_t * const uplink = pending[itLink]; if ( uplink == NULL ) { // Check again after locking pthread_mutex_unlock( &pendingLockConsume ); continue; |
