mirror of
https://github.com/irssi/irssi.git
synced 2025-01-03 14:56:47 -05:00
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
This commit is contained in:
parent
a2d0944eee
commit
3baf7fbd4c
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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 */
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user