aboutsummaryrefslogtreecommitdiff
path: root/gdb/mingw-hdep.c
diff options
context:
space:
mode:
authorDaniel Jacobowitz <drow@false.org>2007-10-02 16:09:53 +0000
committerDaniel Jacobowitz <drow@false.org>2007-10-02 16:09:53 +0000
commit4577549b8f2c2839976293166e7475401d9e21f2 (patch)
tree61f014025f2d20732677c9fe60d15ba2b70fd15b /gdb/mingw-hdep.c
parentb0b951d937a64163513e46d65b529c6a5ac87139 (diff)
downloadgdb-4577549b8f2c2839976293166e7475401d9e21f2.zip
gdb-4577549b8f2c2839976293166e7475401d9e21f2.tar.gz
gdb-4577549b8f2c2839976293166e7475401d9e21f2.tar.bz2
2007-10-02 Mark Mitchell <mark@codesourcery.com>
* mingw-hdep.c (gdb_select): Stop helper threads before returning. * ser-mingw.c (enum select_thread_state): New type. (struct ser_console_state): Add have_started and thread_state. (select_thread_wait): New function. (thread_fn_type): New type. (create_select_thread): New function. (destroy_select_thread): Likewise. (start_select_thread): Likewise. (stop_select_thread): Likewise. (console_select_thread): Use new functions. (pipe_select_thread): Likewise. (file_select_thread): Likewise. (ser_console_wait_handle): Likewise. (ser_console_done_wait_handle): Likewise. (ser_console_close): Likewise. (free_pipe_state): Likewise. (pipe_wait_handle): Likewise. (pipe_done_wait_handle): Likewise. (struct net_windows_state): Derive from ser_console_state. (net_windows_select_thread): Use new functions. (net_windows_wait_handle): Likewise. (net_windows_done_wait_handle): Likewise. (net_windows_close): Likewise.
Diffstat (limited to 'gdb/mingw-hdep.c')
-rw-r--r--gdb/mingw-hdep.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/gdb/mingw-hdep.c b/gdb/mingw-hdep.c
index 355b2fc..f57e3ce 100644
--- a/gdb/mingw-hdep.c
+++ b/gdb/mingw-hdep.c
@@ -86,12 +86,18 @@ gdb_select (int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
HANDLE h;
DWORD event;
DWORD num_handles;
+ /* SCBS contains serial control objects corresponding to file
+ descriptors in READFDS and WRITEFDS. */
+ struct serial *scbs[MAXIMUM_WAIT_OBJECTS];
+ /* The number of valid entries in SCBS. */
+ size_t num_scbs;
int fd;
int num_ready;
- int indx;
+ size_t indx;
num_ready = 0;
num_handles = 0;
+ num_scbs = 0;
for (fd = 0; fd < n; ++fd)
{
HANDLE read = NULL, except = NULL;
@@ -105,14 +111,16 @@ gdb_select (int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
if ((!readfds || !FD_ISSET (fd, readfds))
&& (!exceptfds || !FD_ISSET (fd, exceptfds)))
continue;
- h = (HANDLE) _get_osfhandle (fd);
scb = serial_for_fd (fd);
if (scb)
- serial_wait_handle (scb, &read, &except);
+ {
+ serial_wait_handle (scb, &read, &except);
+ scbs[num_scbs++] = scb;
+ }
if (read == NULL)
- read = h;
+ read = (HANDLE) _get_osfhandle (fd);
if (except == NULL)
{
if (!never_handle)
@@ -154,6 +162,9 @@ gdb_select (int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
mutexes, that should never occur. */
gdb_assert (!(WAIT_ABANDONED_0 <= event
&& event < WAIT_ABANDONED_0 + num_handles));
+ /* We no longer need the helper threads to check for activity. */
+ for (indx = 0; indx < num_scbs; ++indx)
+ serial_done_wait_handle (scbs[indx]);
if (event == WAIT_FAILED)
return -1;
if (event == WAIT_TIMEOUT)
@@ -164,7 +175,6 @@ gdb_select (int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
for (fd = 0, indx = 0; fd < n; ++fd)
{
HANDLE fd_h;
- struct serial *scb;
if ((!readfds || !FD_ISSET (fd, readfds))
&& (!exceptfds || !FD_ISSET (fd, exceptfds)))
@@ -191,12 +201,6 @@ gdb_select (int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
else
num_ready++;
}
-
- /* We created at least one event handle for this fd. Let the
- device know we are finished with it. */
- scb = serial_for_fd (fd);
- if (scb)
- serial_done_wait_handle (scb);
}
return num_ready;