summaryrefslogtreecommitdiffstats
path: root/src/server/uplink.c
diff options
context:
space:
mode:
authorSimon Rettberg2020-03-20 12:08:10 +0100
committerSimon Rettberg2020-03-20 12:08:10 +0100
commita9f5b836d9fddb3e1851c5b0a77c566b0f267ead (patch)
tree559a867b661e477553ce26884a74b00f572d26d3 /src/server/uplink.c
parent[SHARED] crc32: Don't skip table lookup if PCLMUL is unavailable (diff)
downloaddnbd3-a9f5b836d9fddb3e1851c5b0a77c566b0f267ead.tar.gz
dnbd3-a9f5b836d9fddb3e1851c5b0a77c566b0f267ead.tar.xz
dnbd3-a9f5b836d9fddb3e1851c5b0a77c566b0f267ead.zip
[SERVER] Fix warnings, add assertions
Diffstat (limited to 'src/server/uplink.c')
-rw-r--r--src/server/uplink.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/server/uplink.c b/src/server/uplink.c
index a7f140f..f5ac6ac 100644
--- a/src/server/uplink.c
+++ b/src/server/uplink.c
@@ -403,8 +403,9 @@ bool uplink_request(dnbd3_uplink_t *uplink, dnbd3_client_t *client, uint64_t han
mutex_unlock( &uplink->sendMutex );
logadd( LOG_DEBUG2, "Cannot do direct uplink request: No socket open" );
} else {
- const bool ret = dnbd3_get_block( uplink->current.fd, req.start, req.end - req.start,
- req.handle, COND_HOPCOUNT( uplink->current.version, hops ) );
+ const bool ret = dnbd3_get_block( uplink->current.fd, req.start,
+ (uint32_t)( req.end - req.start ), req.handle,
+ COND_HOPCOUNT( uplink->current.version, hops ) );
if ( unlikely( !ret ) ) {
markRequestUnsent( uplink, req.handle );
uplink->image->problem.uplink = true;
@@ -426,7 +427,8 @@ success_ref:
if ( client != NULL ) {
// Was from client -- potential prefetch
// Same size as this request, but consider end of image...
- uint32_t len = MIN( uplink->image->virtualFilesize - req.end, req.end - req.start );
+ uint32_t len = (uint32_t)MIN( uplink->image->virtualFilesize - req.end,
+ req.end - req.start );
// Also don't prefetch if we cross a hash block border and BGR mode == hashblock
if ( len > 0 && ( _backgroundReplication != BGR_HASHBLOCK
|| req.start % HASH_BLOCK_SIZE == (req.end-1) % HASH_BLOCK_SIZE ) ) {
@@ -592,7 +594,8 @@ static void* uplink_mainloop(void *data)
}
declare_now;
uint32_t timepassed = timing_diff( &lastKeepalive, &now );
- if ( timepassed >= SERVER_UPLINK_KEEPALIVE_INTERVAL || ( timepassed >= 2 && uplink->idleTime < _bgrWindowSize ) ) {
+ if ( timepassed >= SERVER_UPLINK_KEEPALIVE_INTERVAL
+ || ( timepassed >= 2 && uplink->idleTime < _bgrWindowSize ) ) {
lastKeepalive = now;
uplink->idleTime += timepassed;
// Keep-alive
@@ -714,8 +717,8 @@ static void sendQueuedRequests(dnbd3_uplink_t *uplink, bool newOnly)
dnbd3_request_t *hdr = &reqs[count++];
hdr->magic = dnbd3_packet_magic;
hdr->cmd = CMD_GET_BLOCK;
- hdr->size = it->to - it->from;
- hdr->offset_small = it->from;
+ hdr->size = (uint32_t)( it->to - it->from );
+ hdr->offset = it->from; // Offset first, then hops! (union)
hdr->hops = COND_HOPCOUNT( uplink->current.version, it->hopCount );
hdr->handle = it->handle;
fixup_request( *hdr );