diff options
author | Simon Rettberg | 2015-12-17 14:20:12 +0100 |
---|---|---|
committer | Simon Rettberg | 2015-12-17 14:20:12 +0100 |
commit | 3de54fac10b3dbdcfc3573e175078c7104837ef3 (patch) | |
tree | 307abe2cc283900c0ce0594c7d40d833d8b27c92 /src/server/uplink.c | |
parent | [SERVER] Cancel scanning of image dir if _shutdown is set (diff) | |
download | dnbd3-3de54fac10b3dbdcfc3573e175078c7104837ef3.tar.gz dnbd3-3de54fac10b3dbdcfc3573e175078c7104837ef3.tar.xz dnbd3-3de54fac10b3dbdcfc3573e175078c7104837ef3.zip |
[SERVER] image_markComplete now handles locking so we remove() unlocked
Diffstat (limited to 'src/server/uplink.c')
-rw-r--r-- | src/server/uplink.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/server/uplink.c b/src/server/uplink.c index fa95fba..8be8e5a 100644 --- a/src/server/uplink.c +++ b/src/server/uplink.c @@ -314,13 +314,14 @@ static void* uplink_mainloop(void *data) if ( waitTime > 5000 ) waitTime = 5000; numSocks = epoll_wait( fdEpoll, events, MAXEVENTS, waitTime ); if ( _shutdown || link->shutdown ) goto cleanup; - if ( numSocks < 0 ) { // Error? + if ( numSocks == -1 ) { // Error? + if ( errno == EINTR ) continue; logadd( LOG_DEBUG1, "epoll_wait() error %d", (int)errno); usleep( 10000 ); continue; } // Check all events - for (i = 0; i < numSocks; ++i) { + for ( i = 0; i < numSocks; ++i ) { // Check for errors.... if ( (events[i].events & (EPOLLERR | EPOLLHUP | EPOLLRDHUP)) || !(events[i].events & EPOLLIN) ) { if ( events[i].data.fd == link->signal ) { @@ -362,7 +363,7 @@ static void* uplink_mainloop(void *data) const time_t now = time( NULL ); // Send keep alive if nothing is happening if ( link->fd != -1 && link->replicationHandle == 0 && now > nextKeepalive ) { - nextKeepalive = now + 29; + nextKeepalive = now + 20; if ( !uplink_sendKeepalive( link->fd ) ) { const int fd = link->fd; link->fd = -1; @@ -379,11 +380,8 @@ static void* uplink_mainloop(void *data) if ( image_isComplete( link->image ) ) { // Quit work if image is complete logadd( LOG_INFO, "Replication of %s complete.", link->image->lower_name ); - if ( spin_trylock( &link->image->lock ) == 0 ) { - image_markComplete( link->image ); - spin_unlock( &link->image->lock ); - goto cleanup; - } + image_markComplete( link->image ); + goto cleanup; } else { // Not complete - do measurement altservers_findUplink( link ); // This will set RTT_INPROGRESS (synchronous) |