summaryrefslogtreecommitdiffstats
path: root/src/server/uplink.c
diff options
context:
space:
mode:
authorSimon Rettberg2013-10-22 16:43:08 +0200
committerSimon Rettberg2013-10-22 16:43:08 +0200
commita031fde5f8343d68e774a7087d3deac287ce3a24 (patch)
tree8bb6d8ec4a57b37d0395756b336fb016811539d9 /src/server/uplink.c
parent[SERVER] Fetch correct revision after cloning (diff)
downloaddnbd3-a031fde5f8343d68e774a7087d3deac287ce3a24.tar.gz
dnbd3-a031fde5f8343d68e774a7087d3deac287ce3a24.tar.xz
dnbd3-a031fde5f8343d68e774a7087d3deac287ce3a24.zip
[SERVER] Refactoring, more debug output, try to check for cyclic proxying
Diffstat (limited to 'src/server/uplink.c')
-rw-r--r--src/server/uplink.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/server/uplink.c b/src/server/uplink.c
index a21e50e..0f50fa0 100644
--- a/src/server/uplink.c
+++ b/src/server/uplink.c
@@ -115,6 +115,7 @@ void uplink_removeClient(dnbd3_connection_t *uplink, dnbd3_client_t *client)
/**
* Request a chunk of data through an uplink server
+ * Locks on: image.lock, uplink.queueLock
*/
int uplink_request(dnbd3_client_t *client, uint64_t handle, uint64_t start, uint32_t length)
{
@@ -122,9 +123,17 @@ int uplink_request(dnbd3_client_t *client, uint64_t handle, uint64_t start, uint
spin_lock( &client->image->lock );
if ( client->image->uplink == NULL ) {
spin_unlock( &client->image->lock );
+ printf( "[DEBUG] Uplink request for image with no uplink (%s)\n", client->image->lower_name );
return FALSE;
}
dnbd3_connection_t * const uplink = client->image->uplink;
+ // Check if the client is the same host as the uplink. If so assume this is a circular proxy chain
+ if ( isSameAddress( &uplink->currentServer, &client->host ) ) {
+ spin_unlock( &client->image->lock );
+ printf( "[DEBUG] Proxy cycle detected.\n" );
+ return FALSE;
+ }
+
int foundExisting = -1; // Index of a pending request that is a superset of our range, -1 otherwise
int existingType = -1; // ULR_* type of existing request
int i;