Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConrad Scott <conrad.scott@dsl.pipex.com>2002-07-11 22:15:40 +0400
committerConrad Scott <conrad.scott@dsl.pipex.com>2002-07-11 22:15:40 +0400
commitfe67d1826ccc51b99710f4284c5bd3a6998954a6 (patch)
tree343b3a7fdb4e31fd52f2e9cff9b92d7366c3ac3e
parentf039cc3a2544c08cd8fd0fef06eb727df17604a4 (diff)
* 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.cc2
-rw-r--r--winsup/cygwin/ChangeLog14
-rwxr-xr-xwinsup/cygwin/cygserver.cc48
-rw-r--r--winsup/cygwin/shm.cc5
-rwxr-xr-xwinsup/cygwin/threaded_queue.cc2
5 files changed, 61 insertions, 10 deletions
diff --git a/winsup/cygserver/threaded_queue.cc b/winsup/cygserver/threaded_queue.cc
index ee7a36e3f..ced597865 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 c7d973178..39c2051c6 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 8fe1d9dbb..072c99cfd 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 93d4414aa..f4c6df547 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 ee7a36e3f..ced597865 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);