summaryrefslogtreecommitdiff
path: root/gdb/mingw-hdep.c
diff options
context:
space:
mode:
authorDaniel Jacobowitz <dan@debian.org>2007-10-02 16:09:53 +0000
committerDaniel Jacobowitz <dan@debian.org>2007-10-02 16:09:53 +0000
commit68c819b3987ddd35f375f1152e8f5cf9aa500258 (patch)
tree5a353bd129618335b9d9cc13171c316e564a42b5 /gdb/mingw-hdep.c
parent8834cbdeea9e478dbe0cb64a076853a3aab2f4e4 (diff)
downloadgdb-68c819b3987ddd35f375f1152e8f5cf9aa500258.tar.gz
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 355b2fcc342..f57e3ced2fe 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;