diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2010-11-10 16:39:41 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2010-11-10 16:39:41 +0100 |
commit | 118f2918b33c31dec5f9e9f99aedc22c626a3b61 (patch) | |
tree | 62b89ffed5b310aaf8e4ded7481c805eae4f8ea8 /src/plugins/xfer/xfer-dcc.c | |
parent | 11b3dd2874a60aec5ae286dc99f13bd4a5de4cd8 (diff) | |
download | weechat-118f2918b33c31dec5f9e9f99aedc22c626a3b61.zip |
Fix dcc file transfer for large files (more than 4 GB) on 32-bit systems (bug #31531)
This commit fixes another bug when file is sent: sometimes transfer was still
active although file was successfully sent.
Diffstat (limited to 'src/plugins/xfer/xfer-dcc.c')
-rw-r--r-- | src/plugins/xfer/xfer-dcc.c | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/src/plugins/xfer/xfer-dcc.c b/src/plugins/xfer/xfer-dcc.c index 2185a84e2..9eca48ce0 100644 --- a/src/plugins/xfer/xfer-dcc.c +++ b/src/plugins/xfer/xfer-dcc.c @@ -49,8 +49,8 @@ xfer_dcc_send_file_child (struct t_xfer *xfer) int num_read, num_sent, blocksize; static char buffer[XFER_BLOCKSIZE_MAX]; uint32_t ack; - time_t last_sent, new_time, last_second; - long sent_last_second; + time_t last_sent, new_time, last_second, sent_ok; + unsigned long long sent_last_second; blocksize = xfer->blocksize; if (weechat_config_integer (xfer_config_network_speed_limit) > 0) @@ -61,6 +61,7 @@ xfer_dcc_send_file_child (struct t_xfer *xfer) last_sent = time (NULL); last_second = time (NULL); + sent_ok = 0; sent_last_second = 0; while (1) { @@ -102,7 +103,7 @@ xfer_dcc_send_file_child (struct t_xfer *xfer) (xfer->fast_send || (xfer->pos <= xfer->ack))) { if ((weechat_config_integer (xfer_config_network_speed_limit) > 0) - && (sent_last_second >= weechat_config_integer (xfer_config_network_speed_limit) * 1024)) + && (sent_last_second >= (unsigned long long)weechat_config_integer (xfer_config_network_speed_limit) * 1024)) { /* we're sending too fast (according to speed limit set by user) */ usleep (100); @@ -135,14 +136,17 @@ xfer_dcc_send_file_child (struct t_xfer *xfer) } if (num_sent > 0) { - xfer->pos += (unsigned long) num_sent; - sent_last_second += (unsigned long) num_sent; + xfer->pos += (unsigned long long) num_sent; + sent_last_second += (unsigned long long) num_sent; new_time = time (NULL); - if (last_sent != new_time) + if ((last_sent != new_time) + || ((sent_ok == 0) && (xfer->pos >= xfer->size))) { last_sent = new_time; xfer_network_write_pipe (xfer, XFER_STATUS_ACTIVE, XFER_NO_ERROR); + if (xfer->pos >= xfer->size) + sent_ok = new_time; } } } @@ -150,11 +154,23 @@ xfer_dcc_send_file_child (struct t_xfer *xfer) else usleep (1000); - if (time (NULL) > last_second) + new_time = time (NULL); + if (new_time > last_second) { - last_second = time (NULL); + last_second = new_time; sent_last_second = 0; } + + /* + * if send if ok since 2 seconds or more, and that no ack was received, + * then consider it's ok + */ + if ((sent_ok != 0) && (new_time > sent_ok + 2)) + { + xfer_network_write_pipe (xfer, XFER_STATUS_DONE, + XFER_NO_ERROR); + return; + } } } @@ -215,7 +231,7 @@ xfer_dcc_recv_file_child (struct t_xfer *xfer) return; } - xfer->pos += (unsigned long) num_read; + xfer->pos += (unsigned long long) num_read; pos = htonl (xfer->pos); /* we don't check return code, not a problem if an ACK send failed */ |