xfer: fix freeze/problems when sending empty files with DCC (closes #53)

This commit is contained in:
Sébastien Helleu 2014-04-13 12:52:25 +02:00
parent 417811ba01
commit db912ded26
3 changed files with 15 additions and 11 deletions

View File

@ -138,6 +138,7 @@ http://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
* scripts: fix crash when a signal is received with type "int" and NULL pointer
in signal_data
* trigger: add trigger plugin: new command /trigger and file trigger.conf
* xfer: fix freeze/problems when sending empty files with DCC (closes #53)
* xfer: fix connection to remote host in DCC receive on Mac OS X (closes #25)
* xfer: remove bind on xfer.network.own_ip (closes #5)

View File

@ -54,6 +54,14 @@ xfer_dcc_send_file_child (struct t_xfer *xfer)
time_t last_sent, new_time, last_second, sent_ok;
unsigned long long sent_last_second;
/* empty file? just return immediately */
if (xfer->pos >= xfer->size)
{
xfer_network_write_pipe (xfer, XFER_STATUS_DONE,
XFER_NO_ERROR);
return;
}
blocksize = xfer->blocksize;
if (weechat_config_integer (xfer_config_network_speed_limit) > 0)
{
@ -386,9 +394,7 @@ xfer_dcc_recv_file_child (struct t_xfer *xfer)
}
else
{
total_written = 0;
if (num_read == 0)
if ((num_read == 0) && (xfer->pos < xfer->size))
{
xfer_network_write_pipe (xfer, XFER_STATUS_FAILED,
XFER_ERROR_RECV_BLOCK);
@ -396,6 +402,7 @@ xfer_dcc_recv_file_child (struct t_xfer *xfer)
}
/* bytes received, write to disk */
total_written = 0;
while (total_written < num_read)
{
written = write (xfer->file,

View File

@ -225,16 +225,14 @@ xfer_network_send_file_fork (struct t_xfer *xfer)
switch (pid = fork ())
{
/* fork failed */
case -1:
case -1: /* fork failed */
weechat_printf (NULL,
_("%s%s: unable to fork"),
weechat_prefix ("error"), XFER_PLUGIN_NAME);
xfer_close (xfer, XFER_STATUS_FAILED);
xfer_buffer_refresh (WEECHAT_HOTLIST_MESSAGE);
return;
/* child process */
case 0:
case 0: /* child process */
rc = setuid (getuid ());
(void) rc;
close (xfer->child_read);
@ -298,16 +296,14 @@ xfer_network_recv_file_fork (struct t_xfer *xfer)
switch (pid = fork ())
{
/* fork failed */
case -1:
case -1: /* fork failed */
weechat_printf (NULL,
_("%s%s: unable to fork"),
weechat_prefix ("error"), XFER_PLUGIN_NAME);
xfer_close (xfer, XFER_STATUS_FAILED);
xfer_buffer_refresh (WEECHAT_HOTLIST_MESSAGE);
return;
/* child process */
case 0:
case 0: /* child process */
rc = setuid (getuid ());
(void) rc;
close (xfer->child_read);