summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/select.cc
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2002-08-01 16:20:31 +0000
committerChristopher Faylor <me@cgf.cx>2002-08-01 16:20:31 +0000
commitb6bd703781fdbe466e5a4d41e16743a642e7c0d3 (patch)
treeaa275a070284b0dfb7678c94d881b8ea87544b5f /winsup/cygwin/select.cc
parent3874ac637cba083178c9e678e4cefcd204898c8e (diff)
downloadcygnal-b6bd703781fdbe466e5a4d41e16743a642e7c0d3.tar.gz
cygnal-b6bd703781fdbe466e5a4d41e16743a642e7c0d3.tar.bz2
cygnal-b6bd703781fdbe466e5a4d41e16743a642e7c0d3.zip
* Makefile.in (DLL_OFILES): Add cygthread.o.
* dcrt0.cc (dll_crt0_1): Eliminate various thread initialization functions in favor of new cygthread class. * debug.cc: Remove thread manipulation functions. * debug.h: Ditto. * external.cc (cygwin_internal): Use cygthread method for determining thread name. Remove capability for setting thread name. * fhandler_console.cc (fhandler_console::read): Use cygthread method rather than iscygthread function. * fhandler_tty.cc (fhandler_tty_master::fhandler_tty_master): Use cygthread methods to create threads. (fhandler_tty_common::__acquire_output_mutex): Use cygthread method to retrieve thread name. * select.cc (pipeinf): Use cygthread pointer rather than handle. (start_thread_pipe): Ditto. (pipe_cleanup): Ditto. (serialinf): Ditto. (start_thread_serial): Ditto. (serial_cleanup): Ditto. (socketinf): Ditto. (start_thread_socket): Ditto. (socket_cleanup): Ditto. * sigproc.cc (hwait_sig): Ditto. (hwait_subproc): Ditto. (proc_terminate): Ditto. (sigproc_terminate): Ditto. (sigproc_init): Initialize cygthread hwait_sig pointer. (subproc_init): Initialize cygthread hwait_subproc pointer. (wait_sig): Rely on cygthread HANDLE operator. * strace.cc (strace::vsprntf): Use cygthread::name rather than threadname. * window.cc (gethwnd): Use cygthread method to initialize thread.
Diffstat (limited to 'winsup/cygwin/select.cc')
-rw-r--r--winsup/cygwin/select.cc36
1 files changed, 17 insertions, 19 deletions
diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc
index 808882d3f..97674a92f 100644
--- a/winsup/cygwin/select.cc
+++ b/winsup/cygwin/select.cc
@@ -42,6 +42,7 @@ details. */
#include "sigproc.h"
#include "perthread.h"
#include "tty.h"
+#include "cygthread.h"
/*
* All these defines below should be in sys/types.h
@@ -512,7 +513,7 @@ static int start_thread_pipe (select_record *me, select_stuff *stuff);
struct pipeinf
{
- HANDLE thread;
+ cygthread *thread;
BOOL stop_thread_pipe;
select_record *start;
};
@@ -556,13 +557,14 @@ start_thread_pipe (select_record *me, select_stuff *stuff)
{
if (stuff->device_specific[FHDEVN(FH_PIPE)])
{
- me->h = ((pipeinf *) stuff->device_specific[FHDEVN(FH_PIPE)])->thread;
+ me->h = *((pipeinf *) stuff->device_specific[FHDEVN(FH_PIPE)])->thread;
return 1;
}
pipeinf *pi = new pipeinf;
pi->start = &stuff->start;
pi->stop_thread_pipe = FALSE;
- pi->thread = me->h = makethread (thread_pipe, (LPVOID)pi, 0, "select_pipe");
+ pi->thread = new cygthread (thread_pipe, (LPVOID)pi, "select_pipe");
+ me->h = *pi->thread;
if (!me->h)
return 0;
stuff->device_specific[FHDEVN(FH_PIPE)] = (void *)pi;
@@ -576,8 +578,7 @@ pipe_cleanup (select_record *, select_stuff *stuff)
if (pi && pi->thread)
{
pi->stop_thread_pipe = true;
- WaitForSingleObject (pi->thread, INFINITE);
- CloseHandle (pi->thread);
+ pi->thread->detach ();
delete pi;
stuff->device_specific[FHDEVN(FH_PIPE)] = NULL;
}
@@ -865,7 +866,7 @@ static int start_thread_serial (select_record *me, select_stuff *stuff);
struct serialinf
{
- HANDLE thread;
+ cygthread *thread;
BOOL stop_thread_serial;
select_record *start;
};
@@ -1007,15 +1008,14 @@ start_thread_serial (select_record *me, select_stuff *stuff)
{
if (stuff->device_specific[FHDEVN(FH_SERIAL)])
{
- me->h = ((pipeinf *) stuff->device_specific[FHDEVN(FH_SERIAL)])->thread;
+ me->h = *((serialinf *) stuff->device_specific[FHDEVN(FH_SERIAL)])->thread;
return 1;
}
serialinf *si = new serialinf;
si->start = &stuff->start;
si->stop_thread_serial = FALSE;
- si->thread = me->h = makethread (thread_serial, (LPVOID)si, 0, "select_serial");
- if (!me->h)
- return 0;
+ si->thread = new cygthread (thread_serial, (LPVOID)si, "select_serial");
+ me->h = *si->thread;
stuff->device_specific[FHDEVN(FH_SERIAL)] = (void *)si;
return 1;
}
@@ -1027,8 +1027,7 @@ serial_cleanup (select_record *, select_stuff *stuff)
if (si && si->thread)
{
si->stop_thread_serial = true;
- WaitForSingleObject (si->thread, INFINITE);
- CloseHandle (si->thread);
+ si->thread->detach ();
delete si;
stuff->device_specific[FHDEVN(FH_SERIAL)] = NULL;
}
@@ -1169,7 +1168,7 @@ fhandler_base::select_except (select_record *s)
struct socketinf
{
- HANDLE thread;
+ cygthread *thread;
winsock_fd_set readfds, writefds, exceptfds;
SOCKET exitsock;
struct sockaddr_in sin;
@@ -1280,7 +1279,7 @@ start_thread_socket (select_record *me, select_stuff *stuff)
if ((si = (socketinf *)stuff->device_specific[FHDEVN(FH_SOCKET)]))
{
- me->h = si->thread;
+ me->h = *si->thread;
return 1;
}
@@ -1349,9 +1348,9 @@ start_thread_socket (select_record *me, select_stuff *stuff)
stuff->device_specific[FHDEVN(FH_SOCKET)] = (void *) si;
si->start = &stuff->start;
select_printf ("stuff_start %p", &stuff->start);
- si->thread = me->h = makethread (thread_socket, (LPVOID)si, 0,
- "select_socket");
- return !!me->h;
+ si->thread = new cygthread (thread_socket, (LPVOID)si, "select_socket");
+ me->h = *si->thread;
+ return 1;
err:
set_winsock_errno ();
@@ -1387,10 +1386,9 @@ socket_cleanup (select_record *, select_stuff *stuff)
closesocket (s);
/* Wait for thread to go away */
- WaitForSingleObject (si->thread, INFINITE);
+ si->thread->detach ();
shutdown (si->exitsock, SD_BOTH);
closesocket (si->exitsock);
- CloseHandle (si->thread);
stuff->device_specific[FHDEVN(FH_SOCKET)] = NULL;
delete si;
}