1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

Correctly handle DCC GET write() failures.

git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2427 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2002-02-10 18:42:23 +00:00 committed by cras
parent 0dc3e3f0dd
commit 64e98b7f4a
4 changed files with 17 additions and 1 deletions

View File

@ -98,6 +98,12 @@ static void dcc_error_close_not_found(const char *type, const char *nick,
IRCTXT_DCC_GET_NOT_FOUND, nick, fname);
}
static void dcc_error_write(GET_DCC_REC *dcc, const char *error)
{
printformat(NULL, NULL, MSGLEVEL_DCC,
IRCTXT_DCC_GET_WRITE_ERROR, dcc->file, error);
}
static void sig_dcc_list_print(GET_DCC_REC *dcc)
{
if (IS_DCC_GET(dcc))
@ -112,6 +118,7 @@ void fe_dcc_get_init(void)
signal_add("dcc error file create", (SIGNAL_FUNC) dcc_error_file_create);
signal_add("dcc error get not found", (SIGNAL_FUNC) dcc_error_get_not_found);
signal_add("dcc error close not found", (SIGNAL_FUNC) dcc_error_close_not_found);
signal_add("dcc error write", (SIGNAL_FUNC) dcc_error_write);
signal_add("dcc list print", (SIGNAL_FUNC) sig_dcc_list_print);
}
@ -123,5 +130,6 @@ void fe_dcc_get_deinit(void)
signal_remove("dcc error file create", (SIGNAL_FUNC) dcc_error_file_create);
signal_remove("dcc error get not found", (SIGNAL_FUNC) dcc_error_get_not_found);
signal_remove("dcc error close not found", (SIGNAL_FUNC) dcc_error_close_not_found);
signal_remove("dcc error write", (SIGNAL_FUNC) dcc_error_write);
signal_remove("dcc list print", (SIGNAL_FUNC) sig_dcc_list_print);
}

View File

@ -54,6 +54,7 @@ FORMAT_REC fecommon_irc_dcc_formats[] = {
{ "dcc_get_connected", "{dcc DCC receiving file {dccfile $0} from {nick $1} [$2 port $3]}", 4, { 0, 0, 0, 1 } },
{ "dcc_get_complete", "{dcc DCC received file {dccfile $0} [$1kB] from {nick $2} in {hilight $3} secs [$4kB/s]}", 5, { 0, 2, 0, 2, 3 } },
{ "dcc_get_aborted", "{dcc DCC aborted receiving file {dccfile $0} from {nick $1}}", 2, { 0, 0 } },
{ "dcc_get_write_error", "{dcc DCC error writing to file {dccfile $0}: {comment $1}", 2, { 0, 0 } },
{ "dcc_unknown_ctcp", "{dcc DCC unknown ctcp {hilight $0} from {nick $1} [$2]}", 3, { 0, 0, 0 } },
{ "dcc_unknown_reply", "{dcc DCC unknown reply {hilight $0} from {nick $1} [$2]}", 3, { 0, 0, 0 } },
{ "dcc_unknown_type", "{dcc DCC unknown type {hilight $0}}", 1, { 0 } },

View File

@ -32,6 +32,7 @@ enum {
IRCTXT_DCC_GET_CONNECTED,
IRCTXT_DCC_GET_COMPLETE,
IRCTXT_DCC_GET_ABORTED,
IRCTXT_DCC_GET_WRITE_ERROR,
IRCTXT_DCC_UNKNOWN_CTCP,
IRCTXT_DCC_UNKNOWN_REPLY,
IRCTXT_DCC_UNKNOWN_TYPE,

View File

@ -154,7 +154,13 @@ static void sig_dccget_receive(GET_DCC_REC *dcc)
return;
}
write(dcc->fhandle, buffer, ret);
if (write(dcc->fhandle, buffer, ret) != ret) {
/* most probably out of disk space */
signal_emit("dcc error write", 2,
dcc, g_strerror(errno));
dcc_close(DCC(dcc));
return;
}
dcc->transfd += ret;
}