summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2013-08-28 18:23:50 +0200
committerSimon Rettberg2013-08-28 18:23:50 +0200
commitc4141d61d8748bbbc3e21a9416b9fd7f8a5a75f3 (patch)
tree6ea18863656a0e264cf8b708d0741661a087f943
parent[SERVER] Fix *printf format strings, remove falsely detected errors (diff)
downloaddnbd3-c4141d61d8748bbbc3e21a9416b9fd7f8a5a75f3.tar.gz
dnbd3-c4141d61d8748bbbc3e21a9416b9fd7f8a5a75f3.tar.xz
dnbd3-c4141d61d8748bbbc3e21a9416b9fd7f8a5a75f3.zip
[SERVER] Remove stupid 1MiB request expansion, this clearly needs to be done differently :)
-rw-r--r--src/server/altservers.c4
-rw-r--r--src/server/image.c2
-rw-r--r--src/server/uplink.c8
3 files changed, 8 insertions, 6 deletions
diff --git a/src/server/altservers.c b/src/server/altservers.c
index a5a4b7c..b85b6a9 100644
--- a/src/server/altservers.c
+++ b/src/server/altservers.c
@@ -414,8 +414,8 @@ static void *altservers_main(void *data)
}
// check reply header
if ( reply.cmd != CMD_GET_BLOCK || reply.size != DNBD3_BLOCK_SIZE ) {
- //ERROR_GOTO_VA( server_failed, "[ERROR] Reply to random block request is %d bytes for %s",
- // reply.size, uplink->image->lower_name );
+ ERROR_GOTO_VA( server_failed, "[ERROR] Reply to random block request is %d bytes for %s",
+ reply.size, uplink->image->lower_name );
goto server_failed;
}
if ( recv( sock, buffer, DNBD3_BLOCK_SIZE, MSG_WAITALL ) != DNBD3_BLOCK_SIZE ) {
diff --git a/src/server/image.c b/src/server/image.c
index 11029df..b47be48 100644
--- a/src/server/image.c
+++ b/src/server/image.c
@@ -251,7 +251,7 @@ dnbd3_image_t* image_get(char *name, uint16_t revision)
// Either the image is already marked as "not working", or the file cannot be accessed
printf( "[DEBUG] File '%s' has gone away...\n", candidate->path );
candidate->working = FALSE; // No file? OUT!
- } else if ( !candidate->working && candidate->cache_map != NULL && file_isWritable( candidate->path ) ) {
+ } else if ( !candidate->working && candidate->cache_map != NULL && candidate->uplink == NULL && file_isWritable( candidate->path ) ) {
// Not working and has file + cache-map, try to init uplink (uplink_init will check if proxy mode is enabled)
uplink_init( candidate, -1, NULL );
}
diff --git a/src/server/uplink.c b/src/server/uplink.c
index e452557..111cda6 100644
--- a/src/server/uplink.c
+++ b/src/server/uplink.c
@@ -40,7 +40,10 @@ int uplink_init(dnbd3_image_t *image, int sock, dnbd3_host_t *host)
dnbd3_connection_t *link = NULL;
assert( image != NULL );
spin_lock( &image->lock );
- assert( image->uplink == NULL );
+ if ( image->uplink != NULL ) {
+ spin_unlock( &image->lock );
+ return TRUE;
+ }
if ( image->cache_map == NULL ) {
memlogf( "[WARNING] Uplink was requested for image %s, but it is already complete", image->lower_name );
goto failure;
@@ -127,8 +130,7 @@ int uplink_request(dnbd3_client_t *client, uint64_t handle, uint64_t start, uint
int existingType = -1; // ULR_* type of existing request
int i;
int freeSlot = -1;
- if ( length < 1024 * 1024 ) length = 1024 * 1024;
- const uint64_t end = MIN(start + length, uplink->image->filesize);
+ const uint64_t end = start + length;
spin_lock( &uplink->queueLock );
spin_unlock( &client->image->lock );