View | Details | Raw Unified | Return to bug 48094
Collapse All | Expand All

(-)server/mpm/worker/worker.c (+45 lines)
Lines 237-244 Link Here
237
 * perform a non-graceful (forced) shutdown of the server. */
237
 * perform a non-graceful (forced) shutdown of the server. */
238
static apr_socket_t **worker_sockets;
238
static apr_socket_t **worker_sockets;
239
239
240
#ifdef HAVE_PTHREAD_KILL
241
242
#define SOCKET_SIGNAL       AP_SIG_GRACEFUL_STOP
243
244
static apr_os_thread_t **worker_os_threads;
245
246
static void worker_socket_shutdown(int sig)
247
{
248
    int i;
249
250
    for (i = 0; i < threads_per_child; i++) {
251
        if (worker_os_threads[i] &&
252
            pthread_equal(*worker_os_threads[i], pthread_self())) {
253
254
            if (worker_sockets[i]) {
255
                    apr_socket_shutdown(worker_sockets[i],
256
                                        APR_SHUTDOWN_READWRITE);
257
            }
258
            break;
259
        }
260
    }
261
}
262
240
static void close_worker_sockets(void)
263
static void close_worker_sockets(void)
241
{
264
{
265
   int i;
266
267
    for (i = 0; i < threads_per_child; i++) {
268
        if (worker_os_threads[i]) {
269
            pthread_kill(*worker_os_threads[i], SOCKET_SIGNAL);
270
        }
271
    }
272
}
273
#else
274
static void close_worker_sockets(void)
275
{
242
    int i;
276
    int i;
243
    for (i = 0; i < threads_per_child; i++) {
277
    for (i = 0; i < threads_per_child; i++) {
244
        if (worker_sockets[i]) {
278
        if (worker_sockets[i]) {
Lines 247-252 Link Here
247
        }
281
        }
248
    }
282
    }
249
}
283
}
284
#endif
250
285
251
static void wakeup_listener(void)
286
static void wakeup_listener(void)
252
{
287
{
Lines 863-868 Link Here
863
#ifdef HAVE_PTHREAD_KILL
898
#ifdef HAVE_PTHREAD_KILL
864
    unblock_signal(WORKER_SIGNAL);
899
    unblock_signal(WORKER_SIGNAL);
865
    apr_signal(WORKER_SIGNAL, dummy_signal_handler);
900
    apr_signal(WORKER_SIGNAL, dummy_signal_handler);
901
902
    unblock_signal(SOCKET_SIGNAL);
903
    apr_signal(SOCKET_SIGNAL, worker_socket_shutdown);
866
#endif
904
#endif
867
905
868
    while (!workers_may_exit) {
906
    while (!workers_may_exit) {
Lines 1003-1008 Link Here
1003
1041
1004
    worker_sockets = apr_pcalloc(pchild, threads_per_child
1042
    worker_sockets = apr_pcalloc(pchild, threads_per_child
1005
                                        * sizeof(apr_socket_t *));
1043
                                        * sizeof(apr_socket_t *));
1044
#ifdef HAVE_PTHREAD_KILL
1045
    worker_os_threads = apr_pcalloc(pchild, threads_per_child
1046
                                           * sizeof(*worker_os_threads));
1047
#endif
1006
1048
1007
    loops = prev_threads_created = 0;
1049
    loops = prev_threads_created = 0;
1008
    while (1) {
1050
    while (1) {
Lines 1038-1043 Link Here
1038
                /* let the parent decide how bad this really is */
1080
                /* let the parent decide how bad this really is */
1039
                clean_child_exit(APEXIT_CHILDSICK);
1081
                clean_child_exit(APEXIT_CHILDSICK);
1040
            }
1082
            }
1083
#ifdef HAVE_PTHREAD_KILL
1084
            apr_os_thread_get(&worker_os_threads[i], threads[i]);
1085
#endif
1041
            threads_created++;
1086
            threads_created++;
1042
        }
1087
        }
1043
        /* Start the listener only when there are workers available */
1088
        /* Start the listener only when there are workers available */

Return to bug 48094