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

Function core_create_conn

server/core.c:5248–5309  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5246}
5247
5248static conn_rec *core_create_conn(apr_pool_t *ptrans, server_rec *server,
5249 apr_socket_t *csd, long id, void *sbh,
5250 apr_bucket_alloc_t *alloc)
5251{
5252 apr_status_t rv;
5253 conn_rec *c = (conn_rec *) apr_pcalloc(ptrans, sizeof(conn_rec));
5254
5255 c->sbh = sbh;
5256 ap_update_child_status(c->sbh, SERVER_BUSY_READ, NULL);
5257
5258 /* Got a connection structure, so initialize what fields we can
5259 * (the rest are zeroed out by pcalloc).
5260 */
5261 c->pool = ptrans;
5262 c->conn_config = ap_create_conn_config(ptrans);
5263 c->notes = apr_table_make(ptrans, 5);
5264
5265 if ((rv = apr_socket_addr_get(&c->local_addr, APR_LOCAL, csd))
5266 != APR_SUCCESS) {
5267 ap_log_error(APLOG_MARK, APLOG_INFO, rv, server, APLOGNO(00137)
5268 "apr_socket_addr_get(APR_LOCAL)");
5269 apr_socket_close(csd);
5270 return NULL;
5271 }
5272 if (apr_sockaddr_ip_get(&c->local_ip, c->local_addr)) {
5273#if APR_HAVE_SOCKADDR_UN
5274 if (c->local_addr->family == APR_UNIX) {
5275 c->local_ip = apr_pstrndup(c->pool, c->local_addr->ipaddr_ptr,
5276 c->local_addr->ipaddr_len);
5277 }
5278 else
5279#endif
5280 c->local_ip = apr_pstrdup(c->pool, "unknown");
5281 }
5282
5283 if ((rv = apr_socket_addr_get(&c->client_addr, APR_REMOTE, csd))
5284 != APR_SUCCESS) {
5285 ap_log_error(APLOG_MARK, APLOG_INFO, rv, server, APLOGNO(00138)
5286 "apr_socket_addr_get(APR_REMOTE)");
5287 apr_socket_close(csd);
5288 return NULL;
5289 }
5290 if (apr_sockaddr_ip_get(&c->client_ip, c->client_addr)) {
5291#if APR_HAVE_SOCKADDR_UN
5292 if (c->client_addr->family == APR_UNIX) {
5293 c->client_ip = apr_pstrndup(c->pool, c->client_addr->ipaddr_ptr,
5294 c->client_addr->ipaddr_len);
5295 }
5296 else
5297#endif
5298 c->client_ip = apr_pstrdup(c->pool, "unknown");
5299 }
5300
5301 c->base_server = server;
5302
5303 c->id = id;
5304 c->bucket_alloc = alloc;
5305

Callers

nothing calls this directly

Calls 3

ap_update_child_statusFunction · 0.85
ap_create_conn_configFunction · 0.85
ap_log_errorFunction · 0.50

Tested by

no test coverage detected