diff options
author | irungentoo <irungentoo@gmail.com> | 2015-06-30 22:05:40 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2015-06-30 22:05:40 -0400 |
commit | a377f55b3da4ecb4ec7567f9bd2d3eaa092d0fe0 (patch) | |
tree | 5a5608ce4c620eb4a94e43fdaf6374340e00bff5 /toxcore/Messenger.c | |
parent | 97d6c4ba1893cce6d6c6d999bbc08a4b4455b832 (diff) |
Allow sending data after file is paused.
Dissallow sending non requested data.
Diffstat (limited to 'toxcore/Messenger.c')
-rw-r--r-- | toxcore/Messenger.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index dccd6495..6ec5a796 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c | |||
@@ -1329,9 +1329,6 @@ int file_data(const Messenger *m, int32_t friendnumber, uint32_t filenumber, uin | |||
1329 | if (ft->status != FILESTATUS_TRANSFERRING) | 1329 | if (ft->status != FILESTATUS_TRANSFERRING) |
1330 | return -4; | 1330 | return -4; |
1331 | 1331 | ||
1332 | if (ft->paused != FILE_PAUSE_NOT) | ||
1333 | return -4; | ||
1334 | |||
1335 | if (length > MAX_FILE_DATA_SIZE) | 1332 | if (length > MAX_FILE_DATA_SIZE) |
1336 | return -5; | 1333 | return -5; |
1337 | 1334 | ||
@@ -1343,7 +1340,7 @@ int file_data(const Messenger *m, int32_t friendnumber, uint32_t filenumber, uin | |||
1343 | return -5; | 1340 | return -5; |
1344 | } | 1341 | } |
1345 | 1342 | ||
1346 | if (position != ft->transferred) { | 1343 | if (position != ft->transferred || (ft->requested <= position && ft->size != 0)) { |
1347 | return -7; | 1344 | return -7; |
1348 | } | 1345 | } |
1349 | 1346 | ||
@@ -1469,11 +1466,12 @@ static void do_reqchunk_filecb(Messenger *m, int32_t friendnumber) | |||
1469 | 1466 | ||
1470 | ++ft->slots_allocated; | 1467 | ++ft->slots_allocated; |
1471 | 1468 | ||
1472 | if (m->file_reqchunk) | 1469 | uint64_t position = ft->requested; |
1473 | (*m->file_reqchunk)(m, friendnumber, i, ft->requested, length, m->file_reqchunk_userdata); | ||
1474 | |||
1475 | ft->requested += length; | 1470 | ft->requested += length; |
1476 | 1471 | ||
1472 | if (m->file_reqchunk) | ||
1473 | (*m->file_reqchunk)(m, friendnumber, i, position, length, m->file_reqchunk_userdata); | ||
1474 | |||
1477 | --free_slots; | 1475 | --free_slots; |
1478 | 1476 | ||
1479 | } | 1477 | } |