diff options
author | Ulf Lamping <ulf.lamping@web.de> | 2005-10-03 19:34:58 +0000 |
---|---|---|
committer | Ulf Lamping <ulf.lamping@web.de> | 2005-10-03 19:34:58 +0000 |
commit | d24ce3d4ad5f2d025b0dc63b3e95e89b488452f0 (patch) | |
tree | c0b6f08e5b116980c1eff57133e9839212b618ae /gtk/gui_utils.c | |
parent | 5851cd16949c1e6014c6ace4f15fd572feeea3f4 (diff) | |
download | wireshark-d24ce3d4ad5f2d025b0dc63b3e95e89b488452f0.tar.gz wireshark-d24ce3d4ad5f2d025b0dc63b3e95e89b488452f0.tar.bz2 wireshark-d24ce3d4ad5f2d025b0dc63b3e95e89b488452f0.zip |
major Win32 bugfix: when getting messages from the capture slave, only one message was processed every 200ms (UNIX handles this differently). If more messages were initiated from the slave, they stacked up. This slowed down the display update and slowed down stopping the capture as a lot of messages had to be processed before the close really finished ...
Now the timer callback function will call the pipe read function up to 5 times to avoid this, but won't do this more often to prevent "endless blocking".
svn path=/trunk/; revision=16091
Diffstat (limited to 'gtk/gui_utils.c')
-rw-r--r-- | gtk/gui_utils.c | 63 |
1 files changed, 40 insertions, 23 deletions
diff --git a/gtk/gui_utils.c b/gtk/gui_utils.c index b1ae730fe7..c42e9fbf21 100644 --- a/gtk/gui_utils.c +++ b/gtk/gui_utils.c @@ -632,37 +632,54 @@ pipe_timer_cb(gpointer data) gboolean result, result1; DWORD childstatus; pipe_input_t *pipe_input = data; + gint iterations = 0; - /* Oddly enough although Named pipes don't work on win9x, - PeekNamedPipe does !!! */ - handle = (HANDLE) _get_osfhandle (pipe_input->source); - result = PeekNamedPipe(handle, NULL, 0, NULL, &avail, NULL); + /* try to read data from the pipe only 5 times, to avoid blocking */ + while(iterations < 5) { + /* Oddly enough although Named pipes don't work on win9x, + PeekNamedPipe does !!! */ + handle = (HANDLE) _get_osfhandle (pipe_input->source); + result = PeekNamedPipe(handle, NULL, 0, NULL, &avail, NULL); - /* Get the child process exit status */ - result1 = GetExitCodeProcess((HANDLE)*(pipe_input->child_process), - &childstatus); + /* Get the child process exit status */ + result1 = GetExitCodeProcess((HANDLE)*(pipe_input->child_process), + &childstatus); - /* If the Peek returned an error, or there are bytes to be read - or the childwatcher thread has terminated then call the normal - callback */ - if (!result || avail > 0 || childstatus != STILL_ACTIVE) { + /* If the Peek returned an error, or there are bytes to be read + or the childwatcher thread has terminated then call the normal + callback */ + if (!result || avail > 0 || childstatus != STILL_ACTIVE) { - /* avoid reentrancy problems and stack overflow */ - gtk_timeout_remove(pipe_input->pipe_input_id); + if(pipe_input->pipe_input_id != 0) { + /* avoid reentrancy problems and stack overflow */ + gtk_timeout_remove(pipe_input->pipe_input_id); + pipe_input->pipe_input_id = 0; + } - /* And call the real handler */ - if (pipe_input->input_cb(pipe_input->source, pipe_input->user_data)) { - /* restore pipe handler */ - pipe_input->pipe_input_id = gtk_timeout_add(200, pipe_timer_cb, data); - } + /* And call the real handler */ + if (!pipe_input->input_cb(pipe_input->source, pipe_input->user_data)) { + /* pipe closed, return false so that the old timer is not run again */ + return FALSE; + } + } + else { + /* No data, stop now */ + break; + } - /* Return false so that this timer is not run again */ - return FALSE; + iterations++; } - else { - /* No data so let timer run again */ - return TRUE; + + if(pipe_input->pipe_input_id == 0) { + /* restore pipe handler */ + pipe_input->pipe_input_id = gtk_timeout_add(200, pipe_timer_cb, data); + + /* Return false so that the old timer is not run again */ + return FALSE; + } else { + /* we didn't stopped the old timer, so let it run */ + return TRUE; } } |