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

(-)httpd-2.2.14-v/server/mpm/worker/worker.c (+45 lines)
Lines 230-235 Link Here
230
 * perform a non-graceful (forced) shutdown of the server. */
230
 * perform a non-graceful (forced) shutdown of the server. */
231
static apr_socket_t **worker_sockets;
231
static apr_socket_t **worker_sockets;
232
232
233
#ifdef HAVE_PTHREAD_KILL
234
235
#define SOCKET_SIGNAL       AP_SIG_GRACEFUL_STOP
236
237
static apr_os_thread_t **worker_os_threads;
238
239
static void worker_socket_shutdown(int sig)
240
{
241
    int i;
242
243
    for (i = 0; i < ap_threads_per_child; i++) {
244
        if (worker_os_threads[i] &&
245
            pthread_equal(*worker_os_threads[i], pthread_self())) {
246
247
            if (worker_sockets[i]) {
248
                    apr_socket_shutdown(worker_sockets[i],
249
                                        APR_SHUTDOWN_READWRITE);
250
            }
251
            break;
252
        }
253
    }
254
}
255
256
static void close_worker_sockets(void)
257
{
258
   int i;
259
260
    for (i = 0; i < ap_threads_per_child; i++) {
261
        if (worker_os_threads[i]) {
262
            pthread_kill(*worker_os_threads[i], SOCKET_SIGNAL);
263
        }
264
    }
265
}
266
#else
233
static void close_worker_sockets(void)
267
static void close_worker_sockets(void)
234
{
268
{
235
    int i;
269
    int i;
Lines 240-245 Link Here
240
        }
274
        }
241
    }
275
    }
242
}
276
}
277
#endif
243
278
244
static void wakeup_listener(void)
279
static void wakeup_listener(void)
245
{
280
{
Lines 837-842 Link Here
837
#ifdef HAVE_PTHREAD_KILL
872
#ifdef HAVE_PTHREAD_KILL
838
    unblock_signal(WORKER_SIGNAL);
873
    unblock_signal(WORKER_SIGNAL);
839
    apr_signal(WORKER_SIGNAL, dummy_signal_handler);
874
    apr_signal(WORKER_SIGNAL, dummy_signal_handler);
875
876
    unblock_signal(SOCKET_SIGNAL);
877
    apr_signal(SOCKET_SIGNAL, worker_socket_shutdown);
840
#endif
878
#endif
841
879
842
    while (!workers_may_exit) {
880
    while (!workers_may_exit) {
Lines 977-982 Link Here
977
1015
978
    worker_sockets = apr_pcalloc(pchild, ap_threads_per_child
1016
    worker_sockets = apr_pcalloc(pchild, ap_threads_per_child
979
                                        * sizeof(apr_socket_t *));
1017
                                        * sizeof(apr_socket_t *));
1018
#ifdef HAVE_PTHREAD_KILL
1019
    worker_os_threads = apr_pcalloc(pchild, ap_threads_per_child
1020
                                           * sizeof(*worker_os_threads));
1021
#endif
980
1022
981
    loops = prev_threads_created = 0;
1023
    loops = prev_threads_created = 0;
982
    while (1) {
1024
    while (1) {
Lines 1012-1017 Link Here
1012
                /* let the parent decide how bad this really is */
1054
                /* let the parent decide how bad this really is */
1013
                clean_child_exit(APEXIT_CHILDSICK);
1055
                clean_child_exit(APEXIT_CHILDSICK);
1014
            }
1056
            }
1057
#ifdef HAVE_PTHREAD_KILL
1058
            apr_os_thread_get(&worker_os_threads[i], threads[i]);
1059
#endif
1015
            threads_created++;
1060
            threads_created++;
1016
        }
1061
        }
1017
        /* Start the listener only when there are workers available */
1062
        /* Start the listener only when there are workers available */

Return to bug 48094