MCPcopy Create free account
hub / github.com/apache/httpd / process_socket

Function process_socket

server/mpm/event/event.c:1005–1297  ·  view source on GitHub ↗

* process one connection in the worker */

Source from the content-addressed store, hash-verified

1003 * process one connection in the worker
1004 */
1005static void process_socket(apr_thread_t *thd, apr_pool_t * p, apr_socket_t * sock,
1006 event_conn_state_t * cs, int my_child_num,
1007 int my_thread_num)
1008{
1009 conn_rec *c;
1010 long conn_id = ID_FROM_CHILD_THREAD(my_child_num, my_thread_num);
1011 int clogging = 0;
1012 apr_status_t rv;
1013 int rc = OK;
1014
1015 if (cs == NULL) { /* This is a new connection */
1016 listener_poll_type *pt = apr_pcalloc(p, sizeof(*pt));
1017 cs = apr_pcalloc(p, sizeof(event_conn_state_t));
1018 cs->bucket_alloc = apr_bucket_alloc_create(p);
1019 ap_create_sb_handle(&cs->sbh, p, my_child_num, my_thread_num);
1020 c = ap_run_create_connection(p, ap_server_conf, sock,
1021 conn_id, cs->sbh, cs->bucket_alloc);
1022 if (!c) {
1023 ap_queue_info_push_pool(worker_queue_info, p);
1024 return;
1025 }
1026 apr_atomic_inc32(&connection_count);
1027 apr_pool_cleanup_register(c->pool, cs, decrement_connection_count,
1028 apr_pool_cleanup_null);
1029 ap_set_module_config(c->conn_config, &mpm_event_module, cs);
1030 c->current_thread = thd;
1031 c->cs = &cs->pub;
1032 cs->c = c;
1033 cs->p = p;
1034 cs->sc = ap_get_module_config(ap_server_conf->module_config,
1035 &mpm_event_module);
1036 cs->pfd.desc_type = APR_POLL_SOCKET;
1037 cs->pfd.desc.s = sock;
1038 pt->type = PT_CSD;
1039 pt->baton = cs;
1040 cs->pfd.client_data = pt;
1041 apr_pool_pre_cleanup_register(p, cs, ptrans_pre_cleanup);
1042 TO_QUEUE_ELEM_INIT(cs);
1043
1044 ap_update_vhost_given_ip(c);
1045
1046 rc = ap_pre_connection(c, sock);
1047 if (rc != OK && rc != DONE) {
1048 ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, c, APLOGNO(00469)
1049 "process_socket: connection aborted");
1050 close_connection(cs);
1051 return;
1052 }
1053
1054 /**
1055 * XXX If the platform does not have a usable way of bundling
1056 * accept() with a socket readability check, like Win32,
1057 * and there are measurable delays before the
1058 * socket is readable due to the first data packet arriving,
1059 * it might be better to create the cs on the listener thread
1060 * with the state set to CONN_STATE_KEEPALIVE
1061 *
1062 * FreeBSD users will want to enable the HTTP accept filter

Callers 1

worker_threadFunction · 0.70

Calls 15

ap_create_sb_handleFunction · 0.85
ap_queue_info_push_poolFunction · 0.85
ap_set_module_configFunction · 0.85
ap_get_module_configFunction · 0.85
ap_update_vhost_given_ipFunction · 0.85
ap_pre_connectionFunction · 0.85
ap_update_sb_handleFunction · 0.85
notify_resumeFunction · 0.85
notify_suspendFunction · 0.85
ap_update_child_statusFunction · 0.85
TO_QUEUE_APPENDFunction · 0.85

Tested by

no test coverage detected