mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
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
This commit is contained in:
parent
f8ea75ceb1
commit
0158782b02
@ -55,6 +55,8 @@ typedef void (*GInputFunction) (void *data, int source,
|
|||||||
|
|
||||||
int g_input_add(int source, GInputCondition condition,
|
int g_input_add(int source, GInputCondition condition,
|
||||||
GInputFunction function, void *data);
|
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)
|
#define MAX_INT_STRLEN ((sizeof(int) * CHAR_BIT + 2) / 3 + 1)
|
||||||
|
|
||||||
|
@ -58,8 +58,8 @@ static int irssi_io_invoke(GIOChannel *source, GIOCondition condition,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int g_input_add(int source, GInputCondition condition,
|
int g_input_add_full(int source, int priority, GInputCondition condition,
|
||||||
GInputFunction function, void *data)
|
GInputFunction function, void *data)
|
||||||
{
|
{
|
||||||
IRSSI_INPUT_REC *rec;
|
IRSSI_INPUT_REC *rec;
|
||||||
unsigned int result;
|
unsigned int result;
|
||||||
@ -78,13 +78,20 @@ int g_input_add(int source, GInputCondition condition,
|
|||||||
cond |= G_IO_OUT;
|
cond |= G_IO_OUT;
|
||||||
|
|
||||||
channel = g_io_channel_unix_new (source);
|
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);
|
irssi_io_invoke, rec, g_free);
|
||||||
g_io_channel_unref(channel);
|
g_io_channel_unref(channel);
|
||||||
|
|
||||||
return result;
|
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 get_timeval_diff(const GTimeVal *tv1, const GTimeVal *tv2)
|
||||||
{
|
{
|
||||||
long secs, usecs;
|
long secs, usecs;
|
||||||
|
@ -513,7 +513,7 @@ void gui_readline_init(void)
|
|||||||
cutbuffer = NULL;
|
cutbuffer = NULL;
|
||||||
redir = NULL;
|
redir = NULL;
|
||||||
idle_time = time(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("backward_character", "", "Left", NULL, (SIGNAL_FUNC) key_backward_character);
|
||||||
key_bind("forward_character", "", "Right", NULL, (SIGNAL_FUNC) key_forward_character);
|
key_bind("forward_character", "", "Right", NULL, (SIGNAL_FUNC) key_forward_character);
|
||||||
|
@ -271,7 +271,7 @@ static void irc_server_event(const char *line, IRC_SERVER_REC *server, const cha
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Read line from server */
|
/* 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];
|
char tmpbuf[512];
|
||||||
int recvlen, ret;
|
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(server != NULL, -1);
|
||||||
g_return_val_if_fail(str != NULL, -1);
|
g_return_val_if_fail(str != NULL, -1);
|
||||||
|
|
||||||
recvlen = net_receive(net_sendbuffer_handle(server->handle),
|
recvlen = !read_socket ? 0 :
|
||||||
tmpbuf, sizeof(tmpbuf));
|
net_receive(net_sendbuffer_handle(server->handle),
|
||||||
|
tmpbuf, sizeof(tmpbuf));
|
||||||
|
|
||||||
ret = line_split(tmpbuf, recvlen, str, (LINEBUF_REC **) &server->buffer);
|
ret = line_split(tmpbuf, recvlen, str, (LINEBUF_REC **) &server->buffer);
|
||||||
if (ret == -1) {
|
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)
|
static void irc_parse_incoming(SERVER_REC *server)
|
||||||
{
|
{
|
||||||
char *str;
|
char *str;
|
||||||
|
int count;
|
||||||
|
|
||||||
g_return_if_fail(server != NULL);
|
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);
|
rawlog_input(server->rawlog, str);
|
||||||
signal_emit_id(signal_server_incoming, 2, server, str);
|
signal_emit_id(signal_server_incoming, 2, server, str);
|
||||||
|
|
||||||
|
count++;
|
||||||
if (g_slist_find(servers, server) == NULL)
|
if (g_slist_find(servers, server) == NULL)
|
||||||
break; /* disconnected */
|
break; /* disconnected */
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user