summaryrefslogtreecommitdiffstats
path: root/src/handler.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/handler.c')
-rw-r--r--src/handler.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/handler.c b/src/handler.c
index 8534c69..1c107dd 100644
--- a/src/handler.c
+++ b/src/handler.c
@@ -167,6 +167,7 @@ int tip_client_state_process_payload(struct tip_client *cli)
int tip_client_state_process_payload_reply(struct tip_client *cli)
{
uint64_t chunk_size;
+ uint32_t remainder;
off_t chunk_offset;
char buf[1024];
int fd;
@@ -191,18 +192,13 @@ int tip_client_state_process_payload_reply(struct tip_client *cli)
break;
chunk_size = cli->size / MAX_CHUNKS;
- if (cli->size % MAX_CHUNKS) {
- if (cli->chunk < MAX_CHUNKS - 1) {
- chunk_size++;
- chunk_offset = chunk_size * cli->chunk;
- } else {
- chunk_offset = chunk_size * cli->chunk;
- chunk_offset += MAX_CHUNKS - 1;
- chunk_size--;
- }
- } else {
- chunk_offset = chunk_size * cli->chunk;
+ chunk_offset = chunk_size * cli->chunk;
+
+ if (cli->chunk == MAX_CHUNKS - 1) {
+ remainder = cli->size % MAX_CHUNKS;
+ chunk_size += remainder;
}
+
cli->size = chunk_size;
cli->offset = chunk_offset;
break;