diff options
-rw-r--r-- | src/server/altservers.c | 3 | ||||
-rw-r--r-- | src/server/image.c | 5 | ||||
-rw-r--r-- | src/server/uplink.c | 2 |
3 files changed, 7 insertions, 3 deletions
diff --git a/src/server/altservers.c b/src/server/altservers.c index 44061a3..49da7d4 100644 --- a/src/server/altservers.c +++ b/src/server/altservers.c @@ -62,6 +62,7 @@ int altservers_load() if ( altservers_add( &host, space ) ) ++count; } fclose( fp ); + printf( "[DEBUG] Added %d alt servers\n", count ); return count; } @@ -414,11 +415,13 @@ static void *altserver_main(void *data) // Done testing all servers. See if we should switch if ( bestSock != -1 && (uplink->fd == -1 || (bestRtt < 10000000 && RTT_THRESHOLD_FACTOR(currentRtt) > bestRtt)) ) { // yep + printf( "DO CHANGE: best: %uµs, current: %uµs\n", bestRtt, currentRtt ); uplink->betterFd = bestSock; uplink->betterServer = servers[bestIndex]; uplink->rttTestResult = RTT_DOCHANGE; } else { // nope + printf( "DONT CHANGE: best: %uµs, current: %uµs\n", bestRtt, currentRtt ); if ( bestSock != -1 ) close( bestSock ); uplink->rttTestResult = RTT_DONTCHANGE; } diff --git a/src/server/image.c b/src/server/image.c index 6b6fb99..d4ed5cf 100644 --- a/src/server/image.c +++ b/src/server/image.c @@ -332,12 +332,13 @@ static int image_try_load(char *base, char *path) assert( path != NULL ); assert( *path == '/' ); assert( strncmp( path, base, strlen(base)) == 0 ); - assert( base[strlen(base) - 1] == '/' ); + assert( base[strlen(base) - 1] != '/' ); + assert( strlen(path) > strlen(base) ); char *lastSlash = strrchr( path, '/' ); char *fileName = lastSlash + 1; char imgName[strlen( path )]; const int fileNameLen = strlen( fileName ); - char * const virtBase = path + strlen( base ); + char * const virtBase = path + strlen( base ) + 1; // Copy virtual path assert( *virtBase != '/' ); char *src = virtBase, *dst = imgName; diff --git a/src/server/uplink.c b/src/server/uplink.c index 9896e49..3541728 100644 --- a/src/server/uplink.c +++ b/src/server/uplink.c @@ -238,7 +238,7 @@ static void* uplink_mainloop(void *data) // more to do here } // See if we should trigger a RTT measurement - if ( link->rttTestResult == RTT_IDLE ) { + if ( link->rttTestResult == RTT_IDLE || link->rttTestResult == RTT_DONTCHANGE ) { const time_t now = time( NULL ); if ( nextAltCheck - now > SERVER_RTT_DELAY_MAX ) { nextAltCheck = now + SERVER_RTT_DELAY_MAX; |