You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by sf...@apache.org on 2016/04/11 00:53:42 UTC
svn commit: r1738486 - in /httpd/httpd/trunk/server/mpm/event: event.c
fdqueue.c fdqueue.h
Author: sf
Date: Sun Apr 10 22:53:42 2016
New Revision: 1738486
URL: http://svn.apache.org/viewvc?rev=1738486&view=rev
Log:
Exit threads early during shutdown, part 2
Follow up to r1738466: During graceful shutdown, when the listener thread is
closing a connection, it needs to wake up a worker thread so that it may
terminate.
Modified:
httpd/httpd/trunk/server/mpm/event/event.c
httpd/httpd/trunk/server/mpm/event/fdqueue.c
httpd/httpd/trunk/server/mpm/event/fdqueue.h
Modified: httpd/httpd/trunk/server/mpm/event/event.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/event/event.c?rev=1738486&r1=1738485&r2=1738486&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/event/event.c (original)
+++ httpd/httpd/trunk/server/mpm/event/event.c Sun Apr 10 22:53:42 2016
@@ -950,6 +950,8 @@ static int start_lingering_close_nonbloc
|| apr_socket_shutdown(csd, APR_SHUTDOWN_WRITE) != APR_SUCCESS) {
apr_socket_close(csd);
ap_push_pool(worker_queue_info, cs->p);
+ if (dying)
+ ap_queue_interrupt_one(worker_queue);
return 0;
}
return start_lingering_close_common(cs, 0);
@@ -973,6 +975,8 @@ static int stop_lingering_close(event_co
AP_DEBUG_ASSERT(0);
}
ap_push_pool(worker_queue_info, cs->p);
+ if (dying)
+ ap_queue_interrupt_one(worker_queue);
return 0;
}
@@ -1645,6 +1649,8 @@ static void process_lingering_close(even
TO_QUEUE_ELEM_INIT(cs);
ap_push_pool(worker_queue_info, cs->p);
+ if (dying)
+ ap_queue_interrupt_one(worker_queue);
}
/* call 'func' for all elements of 'q' with timeout less than 'timeout_time'.
Modified: httpd/httpd/trunk/server/mpm/event/fdqueue.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/event/fdqueue.c?rev=1738486&r1=1738485&r2=1738486&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/event/fdqueue.c (original)
+++ httpd/httpd/trunk/server/mpm/event/fdqueue.c Sun Apr 10 22:53:42 2016
@@ -487,7 +487,7 @@ apr_status_t ap_queue_pop_something(fd_q
return rv;
}
-static apr_status_t queue_interrupt_all(fd_queue_t *queue, int term)
+static apr_status_t queue_interrupt(fd_queue_t *queue, int all, int term)
{
apr_status_t rv;
@@ -501,16 +501,24 @@ static apr_status_t queue_interrupt_all(
if (term) {
queue->terminated = 1;
}
- apr_thread_cond_broadcast(queue->not_empty);
+ if (all)
+ apr_thread_cond_broadcast(queue->not_empty);
+ else
+ apr_thread_cond_signal(queue->not_empty);
return apr_thread_mutex_unlock(queue->one_big_mutex);
}
apr_status_t ap_queue_interrupt_all(fd_queue_t * queue)
{
- return queue_interrupt_all(queue, 0);
+ return queue_interrupt(queue, 1, 0);
+}
+
+apr_status_t ap_queue_interrupt_one(fd_queue_t * queue)
+{
+ return queue_interrupt(queue, 0, 0);
}
apr_status_t ap_queue_term(fd_queue_t * queue)
{
- return queue_interrupt_all(queue, 1);
+ return queue_interrupt(queue, 1, 1);
}
Modified: httpd/httpd/trunk/server/mpm/event/fdqueue.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/event/fdqueue.h?rev=1738486&r1=1738485&r2=1738486&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/event/fdqueue.h (original)
+++ httpd/httpd/trunk/server/mpm/event/fdqueue.h Sun Apr 10 22:53:42 2016
@@ -101,6 +101,7 @@ apr_status_t ap_queue_pop_something(fd_q
event_conn_state_t ** ecs, apr_pool_t ** p,
timer_event_t ** te);
apr_status_t ap_queue_interrupt_all(fd_queue_t * queue);
+apr_status_t ap_queue_interrupt_one(fd_queue_t * queue);
apr_status_t ap_queue_term(fd_queue_t * queue);
#endif /* FDQUEUE_H */