From 3baf7fbd4c5724b50830271bd06e139a6f2ab712 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Tue, 15 Aug 2000 00:22:08 +0000 Subject: [PATCH] Some changes handling g_input_add() - maybe this helps to problems where irssi sometimes eats all the cpu. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@608 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/common.h | 3 +-- src/core/misc.c | 17 +++++++++++------ src/core/server.c | 3 +-- src/fe-common/irc/fe-query.c | 2 +- src/irc/dcc/dcc-chat.c | 2 +- src/irc/dcc/dcc-files.c | 2 +- 6 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/common.h b/src/common.h index bf927676..d0e07b5a 100644 --- a/src/common.h +++ b/src/common.h @@ -46,8 +46,7 @@ typedef enum { G_INPUT_READ = 1 << 0, - G_INPUT_WRITE = 1 << 1, - G_INPUT_EXCEPTION = 1 << 2 + G_INPUT_WRITE = 1 << 1 } GInputCondition; typedef void (*GInputFunction) (void *data, int source, diff --git a/src/core/misc.c b/src/core/misc.c index e3762e2f..c9abeb07 100644 --- a/src/core/misc.c +++ b/src/core/misc.c @@ -37,12 +37,18 @@ static int irssi_io_invoke(GIOChannel *source, GIOCondition condition, IRSSI_INPUT_REC *rec = data; GInputCondition icond = 0; + if (condition & (G_IO_ERR | G_IO_HUP | G_IO_NVAL)) { + /* error, we have to call the function.. */ + if (rec->condition & G_IO_IN) + icond |= G_INPUT_READ; + else + icond |= G_INPUT_WRITE; + } + if (condition & (G_IO_IN | G_IO_PRI)) icond |= G_INPUT_READ; if (condition & G_IO_OUT) icond |= G_INPUT_WRITE; - if (condition & (G_IO_ERR | G_IO_HUP | G_IO_NVAL)) - icond |= G_INPUT_EXCEPTION; if (rec->condition & icond) { rec->function(rec->data, g_io_channel_unix_get_fd(source), @@ -58,19 +64,18 @@ int g_input_add(int source, GInputCondition condition, IRSSI_INPUT_REC *rec; unsigned int result; GIOChannel *channel; - GIOCondition cond = 0; + GIOCondition cond; rec = g_new(IRSSI_INPUT_REC, 1); rec->condition = condition; rec->function = function; rec->data = data; + cond = G_IO_ERR|G_IO_HUP|G_IO_NVAL; if (condition & G_INPUT_READ) - cond |= (G_IO_IN | G_IO_PRI); + cond |= G_IO_IN|G_IO_PRI; if (condition & G_INPUT_WRITE) cond |= G_IO_OUT; - if (condition & G_INPUT_EXCEPTION) - cond |= G_IO_ERR|G_IO_HUP|G_IO_NVAL; channel = g_io_channel_unix_new (source); result = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, cond, diff --git a/src/core/server.c b/src/core/server.c index f9ebf682..c4d22d6c 100644 --- a/src/core/server.c +++ b/src/core/server.c @@ -176,8 +176,7 @@ static void server_connect_callback_readpipe(SERVER_REC *server) server->handle = net_sendbuffer_create(handle, 0); server->connect_tag = - g_input_add(handle, G_INPUT_WRITE | G_INPUT_READ | - G_INPUT_EXCEPTION, + g_input_add(handle, G_INPUT_WRITE | G_INPUT_READ, (GInputFunction) server_connect_callback_init, server); signal_emit("server connecting", 2, server, &iprec.ip); diff --git a/src/fe-common/irc/fe-query.c b/src/fe-common/irc/fe-query.c index 3a365e74..f48505be 100644 --- a/src/fe-common/irc/fe-query.c +++ b/src/fe-common/irc/fe-query.c @@ -170,7 +170,7 @@ static void cmd_query(const char *data, IRC_SERVER_REC *server, WI_IRC_REC *item } if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS | - PARAM_FLAG_UNKNOWN_OPTIONS | PARAM_FLAG_GETREST, + PARAM_FLAG_UNKNOWN_OPTIONS, "query", &optlist, &nick)) return; if (*nick == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); diff --git a/src/irc/dcc/dcc-chat.c b/src/irc/dcc/dcc-chat.c index 69299304..e8fdd2ad 100644 --- a/src/irc/dcc/dcc-chat.c +++ b/src/irc/dcc/dcc-chat.c @@ -248,7 +248,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->tagconn = 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, (GInputFunction) sig_chat_connected, dcc); } else { /* error connecting */ diff --git a/src/irc/dcc/dcc-files.c b/src/irc/dcc/dcc-files.c index c6695d40..0f9facec 100644 --- a/src/irc/dcc/dcc-files.c +++ b/src/irc/dcc/dcc-files.c @@ -198,7 +198,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->tagconn = 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, (GInputFunction) sig_dccget_connected, dcc); } else { /* error connecting */