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

(-)server/mpm/event/event.c (-22 / +35 lines)
Lines 690-713 static int start_lingering_close_common(event_conn Link Here
690
    else {
690
    else {
691
        cs->c->sbh = NULL;
691
        cs->c->sbh = NULL;
692
    }
692
    }
693
    apr_thread_mutex_lock(timeout_mutex);
694
    TO_QUEUE_APPEND(q, cs);
695
    cs->pfd.reqevents = (
693
    cs->pfd.reqevents = (
696
            cs->pub.sense == CONN_SENSE_WANT_WRITE ? APR_POLLOUT :
694
            cs->pub.sense == CONN_SENSE_WANT_WRITE ? APR_POLLOUT :
697
                    APR_POLLIN) | APR_POLLHUP | APR_POLLERR;
695
                    APR_POLLIN) | APR_POLLHUP | APR_POLLERR;
698
    cs->pub.sense = CONN_SENSE_DEFAULT;
696
    cs->pub.sense = CONN_SENSE_DEFAULT;
697
    apr_thread_mutex_lock(timeout_mutex);
698
    TO_QUEUE_APPEND(q, cs);
699
    rv = apr_pollset_add(event_pollset, &cs->pfd);
699
    rv = apr_pollset_add(event_pollset, &cs->pfd);
700
    apr_thread_mutex_unlock(timeout_mutex);
701
    if (rv != APR_SUCCESS && !APR_STATUS_IS_EEXIST(rv)) {
700
    if (rv != APR_SUCCESS && !APR_STATUS_IS_EEXIST(rv)) {
701
        TO_QUEUE_REMOVE(q, cs);
702
        apr_thread_mutex_unlock(timeout_mutex);
702
        ap_log_error(APLOG_MARK, APLOG_ERR, rv, ap_server_conf, APLOGNO(03092)
703
        ap_log_error(APLOG_MARK, APLOG_ERR, rv, ap_server_conf, APLOGNO(03092)
703
                     "start_lingering_close: apr_pollset_add failure");
704
                     "start_lingering_close: apr_pollset_add failure");
704
        apr_thread_mutex_lock(timeout_mutex);
705
        TO_QUEUE_REMOVE(q, cs);
706
        apr_thread_mutex_unlock(timeout_mutex);
707
        apr_socket_close(cs->pfd.desc.s);
705
        apr_socket_close(cs->pfd.desc.s);
708
        ap_push_pool(worker_queue_info, cs->p);
706
        ap_push_pool(worker_queue_info, cs->p);
709
        return 0;
707
        return 0;
710
    }
708
    }
709
    apr_thread_mutex_unlock(timeout_mutex);
711
    return 1;
710
    return 1;
712
}
711
}
713
712
Lines 974-987 read_request: Link Here
974
             */
973
             */
975
            cs->queue_timestamp = apr_time_now();
974
            cs->queue_timestamp = apr_time_now();
976
            notify_suspend(cs);
975
            notify_suspend(cs);
977
            apr_thread_mutex_lock(timeout_mutex);
978
            TO_QUEUE_APPEND(cs->sc->wc_q, cs);
979
            cs->pfd.reqevents = (
976
            cs->pfd.reqevents = (
980
                    cs->pub.sense == CONN_SENSE_WANT_READ ? APR_POLLIN :
977
                    cs->pub.sense == CONN_SENSE_WANT_READ ? APR_POLLIN :
981
                            APR_POLLOUT) | APR_POLLHUP | APR_POLLERR;
978
                            APR_POLLOUT) | APR_POLLHUP | APR_POLLERR;
982
            cs->pub.sense = CONN_SENSE_DEFAULT;
979
            cs->pub.sense = CONN_SENSE_DEFAULT;
980
            apr_thread_mutex_lock(timeout_mutex);
981
            TO_QUEUE_APPEND(cs->sc->wc_q, cs);
983
            rc = apr_pollset_add(event_pollset, &cs->pfd);
982
            rc = apr_pollset_add(event_pollset, &cs->pfd);
984
            apr_thread_mutex_unlock(timeout_mutex);
983
            if (rc != APR_SUCCESS && !APR_STATUS_IS_EEXIST(rc)) {
984
                TO_QUEUE_REMOVE(cs->sc->wc_q, cs);
985
                apr_thread_mutex_unlock(timeout_mutex);
986
                ap_log_error(APLOG_MARK, APLOG_ERR, rc, ap_server_conf, APLOGNO(03465)
987
                             "process_socket: apr_pollset_add failure for "
988
                             "write completion");
989
                apr_socket_close(cs->pfd.desc.s);
990
                ap_push_pool(worker_queue_info, cs->p);
991
            }
992
            else {
993
                apr_thread_mutex_unlock(timeout_mutex);
994
            }
985
            return;
995
            return;
986
        }
996
        }
987
        else if (c->keepalive != AP_CONN_KEEPALIVE || c->aborted ||
997
        else if (c->keepalive != AP_CONN_KEEPALIVE || c->aborted ||
Lines 1011-1029 read_request: Link Here
1011
         */
1021
         */
1012
        cs->queue_timestamp = apr_time_now();
1022
        cs->queue_timestamp = apr_time_now();
1013
        notify_suspend(cs);
1023
        notify_suspend(cs);
1014
        apr_thread_mutex_lock(timeout_mutex);
1015
        TO_QUEUE_APPEND(cs->sc->ka_q, cs);
1016
1024
1017
        /* Add work to pollset. */
1025
        /* Add work to pollset. */
1018
        cs->pfd.reqevents = APR_POLLIN;
1026
        cs->pfd.reqevents = APR_POLLIN;
1027
        apr_thread_mutex_lock(timeout_mutex);
1028
        TO_QUEUE_APPEND(cs->sc->ka_q, cs);
1019
        rc = apr_pollset_add(event_pollset, &cs->pfd);
1029
        rc = apr_pollset_add(event_pollset, &cs->pfd);
1020
        apr_thread_mutex_unlock(timeout_mutex);
1030
        if (rc != APR_SUCCESS && !APR_STATUS_IS_EEXIST(rc)) {
1021
1031
            TO_QUEUE_REMOVE(cs->sc->ka_q, cs);
1022
        if (rc != APR_SUCCESS) {
1032
            apr_thread_mutex_unlock(timeout_mutex);
1023
            ap_log_error(APLOG_MARK, APLOG_ERR, rc, ap_server_conf, APLOGNO(03093)
1033
            ap_log_error(APLOG_MARK, APLOG_ERR, rc, ap_server_conf, APLOGNO(03093)
1024
                         "process_socket: apr_pollset_add failure");
1034
                         "process_socket: apr_pollset_add failure for "
1025
            AP_DEBUG_ASSERT(rc == APR_SUCCESS);
1035
                         "keep alive");
1036
            apr_socket_close(cs->pfd.desc.s);
1037
            ap_push_pool(worker_queue_info, cs->p);
1026
        }
1038
        }
1039
        else {
1040
            apr_thread_mutex_unlock(timeout_mutex);
1041
        }
1027
    }
1042
    }
1028
    else if (cs->pub.state == CONN_STATE_SUSPENDED) {
1043
    else if (cs->pub.state == CONN_STATE_SUSPENDED) {
1029
        apr_atomic_inc32(&suspended_count);
1044
        apr_atomic_inc32(&suspended_count);
Lines 1274-1289 static void process_lingering_close(event_conn_sta Link Here
1274
    }
1289
    }
1275
1290
1276
    apr_thread_mutex_lock(timeout_mutex);
1291
    apr_thread_mutex_lock(timeout_mutex);
1292
    TO_QUEUE_REMOVE(q, cs);
1277
    rv = apr_pollset_remove(event_pollset, pfd);
1293
    rv = apr_pollset_remove(event_pollset, pfd);
1278
    AP_DEBUG_ASSERT(rv == APR_SUCCESS);
1294
    apr_thread_mutex_unlock(timeout_mutex);
1295
    AP_DEBUG_ASSERT(rv == APR_SUCCESS ||  APR_STATUS_IS_NOTFOUND(rv));
1296
    TO_QUEUE_ELEM_INIT(cs);
1279
1297
1280
    rv = apr_socket_close(csd);
1298
    rv = apr_socket_close(csd);
1281
    AP_DEBUG_ASSERT(rv == APR_SUCCESS);
1299
    AP_DEBUG_ASSERT(rv == APR_SUCCESS);
1282
1300
1283
    TO_QUEUE_REMOVE(q, cs);
1284
    apr_thread_mutex_unlock(timeout_mutex);
1285
    TO_QUEUE_ELEM_INIT(cs);
1286
1287
    ap_push_pool(worker_queue_info, cs->p);
1301
    ap_push_pool(worker_queue_info, cs->p);
1288
    if (dying)
1302
    if (dying)
1289
        ap_queue_interrupt_one(worker_queue);
1303
        ap_queue_interrupt_one(worker_queue);
Lines 1514-1520 static void * APR_THREAD_FUNC listener_thread(apr_ Link Here
1514
                    TO_QUEUE_REMOVE(remove_from_q, cs);
1528
                    TO_QUEUE_REMOVE(remove_from_q, cs);
1515
                    rc = apr_pollset_remove(event_pollset, &cs->pfd);
1529
                    rc = apr_pollset_remove(event_pollset, &cs->pfd);
1516
                    apr_thread_mutex_unlock(timeout_mutex);
1530
                    apr_thread_mutex_unlock(timeout_mutex);
1517
1518
                    /*
1531
                    /*
1519
                     * Some of the pollset backends, like KQueue or Epoll
1532
                     * Some of the pollset backends, like KQueue or Epoll
1520
                     * automagically remove the FD if the socket is closed,
1533
                     * automagically remove the FD if the socket is closed,

Return to bug 61551