diff options
author | scottc <scottc> | 2002-07-11 18:15:39 +0000 |
---|---|---|
committer | scottc <scottc> | 2002-07-11 18:15:39 +0000 |
commit | c6a9e44197d3b4c3445498b2c6f1bf61f15851b0 (patch) | |
tree | 0fc47e6dbc0d83893670b66f955c00e5468a7048 | |
parent | 002ce408d5a22cb844552d0cc08442349eeb4295 (diff) | |
download | gdb-c6a9e44197d3b4c3445498b2c6f1bf61f15851b0.tar.gz |
* cygserver.cc (client_request_shutdown::serve): Don't set the
shutdown flag directly, but send a SIGINT, as the signal handler
sets the flag and the signal breaks the pause(2) in the main loop.
(print_usage): Add new options.
(main): Add new --cleanup-threads and --request-threads options to
set the number of threads used by the daemon. Use pause(2) rather
the win32 Sleep in the main loop.
* shm.cc (shmat): Add sigframe.
(shmctl): Ditto.
(shmdt): Ditto.
(shmget): Ditto.
-rw-r--r-- | winsup/cygserver/threaded_queue.cc | 2 | ||||
-rw-r--r-- | winsup/cygwin/ChangeLog | 14 | ||||
-rwxr-xr-x | winsup/cygwin/cygserver.cc | 48 | ||||
-rw-r--r-- | winsup/cygwin/shm.cc | 5 | ||||
-rwxr-xr-x | winsup/cygwin/threaded_queue.cc | 2 |
5 files changed, 61 insertions, 10 deletions
diff --git a/winsup/cygserver/threaded_queue.cc b/winsup/cygserver/threaded_queue.cc index ee7a36e3fdb..ced59786500 100644 --- a/winsup/cygserver/threaded_queue.cc +++ b/winsup/cygserver/threaded_queue.cc @@ -214,6 +214,8 @@ threaded_queue::start_routine (const LPVOID lpParam) void threaded_queue::create_workers (const size_t initial_workers) { + assert (initial_workers > 0); + for (unsigned int i = 0; i != initial_workers; i++) { const long count = InterlockedIncrement (&_workers_count); diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index c7d9731780d..39c2051c6e1 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,19 @@ 2002-07-11 Conrad Scott <conrad.scott@dsl.pipex.com> + * cygserver.cc (client_request_shutdown::serve): Don't set the + shutdown flag directly, but send a SIGINT, as the signal handler + sets the flag and the signal breaks the pause(2) in the main loop. + (print_usage): Add new options. + (main): Add new --cleanup-threads and --request-threads options to + set the number of threads used by the daemon. Use pause(2) rather + the win32 Sleep in the main loop. + * shm.cc (shmat): Add sigframe. + (shmctl): Ditto. + (shmdt): Ditto. + (shmget): Ditto. + +2002-07-11 Conrad Scott <conrad.scott@dsl.pipex.com> + * cygserver_shm.cc: Automatically detach processes from any segments they are attached to at exit. (class server_shmmgr::attach_t): New class. diff --git a/winsup/cygwin/cygserver.cc b/winsup/cygwin/cygserver.cc index 8fe1d9dbbe7..072c99cfd68 100755 --- a/winsup/cygwin/cygserver.cc +++ b/winsup/cygwin/cygserver.cc @@ -465,8 +465,6 @@ client_request_shutdown::client_request_shutdown () syscall_printf ("created"); } -static volatile sig_atomic_t shutdown_server = false; - void client_request_shutdown::serve (transport_layer_base *, process_cache *) { @@ -479,11 +477,13 @@ client_request_shutdown::serve (transport_layer_base *, process_cache *) * only shutdown _this queue_ */ - shutdown_server = true; + kill (getpid (), SIGINT); msglen (0); } +static sig_atomic_t shutdown_server = false; + static void handle_signal (const int signum) { @@ -500,9 +500,11 @@ static void print_usage (const char *const pgm) { printf ("Usage: %s [OPTIONS]\n", pgm); - printf (" -h, --help output usage information and exit\n"); - printf (" -s, --shutdown shutdown the current instance of the daemon\n"); - printf (" -v, --version output version information and exit\n"); + printf (" -c, --cleanup-threads number of cleanup threads to use\n"); + printf (" -h, --help output usage information and exit\n"); + printf (" -r, --request-threads number of request threads to use\n"); + printf (" -s, --shutdown shutdown the daemon\n"); + printf (" -v, --version output version information and exit\n"); } /* @@ -561,14 +563,18 @@ int main (const int argc, char *argv[]) { const struct option longopts[] = { + {"cleanup-threads", required_argument, NULL, 'c'}, {"help", no_argument, NULL, 'h'}, + {"request-threads", required_argument, NULL, 'r'}, {"shutdown", no_argument, NULL, 's'}, {"version", no_argument, NULL, 'v'}, {0, no_argument, NULL, 0} }; - const char opts[] = "hsv"; + const char opts[] = "c:hr:sv"; + int cleanup_threads = 2; + int request_threads = 10; bool shutdown = false; const char *pgm = NULL; @@ -587,10 +593,32 @@ main (const int argc, char *argv[]) while ((opt = getopt_long (argc, argv, opts, longopts, NULL)) != EOF) switch (opt) { + case 'c': + cleanup_threads = atoi (optarg); + if (cleanup_threads <= 0) + { + fprintf (stderr, + "%s: number of cleanup threads must be positive\n", + pgm); + exit (1); + } + break; + case 'h': print_usage (pgm); return 0; + case 'r': + request_threads = atoi (optarg); + if (request_threads <= 0) + { + fprintf (stderr, + "%s: number of request threads must be positive\n", + pgm); + exit (1); + } + break; + case 's': shutdown = true; break; @@ -642,14 +670,14 @@ main (const int argc, char *argv[]) setbuf (stdout, NULL); printf ("daemon starting up"); - threaded_queue request_queue (10); + threaded_queue request_queue (request_threads); printf ("."); transport_layer_base *const transport = create_server_transport (); assert (transport); printf ("."); - process_cache cache (2); + process_cache cache (cleanup_threads); printf ("."); server_submission_loop submission_loop (&request_queue, transport, &cache); @@ -682,7 +710,7 @@ main (const int argc, char *argv[]) -- if signal event then retrigger it */ while (!shutdown_server && request_queue.running () && cache.running ()) - Sleep (1000); + pause (); printf ("\nShutdown request received - new requests will be denied\n"); request_queue.stop (); diff --git a/winsup/cygwin/shm.cc b/winsup/cygwin/shm.cc index 93d4414aada..f4c6df54756 100644 --- a/winsup/cygwin/shm.cc +++ b/winsup/cygwin/shm.cc @@ -21,6 +21,7 @@ details. */ #include <unistd.h> #include "cygerrno.h" +#include "sigproc.h" #include "cygserver_ipc.h" #include "cygserver_shm.h" @@ -609,6 +610,7 @@ client_shmmgr::new_segment (const int shmid, extern "C" void * shmat (const int shmid, const void *const shmaddr, const int shmflg) { + sigframe thisframe (mainthread); return shmmgr.shmat (shmid, shmaddr, shmflg); } @@ -619,6 +621,7 @@ shmat (const int shmid, const void *const shmaddr, const int shmflg) extern "C" int shmctl (const int shmid, const int cmd, struct shmid_ds *const buf) { + sigframe thisframe (mainthread); return shmmgr.shmctl (shmid, cmd, buf); } @@ -629,6 +632,7 @@ shmctl (const int shmid, const int cmd, struct shmid_ds *const buf) extern "C" int shmdt (const void *const shmaddr) { + sigframe thisframe (mainthread); return shmmgr.shmdt (shmaddr); } @@ -639,6 +643,7 @@ shmdt (const void *const shmaddr) extern "C" int shmget (const key_t key, const size_t size, const int shmflg) { + sigframe thisframe (mainthread); return shmmgr.shmget (key, size, shmflg); } diff --git a/winsup/cygwin/threaded_queue.cc b/winsup/cygwin/threaded_queue.cc index ee7a36e3fdb..ced59786500 100755 --- a/winsup/cygwin/threaded_queue.cc +++ b/winsup/cygwin/threaded_queue.cc @@ -214,6 +214,8 @@ threaded_queue::start_routine (const LPVOID lpParam) void threaded_queue::create_workers (const size_t initial_workers) { + assert (initial_workers > 0); + for (unsigned int i = 0; i != initial_workers; i++) { const long count = InterlockedIncrement (&_workers_count); |