summaryrefslogtreecommitdiff
path: root/src/irc
diff options
context:
space:
mode:
Diffstat (limited to 'src/irc')
-rw-r--r--src/irc/dcc/dcc-chat.c8
-rw-r--r--src/irc/dcc/dcc-files.c11
-rw-r--r--src/irc/dcc/dcc.c3
-rw-r--r--src/irc/dcc/dcc.h2
4 files changed, 13 insertions, 11 deletions
diff --git a/src/irc/dcc/dcc-chat.c b/src/irc/dcc/dcc-chat.c
index e984d594..83330c6a 100644
--- a/src/irc/dcc/dcc-chat.c
+++ b/src/irc/dcc/dcc-chat.c
@@ -198,7 +198,7 @@ static void dcc_chat_listen(DCC_REC *dcc)
/* TODO: add paranoia check - see dcc-files.c */
- g_source_remove(dcc->tagread);
+ g_source_remove(dcc->tagconn);
close(dcc->handle);
dcc->starttime = time(NULL);
@@ -217,7 +217,6 @@ static void sig_chat_connected(DCC_REC *dcc)
{
g_return_if_fail(dcc != NULL);
- g_source_remove(dcc->tagread);
if (net_geterror(dcc->handle) != 0) {
/* error connecting */
signal_emit("dcc error connect", 1, dcc);
@@ -226,6 +225,7 @@ static void sig_chat_connected(DCC_REC *dcc)
}
/* connect ok. */
+ g_source_remove(dcc->tagconn);
dcc->starttime = time(NULL);
dcc->tagread = g_input_add(dcc->handle, G_INPUT_READ,
(GInputFunction) dcc_chat_input, dcc);
@@ -245,7 +245,7 @@ static void dcc_chat_connect(DCC_REC *dcc)
dcc->handle = net_connect_ip(&dcc->addr, dcc->port,
source_host_ok ? source_host_ip : NULL);
if (dcc->handle != -1) {
- dcc->tagread = g_input_add(dcc->handle, G_INPUT_WRITE|G_INPUT_READ|G_INPUT_EXCEPTION,
+ dcc->tagconn = g_input_add(dcc->handle, G_INPUT_WRITE|G_INPUT_READ|G_INPUT_EXCEPTION,
(GInputFunction) sig_chat_connected, dcc);
} else {
/* error connecting */
@@ -290,7 +290,7 @@ static void cmd_dcc_chat(const char *data, IRC_SERVER_REC *server)
cmd_param_error(CMDERR_ERRNO);
dcc = dcc_create(DCC_TYPE_CHAT, handle, nick, "chat", server, NULL);
- dcc->tagread = g_input_add(dcc->handle, G_INPUT_READ,
+ dcc->tagconn = g_input_add(dcc->handle, G_INPUT_READ,
(GInputFunction) dcc_chat_listen, dcc);
/* send the request */
diff --git a/src/irc/dcc/dcc-files.c b/src/irc/dcc/dcc-files.c
index 3d17af01..68df8033 100644
--- a/src/irc/dcc/dcc-files.c
+++ b/src/irc/dcc/dcc-files.c
@@ -61,7 +61,7 @@ void dcc_get_send_received(DCC_REC *dcc)
count_buf should be re-sent.. also, if it's 1, 2 or 3, the
last 1-3 bytes should be sent later. these happen probably
never, but I just want to do it right.. :) */
- if (dcc->tagwrite != -1) {
+ if (dcc->tagwrite == -1) {
dcc->tagwrite = g_input_add(dcc->handle, G_INPUT_WRITE,
(GInputFunction) sig_dccget_send, dcc);
}
@@ -151,7 +151,6 @@ static void sig_dccget_connected(DCC_REC *dcc)
g_return_if_fail(dcc != NULL);
- g_source_remove(dcc->tagread);
if (net_geterror(dcc->handle) != 0) {
/* error connecting */
signal_emit("dcc error connect", 1, dcc);
@@ -159,6 +158,8 @@ static void sig_dccget_connected(DCC_REC *dcc)
return;
}
+ g_source_remove(dcc->tagconn);
+
g_free_not_null(dcc->file);
dcc->file = dcc_get_download_path(dcc->arg);
@@ -196,7 +197,7 @@ static void dcc_get_connect(DCC_REC *dcc)
dcc->handle = net_connect_ip(&dcc->addr, dcc->port,
source_host_ok ? source_host_ip : NULL);
if (dcc->handle != -1) {
- dcc->tagread = g_input_add(dcc->handle, G_INPUT_WRITE|G_INPUT_READ|G_INPUT_EXCEPTION,
+ dcc->tagconn = g_input_add(dcc->handle, G_INPUT_WRITE|G_INPUT_READ|G_INPUT_EXCEPTION,
(GInputFunction) sig_dccget_connected, dcc);
} else {
/* error connecting */
@@ -458,7 +459,7 @@ static void dcc_send_init(DCC_REC *dcc)
that the host of the nick who we sent the request matches the
address who connected us. */
- g_source_remove(dcc->tagread);
+ g_source_remove(dcc->tagconn);
close(dcc->handle);
dcc->starttime = time(NULL);
@@ -562,7 +563,7 @@ static void cmd_dcc_send(const char *data, IRC_SERVER_REC *server, WI_IRC_REC *i
dcc->port = port;
dcc->size = fsize;
dcc->fhandle = hfile;
- dcc->tagread = g_input_add(hlisten, G_INPUT_READ,
+ dcc->tagconn = g_input_add(hlisten, G_INPUT_READ,
(GInputFunction) dcc_send_init, dcc);
/* send DCC request */
diff --git a/src/irc/dcc/dcc.c b/src/irc/dcc/dcc.c
index 8986a6fb..eca81507 100644
--- a/src/irc/dcc/dcc.c
+++ b/src/irc/dcc/dcc.c
@@ -68,7 +68,7 @@ DCC_REC *dcc_create(int type, int handle, const char *nick, const char *arg,
dcc->nick = g_strdup(nick);
dcc->handle = handle;
dcc->fhandle = -1;
- dcc->tagread = dcc->tagwrite = -1;
+ dcc->tagconn = dcc->tagread = dcc->tagwrite = -1;
dcc->server = server;
dcc->mynick = g_strdup(server != NULL ? server->nick :
chat != NULL ? chat->nick : "??");
@@ -110,6 +110,7 @@ void dcc_destroy(DCC_REC *dcc)
if (dcc->fhandle != -1) close(dcc->fhandle);
if (dcc->handle != -1) net_disconnect(dcc->handle);
+ if (dcc->tagconn != -1) g_source_remove(dcc->tagconn);
if (dcc->tagread != -1) g_source_remove(dcc->tagread);
if (dcc->tagwrite != -1) g_source_remove(dcc->tagwrite);
diff --git a/src/irc/dcc/dcc.h b/src/irc/dcc/dcc.h
index f05f294b..91694a24 100644
--- a/src/irc/dcc/dcc.h
+++ b/src/irc/dcc/dcc.h
@@ -41,7 +41,7 @@ typedef struct DCC_REC {
long size, transfd, skipped; /* file size / bytes transferred / skipped at start */
int handle; /* socket handle */
- int tagread, tagwrite;
+ int tagconn, tagread, tagwrite;
int fhandle; /* file handle */
time_t starttime; /* transfer start time */
int trans_bytes;