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

(-)2.2.x/server/mpm/worker/worker.c (-21 / +31 lines)
Lines 590-595 static void dummy_signal_handler(int sig Link Here
590
590
591
static void *listener_thread(apr_thread_t *thd, void * dummy)
591
static void *listener_thread(apr_thread_t *thd, void * dummy)
592
{
592
{
593
    apr_pool_t *pool;
593
    proc_info * ti = dummy;
594
    proc_info * ti = dummy;
594
    int process_slot = ti->pid;
595
    int process_slot = ti->pid;
595
    apr_pool_t *tpool = apr_thread_pool_get(thd);
596
    apr_pool_t *tpool = apr_thread_pool_get(thd);
Lines 604-610 static void *listener_thread(apr_thread_ Link Here
604
    free(ti);
605
    free(ti);
605
606
606
    /* ### check the status */
607
    /* ### check the status */
607
    (void) apr_pollset_create(&pollset, num_listensocks, tpool, 0);
608
    (void) apr_pool_create(&pool, tpool);
609
    (void) apr_pollset_create(&pollset, num_listensocks, pool, 0);
608
610
609
    for (lr = ap_listeners; lr != NULL; lr = lr->next) {
611
    for (lr = ap_listeners; lr != NULL; lr = lr->next) {
610
        apr_pollfd_t pfd = { 0 };
612
        apr_pollfd_t pfd = { 0 };
Lines 913-919 static int check_signal(int signum) Link Here
913
    return 0;
915
    return 0;
914
}
916
}
915
917
916
static void create_listener_thread(thread_starter *ts)
918
static void create_listener_thread(thread_starter *ts, apr_pool_t *pool)
917
{
919
{
918
    int my_child_num = ts->child_num_arg;
920
    int my_child_num = ts->child_num_arg;
919
    apr_threadattr_t *thread_attr = ts->threadattr;
921
    apr_threadattr_t *thread_attr = ts->threadattr;
Lines 925-931 static void create_listener_thread(threa Link Here
925
    my_info->tid = -1; /* listener thread doesn't have a thread slot */
927
    my_info->tid = -1; /* listener thread doesn't have a thread slot */
926
    my_info->sd = 0;
928
    my_info->sd = 0;
927
    rv = apr_thread_create(&ts->listener, thread_attr, listener_thread,
929
    rv = apr_thread_create(&ts->listener, thread_attr, listener_thread,
928
                           my_info, pchild);
930
                           my_info, pool);
929
    if (rv != APR_SUCCESS) {
931
    if (rv != APR_SUCCESS) {
930
        ap_log_error(APLOG_MARK, APLOG_ALERT, rv, ap_server_conf,
932
        ap_log_error(APLOG_MARK, APLOG_ALERT, rv, ap_server_conf,
931
                     "apr_thread_create: unable to create listener thread");
933
                     "apr_thread_create: unable to create listener thread");
Lines 942-947 static void create_listener_thread(threa Link Here
942
 */
944
 */
943
static void * APR_THREAD_FUNC start_threads(apr_thread_t *thd, void *dummy)
945
static void * APR_THREAD_FUNC start_threads(apr_thread_t *thd, void *dummy)
944
{
946
{
947
    apr_pool_t *pool;
945
    thread_starter *ts = dummy;
948
    thread_starter *ts = dummy;
946
    apr_thread_t **threads = ts->threads;
949
    apr_thread_t **threads = ts->threads;
947
    apr_threadattr_t *thread_attr = ts->threadattr;
950
    apr_threadattr_t *thread_attr = ts->threadattr;
Lines 955-981 static void * APR_THREAD_FUNC start_thre Link Here
955
    int loops;
958
    int loops;
956
    int prev_threads_created;
959
    int prev_threads_created;
957
960
958
    /* We must create the fd queues before we start up the listener
961
    rv = apr_pool_create(&pool, NULL);
959
     * and worker threads. */
960
    worker_queue = apr_pcalloc(pchild, sizeof(*worker_queue));
961
    rv = ap_queue_init(worker_queue, ap_threads_per_child, pchild);
962
    if (rv != APR_SUCCESS) {
962
    if (rv != APR_SUCCESS) {
963
        ap_log_error(APLOG_MARK, APLOG_ALERT, rv, ap_server_conf,
963
        ap_log_error(APLOG_MARK, APLOG_ALERT, rv, ap_server_conf,
964
                     "ap_queue_init() failed");
964
                     "apr_pool_create() failed");
965
        clean_child_exit(APEXIT_CHILDFATAL);
965
        clean_child_exit(APEXIT_CHILDFATAL);
966
    }
966
    }
967
967
968
    rv = ap_queue_info_create(&worker_queue_info, pchild,
969
                              ap_threads_per_child);
970
    if (rv != APR_SUCCESS) {
971
        ap_log_error(APLOG_MARK, APLOG_ALERT, rv, ap_server_conf,
972
                     "ap_queue_info_create() failed");
973
        clean_child_exit(APEXIT_CHILDFATAL);
974
    }
975
976
    worker_sockets = apr_pcalloc(pchild, ap_threads_per_child
977
                                        * sizeof(apr_socket_t *));
978
979
    loops = prev_threads_created = 0;
968
    loops = prev_threads_created = 0;
980
    while (1) {
969
    while (1) {
981
        /* ap_threads_per_child does not include the listener thread */
970
        /* ap_threads_per_child does not include the listener thread */
Lines 1003-1009 static void * APR_THREAD_FUNC start_thre Link Here
1003
             * done because it lets us deal with tid better.
992
             * done because it lets us deal with tid better.
1004
             */
993
             */
1005
            rv = apr_thread_create(&threads[i], thread_attr,
994
            rv = apr_thread_create(&threads[i], thread_attr,
1006
                                   worker_thread, my_info, pchild);
995
                                   worker_thread, my_info, pool);
1007
            if (rv != APR_SUCCESS) {
996
            if (rv != APR_SUCCESS) {
1008
                ap_log_error(APLOG_MARK, APLOG_ALERT, rv, ap_server_conf,
997
                ap_log_error(APLOG_MARK, APLOG_ALERT, rv, ap_server_conf,
1009
                    "apr_thread_create: unable to create worker thread");
998
                    "apr_thread_create: unable to create worker thread");
Lines 1014-1020 static void * APR_THREAD_FUNC start_thre Link Here
1014
        }
1003
        }
1015
        /* Start the listener only when there are workers available */
1004
        /* Start the listener only when there are workers available */
1016
        if (!listener_started && threads_created) {
1005
        if (!listener_started && threads_created) {
1017
            create_listener_thread(ts);
1006
            create_listener_thread(ts, pool);
1018
            listener_started = 1;
1007
            listener_started = 1;
1019
        }
1008
        }
1020
        if (start_thread_may_exit || threads_created == ap_threads_per_child) {
1009
        if (start_thread_may_exit || threads_created == ap_threads_per_child) {
Lines 1179-1184 static void child_main(int child_num_arg Link Here
1179
        requests_this_child = INT_MAX;
1168
        requests_this_child = INT_MAX;
1180
    }
1169
    }
1181
1170
1171
    /* We must create the fd queues before we start up the listener
1172
     * and worker threads. */
1173
    worker_queue = apr_pcalloc(pchild, sizeof(*worker_queue));
1174
    rv = ap_queue_init(worker_queue, ap_threads_per_child, pchild);
1175
    if (rv != APR_SUCCESS) {
1176
        ap_log_error(APLOG_MARK, APLOG_ALERT, rv, ap_server_conf,
1177
                     "ap_queue_init() failed");
1178
        clean_child_exit(APEXIT_CHILDFATAL);
1179
    }
1180
1181
    rv = ap_queue_info_create(&worker_queue_info, pchild,
1182
                              ap_threads_per_child);
1183
    if (rv != APR_SUCCESS) {
1184
        ap_log_error(APLOG_MARK, APLOG_ALERT, rv, ap_server_conf,
1185
                     "ap_queue_info_create() failed");
1186
        clean_child_exit(APEXIT_CHILDFATAL);
1187
    }
1188
1189
    worker_sockets = apr_pcalloc(pchild, ap_threads_per_child
1190
                                        * sizeof(apr_socket_t *));
1191
1182
    /* Setup worker threads */
1192
    /* Setup worker threads */
1183
1193
1184
    /* clear the storage; we may not create all our threads immediately,
1194
    /* clear the storage; we may not create all our threads immediately,

Return to bug 41196