@@ -92,6 +92,8 @@ struct _dnbd3_uplink
9292 pthread_t thread ; // thread holding the connection
9393 pthread_mutex_t sendMutex ; // For locking socket while sending
9494 pthread_mutex_t queueLock ; // lock for synchronization on request queue etc.
95+ pthread_mutex_t asyncHandleMutex ; // async handling of received reply
96+ pthread_cond_t asyncHandleCond ; // condition for async receive handler
9597 dnbd3_image_t * image ; // image that this uplink is used for; do not call get/release for this pointer
9698 pthread_mutex_t rttLock ; // When accessing rttTestResult, betterFd or betterServer
9799 atomic_int rttTestResult ; // RTT_*
@@ -105,7 +107,7 @@ struct _dnbd3_uplink
105107 // If BGR == BGR_HASHBLOCK, -1 means "currently no incomplete block"
106108 atomic_uint_fast64_t bytesReceived ; // Number of bytes received by the uplink since startup.
107109 atomic_uint_fast64_t bytesReceivedLastSave ; // Number of bytes received when we last saved the cache map
108- int queueLen ; // length of queue
110+ int queueLen ; // length of queue (slots; either BGR (no client at all) or one or more clients)
109111 int idleTime ; // How many seconds the uplink was idle (apart from keep-alives)
110112 dnbd3_queue_entry_t * queue ;
111113 atomic_uint_fast32_t queueId ;
@@ -169,15 +171,15 @@ struct _dnbd3_client
169171{
170172#define HOSTNAMELEN (48)
171173 atomic_uint_fast64_t bytesSent ; // Byte counter for this client.
172- dnbd3_image_t * _Atomic image ; // Image in use by this client, or NULL during handshake
174+ _Atomic (dnbd3_image_t * ) image ; // Image in use by this client, or NULL during handshake
175+ pthread_t thread ;
173176 int sock ;
174- _Atomic uint8_t relayedCount ; // How many requests are in-flight to the uplink server
177+ _Atomic( uint8_t ) relayedCount ; // How many requests are in-flight to the uplink server
175178 bool isServer ; // true if a server in proxy mode, false if real client
176179 dnbd3_host_t host ;
177180 char hostName [HOSTNAMELEN ]; // inet_ntop version of host
178181 pthread_mutex_t sendMutex ; // Held while writing to sock if image is incomplete (since uplink uses socket too)
179182 pthread_mutex_t lock ;
180- pthread_t thread ;
181183};
182184
183185// #######################################################
0 commit comments