00001 /* 00002 * Copyright 2009 DreamLab Onet.pl Sp. z o.o. 00003 * Licensed under the Apache License, Version 2.0 (the "License"); 00004 * you may not use this file except in compliance with the License. 00005 * You may obtain a copy of the License at 00006 * 00007 * http://www.apache.org/licenses/LICENSE-2.0 00008 * 00009 * Unless required by applicable law or agreed to in writing, software 00010 * distributed under the License is distributed on an "AS IS" BASIS, 00011 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00012 * See the License for the specific language governing permissions and 00013 * limitations under the License. 00014 * 00015 * Authors: 00016 * Michal Szklarzewicz <michal(x)szklarzewicz(y)gmail(x)com> 00017 * Grzegorz Jablonski <jablonski(x)grzegorz(y)gmail(x)com> 00018 * (use dot instead of x, and @ instead of y) 00019 */ 00020 #ifndef _NGX_CONNECTION_POOL_H_INCLUDED_ 00021 #define _NGX_CONNECTION_POOL_H_INCLUDED_ 00022 00023 typedef struct ngx_connection_pool_s ngx_connection_pool_t; 00024 typedef struct ngx_pooled_connection_s ngx_pooled_connection_t; 00025 00029 struct ngx_connection_pool_s 00030 { 00031 struct sockaddr *sockaddr; 00032 ngx_uint_t sockaddr_size; 00033 ngx_pool_t *pool; 00034 ngx_log_t *log; 00035 ngx_uint_t stored_connections_limit; 00036 ngx_uint_t stored_connections; 00037 ngx_uint_t returned_connections; 00038 ngx_pooled_connection_t *first_connection; 00039 ngx_pooled_connection_t *last_connection; 00040 ngx_str_t name; 00041 }; 00042 00046 struct ngx_pooled_connection_s 00047 { 00048 void *data; 00049 ngx_connection_t *connection; 00050 ngx_socket_t fd; 00051 ngx_connection_pool_t *owner_pool; 00052 ngx_pool_t *pool; 00053 ngx_pooled_connection_t *next; 00054 ngx_pooled_connection_t *previous; 00055 }; 00056 00067 ngx_connection_pool_t* 00068 ngx_connection_pool_create(ngx_log_t *_log, struct sockaddr *_sockaddr, 00069 ngx_uint_t _sockaddr_size, ngx_uint_t _stored_connections_limit); 00070 00080 ngx_int_t 00081 ngx_connection_pool_get(ngx_connection_pool_t* pool, 00082 ngx_pooled_connection_t** new_connection, ngx_int_t force_new); 00083 00089 void 00090 ngx_connection_pool_return(ngx_pooled_connection_t *connection); 00091 00097 void 00098 ngx_connection_pool_release(ngx_pooled_connection_t *connection); 00099 #endif