acl/app/jaws/global/conn_cache.h

82 lines
2.2 KiB
C
Raw Normal View History

2014-11-19 00:25:21 +08:00
#ifndef __CONN_CACHE_INCLUDE_H__
#define __CONN_CACHE_INCLUDE_H__
#include "lib_acl.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct CONN_CACHE {
ACL_AIO *aio;
ACL_HTABLE *cache;
int conn_limit;
int nset;
int nget;
int nclose;
} CONN_CACHE;
typedef struct CONN CONN;
/**
* <EFBFBD><EFBFBD><EFBFBD>ӳس<EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD>ú<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>
* @param aio {ACL_AIO*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param conn_limit {int} ÿһ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳص<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return {CONN_CACHE*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳصĻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
CONN_CACHE *conn_cache_create(ACL_AIO *aio, int conn_limit);
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param cache {CONN_CAHCE*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param timeout {int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵij<EFBFBD>ʱʱ<EFBFBD><EFBFBD>
* @param free_fn {void (*)(ACL_ASTREAM*, void*)} <EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>Ļص<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ò<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǿգ<EFBFBD><EFBFBD>򵱸<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӱ<EFBFBD><EFBFBD>ر<EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> free_fn
* @param ctx {void*} free_fn <EFBFBD>IJ<EFBFBD><EFBFBD><EFBFBD>֮һ
*/
void conn_cache_push_stream(CONN_CACHE *cache, ACL_ASTREAM *stream,
int timeout, void (*free_fn)(ACL_ASTREAM*, void*), void *ctx);
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧij<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD>
* @param cache {CONN_CAHCE*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param key {const char*} <EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD>192.168.0.1:80
* @return {CONN*} <EFBFBD><EFBFBD><EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD>Ϊ NULL <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
CONN *conn_cache_get_conn(CONN_CACHE *cache, const char *key);
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧij<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param cache {CONN_CAHCE*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param key {const char*} <EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD>192.168.0.1:80
* @param ctx_pptr {void**} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǿգ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return {ACL_ASTREAM*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
ACL_ASTREAM *conn_cache_get_stream(CONN_CACHE *cache, const char *key, void **ctx_pptr);
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧij<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param cache {CONN_CAHCE*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param key {const char*} <EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD>192.168.0.1:80
*/
void conn_cache_delete_key(CONN_CACHE *cache, const char *key);
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҹر<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param conn {CONN*} <EFBFBD><EFBFBD><EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD>
*/
void conn_cache_delete_conn(CONN *conn);
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҹر<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param cache {CONN_CAHCE*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param stream {ACL_ASTREAM*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
void conn_cache_delete_stream(CONN_CACHE *cache, ACL_ASTREAM *stream);
#ifdef __cplusplus
}
#endif
#endif