diff options
author | Timo Sirainen <cras@irssi.org> | 2000-10-01 22:12:01 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2000-10-01 22:12:01 +0000 |
commit | 0158782b02765bf7eadd8b56c9d71783acf5e802 (patch) | |
tree | 9c09d98f54cf77e0ad348b08bddd3d43ea9fd66e /src | |
parent | f8ea75ceb144fd7efaf0c582f10d06a05420235f (diff) | |
download | irssi-0158782b02765bf7eadd8b56c9d71783acf5e802.zip |
Keyboard should never get stuck again when receiving huge amounts of
text from server that irssi doesn't handle fast enough.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@710 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src')
-rw-r--r-- | src/common.h | 2 | ||||
-rw-r--r-- | src/core/misc.c | 13 | ||||
-rw-r--r-- | src/fe-text/gui-readline.c | 2 | ||||
-rw-r--r-- | src/irc/core/irc.c | 15 |
4 files changed, 24 insertions, 8 deletions
diff --git a/src/common.h b/src/common.h index 199fb5c1..8fa76d78 100644 --- a/src/common.h +++ b/src/common.h @@ -55,6 +55,8 @@ typedef void (*GInputFunction) (void *data, int source, int g_input_add(int source, GInputCondition condition, GInputFunction function, void *data); +int g_input_add_full(int source, int priority, GInputCondition condition, + GInputFunction function, void *data); #define MAX_INT_STRLEN ((sizeof(int) * CHAR_BIT + 2) / 3 + 1) diff --git a/src/core/misc.c b/src/core/misc.c index 2f7d8049..4cdcf4de 100644 --- a/src/core/misc.c +++ b/src/core/misc.c @@ -58,8 +58,8 @@ static int irssi_io_invoke(GIOChannel *source, GIOCondition condition, return TRUE; } -int g_input_add(int source, GInputCondition condition, - GInputFunction function, void *data) +int g_input_add_full(int source, int priority, GInputCondition condition, + GInputFunction function, void *data) { IRSSI_INPUT_REC *rec; unsigned int result; @@ -78,13 +78,20 @@ int g_input_add(int source, GInputCondition condition, cond |= G_IO_OUT; channel = g_io_channel_unix_new (source); - result = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, cond, + result = g_io_add_watch_full(channel, priority, cond, irssi_io_invoke, rec, g_free); g_io_channel_unref(channel); return result; } +int g_input_add(int source, GInputCondition condition, + GInputFunction function, void *data) +{ + return g_input_add_full(source, G_PRIORITY_DEFAULT, condition, + function, data); +} + long get_timeval_diff(const GTimeVal *tv1, const GTimeVal *tv2) { long secs, usecs; diff --git a/src/fe-text/gui-readline.c b/src/fe-text/gui-readline.c index 22d1fb19..f9aafef4 100644 --- a/src/fe-text/gui-readline.c +++ b/src/fe-text/gui-readline.c @@ -513,7 +513,7 @@ void gui_readline_init(void) cutbuffer = NULL; redir = NULL; idle_time = time(NULL); - readtag = g_input_add(0, G_INPUT_READ, (GInputFunction) readline, NULL); + readtag = g_input_add_full(0, G_PRIORITY_HIGH, G_INPUT_READ, (GInputFunction) readline, NULL); key_bind("backward_character", "", "Left", NULL, (SIGNAL_FUNC) key_backward_character); key_bind("forward_character", "", "Right", NULL, (SIGNAL_FUNC) key_forward_character); diff --git a/src/irc/core/irc.c b/src/irc/core/irc.c index 583c55b9..69319783 100644 --- a/src/irc/core/irc.c +++ b/src/irc/core/irc.c @@ -271,7 +271,7 @@ static void irc_server_event(const char *line, IRC_SERVER_REC *server, const cha } /* Read line from server */ -static int irc_receive_line(SERVER_REC *server, char **str) +static int irc_receive_line(SERVER_REC *server, char **str, int read_socket) { char tmpbuf[512]; int recvlen, ret; @@ -279,8 +279,9 @@ static int irc_receive_line(SERVER_REC *server, char **str) g_return_val_if_fail(server != NULL, -1); g_return_val_if_fail(str != NULL, -1); - recvlen = net_receive(net_sendbuffer_handle(server->handle), - tmpbuf, sizeof(tmpbuf)); + recvlen = !read_socket ? 0 : + net_receive(net_sendbuffer_handle(server->handle), + tmpbuf, sizeof(tmpbuf)); ret = line_split(tmpbuf, recvlen, str, (LINEBUF_REC **) &server->buffer); if (ret == -1) { @@ -332,13 +333,19 @@ static void irc_parse_incoming_line(IRC_SERVER_REC *server, char *line) static void irc_parse_incoming(SERVER_REC *server) { char *str; + int count; g_return_if_fail(server != NULL); - while (irc_receive_line(server, &str) > 0) { + /* Some commands can send huge replies and irssi might handle them + too slowly, so read only max. 5 times from the socket before + letting other tasks to run. */ + count = 0; + while (irc_receive_line(server, &str, count < 5) > 0) { rawlog_input(server->rawlog, str); signal_emit_id(signal_server_incoming, 2, server, str); + count++; if (g_slist_find(servers, server) == NULL) break; /* disconnected */ } |