diff options
author | Simon Rettberg | 2013-08-02 18:13:24 +0200 |
---|---|---|
committer | Simon Rettberg | 2013-08-02 18:13:24 +0200 |
commit | 762f7a4d7b3155254416b460c28a23c418ae59ed (patch) | |
tree | fb904393252a9f5688d2327c8c04965edf6c505b /src/server/globals.c | |
parent | fix0rs (diff) | |
download | dnbd3-762f7a4d7b3155254416b460c28a23c418ae59ed.tar.gz dnbd3-762f7a4d7b3155254416b460c28a23c418ae59ed.tar.xz dnbd3-762f7a4d7b3155254416b460c28a23c418ae59ed.zip |
[SERVER] several improvements
1) Close uplink if local copy is complete
2) Fix memleak when closing uplink (recv buffer was not cleared)
3) Add configurable artificial delays for client and server connections
Diffstat (limited to 'src/server/globals.c')
-rw-r--r-- | src/server/globals.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/server/globals.c b/src/server/globals.c index 182b2cc..1e23fb3 100644 --- a/src/server/globals.c +++ b/src/server/globals.c @@ -10,6 +10,8 @@ char *_configDir = NULL; char *_basePath = NULL; int _vmdkLegacyMode = FALSE; int _shutdown = 0; +int _serverPenalty = 0; +int _clientPenalty = 0; #define SAVE_TO_VAR_STR(ss, kk) do { if (strcmp(section, #ss) == 0 && strcmp(key, #kk) == 0) { if (_ ## kk != NULL) free(_ ## kk); _ ## kk = strdup(value); } } while (0) #define SAVE_TO_VAR_BOOL(ss, kk) do { if (strcmp(section, #ss) == 0 && strcmp(key, #kk) == 0) _ ## kk = atoi(value) != 0 || strcmp(value, "true") == 0 || strcmp(value, "True") == 0 || strcmp(value, "TRUE") == 0; } while (0) @@ -19,6 +21,8 @@ static int ini_handler(void *custom, const char* section, const char* key, const { SAVE_TO_VAR_STR( dnbd3, basePath ); SAVE_TO_VAR_BOOL( dnbd3, vmdkLegacyMode ); + SAVE_TO_VAR_INT( dnbd3, serverPenalty ); + SAVE_TO_VAR_INT( dnbd3, clientPenalty ); return TRUE; } @@ -40,4 +44,6 @@ void globals_loadConfig() char *end = _basePath + strlen( _basePath ) - 1; while ( end >= _basePath && *end == '/' ) *end-- = '\0'; + if ( _serverPenalty < 0 ) _serverPenalty = 0; + if ( _clientPenalty < 0 ) _clientPenalty = 0; } |