Lines 182-187
Link Here
|
182 |
static int workers_may_exit = 0; |
182 |
static int workers_may_exit = 0; |
183 |
static int start_thread_may_exit = 0; |
183 |
static int start_thread_may_exit = 0; |
184 |
static int listener_may_exit = 0; |
184 |
static int listener_may_exit = 0; |
|
|
185 |
static int listener_is_wakeable = 0; /* Pollset supports APR_POLLSET_WAKEABLE */ |
185 |
static int num_listensocks = 0; |
186 |
static int num_listensocks = 0; |
186 |
static apr_int32_t conns_this_child; /* MaxConnectionsPerChild, only access |
187 |
static apr_int32_t conns_this_child; /* MaxConnectionsPerChild, only access |
187 |
in listener thread */ |
188 |
in listener thread */ |
Lines 493-498
Link Here
|
493 |
return; |
494 |
return; |
494 |
} |
495 |
} |
495 |
|
496 |
|
|
|
497 |
/* A wakeable listener might be blocked indefinitely on apr_pollset_poll. */ |
498 |
if (listener_is_wakeable) { |
499 |
apr_pollset_wakeup(event_pollset); |
500 |
} |
501 |
|
496 |
/* unblock the listener if it's waiting for a worker */ |
502 |
/* unblock the listener if it's waiting for a worker */ |
497 |
ap_queue_info_term(worker_queue_info); |
503 |
ap_queue_info_term(worker_queue_info); |
498 |
|
504 |
|
Lines 696-702
Link Here
|
696 |
default: |
702 |
default: |
697 |
break; |
703 |
break; |
698 |
} |
704 |
} |
699 |
apr_atomic_dec32(&connection_count); |
705 |
/* Unblock the wakeable listener waiting for connection_count = 0. */ |
|
|
706 |
if (!apr_atomic_dec32(&connection_count) |
707 |
&& listener_may_exit && listener_is_wakeable) { |
708 |
apr_pollset_wakeup(event_pollset); |
709 |
} |
700 |
return APR_SUCCESS; |
710 |
return APR_SUCCESS; |
701 |
} |
711 |
} |
702 |
|
712 |
|
Lines 1523-1528
Link Here
|
1523 |
if (insert) { |
1533 |
if (insert) { |
1524 |
/* Okay, add sorted by when.. */ |
1534 |
/* Okay, add sorted by when.. */ |
1525 |
apr_skiplist_insert(timer_skiplist, te); |
1535 |
apr_skiplist_insert(timer_skiplist, te); |
|
|
1536 |
/* |
1537 |
* Force apr_pollset_poll to wake up the listener since it might need |
1538 |
* to process a new timer. |
1539 |
*/ |
1540 |
if (listener_is_wakeable) { |
1541 |
apr_pollset_wakeup(event_pollset); |
1542 |
} |
1526 |
} |
1543 |
} |
1527 |
apr_thread_mutex_unlock(g_timer_skiplist_mtx); |
1544 |
apr_thread_mutex_unlock(g_timer_skiplist_mtx); |
1528 |
|
1545 |
|
Lines 1832-1838
Link Here
|
1832 |
} |
1849 |
} |
1833 |
} |
1850 |
} |
1834 |
else { |
1851 |
else { |
1835 |
timeout_interval = apr_time_from_msec(100); |
1852 |
/* |
|
|
1853 |
* If the listener is wakeable and there are no timers |
1854 |
* in the skiplist, it can sleep indefinitely |
1855 |
* until an event occurs. The listener will be woken up |
1856 |
* via apr_pollset_wakeup calls. |
1857 |
*/ |
1858 |
if (listener_is_wakeable) { |
1859 |
timeout_interval = -1; |
1860 |
} else { |
1861 |
/* The listener is not wakeable so polling must be performed. */ |
1862 |
timeout_interval = apr_time_from_msec(100); |
1863 |
} |
1836 |
} |
1864 |
} |
1837 |
while (te) { |
1865 |
while (te) { |
1838 |
if (te->when < now + EVENT_FUDGE_FACTOR) { |
1866 |
if (te->when < now + EVENT_FUDGE_FACTOR) { |
Lines 2385-2397
Link Here
|
2385 |
* connections in K-A or lingering |
2413 |
* connections in K-A or lingering |
2386 |
* close? |
2414 |
* close? |
2387 |
*/ |
2415 |
*/ |
2388 |
pchild, APR_POLLSET_THREADSAFE | APR_POLLSET_NOCOPY | APR_POLLSET_NODEFAULT, |
2416 |
pchild, APR_POLLSET_THREADSAFE | APR_POLLSET_NOCOPY |
|
|
2417 |
| APR_POLLSET_NODEFAULT | APR_POLLSET_WAKEABLE, |
2389 |
good_methods[i]); |
2418 |
good_methods[i]); |
2390 |
if (rv == APR_SUCCESS) { |
2419 |
if (rv == APR_SUCCESS) { |
|
|
2420 |
listener_is_wakeable = 1; |
2391 |
break; |
2421 |
break; |
2392 |
} |
2422 |
} |
2393 |
} |
2423 |
} |
2394 |
if (rv != APR_SUCCESS) { |
2424 |
if (rv != APR_SUCCESS) { |
|
|
2425 |
listener_is_wakeable = 0; |
2395 |
rv = apr_pollset_create(&event_pollset, |
2426 |
rv = apr_pollset_create(&event_pollset, |
2396 |
threads_per_child*2, /* XXX don't we need more, to handle |
2427 |
threads_per_child*2, /* XXX don't we need more, to handle |
2397 |
* connections in K-A or lingering |
2428 |
* connections in K-A or lingering |