summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstbuehler <stbuehler@152afb58-edef-0310-8abb-c4023f1b3aa9>2009-06-11 18:00:28 +0000
committerstbuehler <stbuehler@152afb58-edef-0310-8abb-c4023f1b3aa9>2009-06-11 18:00:28 +0000
commit34055922d47de4008ed067488de4d22bdd58ad51 (patch)
tree936b5bb71ee1e22b9f14de74be7d558a6fa69ff2
parent135bc75b71722180e659f1a52c313dd81a89f1d3 (diff)
downloadlighttpd-34055922d47de4008ed067488de4d22bdd58ad51.tar.gz
Send gthread dummy pointers to wake them up for faster exit (thx peto, fixes #1812)
git-svn-id: svn://svn.lighttpd.net/lighttpd/trunk@2538 152afb58-edef-0310-8abb-c4023f1b3aa9
-rw-r--r--NEWS1
-rw-r--r--src/network_gthread_aio.c10
-rw-r--r--src/network_gthread_sendfile.c9
-rw-r--r--src/server.c10
-rw-r--r--src/stat_cache.c3
5 files changed, 28 insertions, 5 deletions
diff --git a/NEWS b/NEWS
index bf92160f..ec6c203f 100644
--- a/NEWS
+++ b/NEWS
@@ -119,6 +119,7 @@ NEWS
* Free wakeup_iosocket (thx peto, fixes #1808)
* Free ssl cipher list (thx peto, fixes #1809)
* Add gthread-freebsd-sendfile (thx peto, fixes #1795)
+ * Send gthread dummy pointers to wake them up for faster exit (thx peto, fixes #1812)
- 1.5.0-r19.. -
* -F option added for spawn-fcgi
diff --git a/src/network_gthread_aio.c b/src/network_gthread_aio.c
index 4b9fdd38..92c5d6be 100644
--- a/src/network_gthread_aio.c
+++ b/src/network_gthread_aio.c
@@ -111,14 +111,20 @@ gpointer network_gthread_aio_read_thread(gpointer _srv) {
ssize_t r;
off_t offset;
size_t toSend;
- chunk *c = wj->c;
- connection *con = wj->con;
+ chunk *c;
+ connection *con;
off_t max_toSend = 64 kByte; /** should be larger than the send buffer */
int fadvise_fd = 0;
off_t fadvise_offset = 0;
off_t fadvise_len = 0;
+ if(wj == (write_job *) 1)
+ continue; /* just notifying us that srv->is_shutdown changed */
+
+ c = wj->c;
+ con = wj->con;
+
#if 0
/* try to be adaptive */
int snd_buf_size = 0;
diff --git a/src/network_gthread_sendfile.c b/src/network_gthread_sendfile.c
index 690e848f..39a40087 100644
--- a/src/network_gthread_sendfile.c
+++ b/src/network_gthread_sendfile.c
@@ -99,10 +99,15 @@ gpointer network_gthread_sendfile_read_thread(gpointer _srv) {
ssize_t r;
off_t offset;
size_t toSend;
- chunk *c = wj->c;
- connection *con = wj->con;
+ chunk *c;
+ connection *con;
off_t max_toSend = 512 kByte; /** should be larger than the send buffer */
+ if(wj == (write_job *) 1)
+ continue; /* just notifying us that srv->is_shutdown changed */
+
+ c = wj->c;
+ con = wj->con;
offset = c->file.start + c->offset;
toSend = c->file.length - c->offset > max_toSend ?
diff --git a/src/server.c b/src/server.c
index 57566b3b..6e69be71 100644
--- a/src/server.c
+++ b/src/server.c
@@ -894,6 +894,7 @@ static int lighty_mainloop(server *srv) {
/* we are in graceful shutdown phase and all connections are closed
* we are ready to terminate without harming anyone */
srv_shutdown = 1;
+ continue;
}
/* we still have some fds to share */
@@ -1851,6 +1852,10 @@ int main (int argc, char **argv, char **envp) {
}
for (i = 0; i < srv->srvconf.max_stat_threads; i++) {
+ g_async_queue_push(srv->stat_queue, (void *) 1);
+ }
+
+ for (i = 0; i < srv->srvconf.max_stat_threads; i++) {
g_thread_join(stat_cache_threads[i]);
}
@@ -1860,7 +1865,10 @@ int main (int argc, char **argv, char **envp) {
g_mutex_unlock(joblist_queue_mutex);
g_cond_signal(joblist_queue_cond);
- if (joblist_queue_thread_id) g_thread_join(joblist_queue_thread_id);
+ if (joblist_queue_thread_id) {
+ g_async_queue_push(srv->joblist_queue, (void *) 1);
+ g_thread_join(joblist_queue_thread_id);
+ }
#if 0
g_mutex_lock(joblist_queue_mutex);
diff --git a/src/stat_cache.c b/src/stat_cache.c
index da2f2c61..276c8ac8 100644
--- a/src/stat_cache.c
+++ b/src/stat_cache.c
@@ -121,6 +121,9 @@ gpointer stat_cache_thread(gpointer _srv) {
g_time_val_add(&ts, 500 * 1000);
if ((sj = g_async_queue_timed_pop(inq, &ts))) {
+ if(sj == (stat_job *) 1)
+ continue; /* just notifying us that srv->is_shutdown changed */
+
/* don't care about the return code for now */
stat(sj->name->ptr, &st);