增加获取evbase、线程数、标准HTTP field设置的工具函数
This commit is contained in:
@@ -158,11 +158,11 @@ enum tfe_http_std_field
|
|||||||
TFE_HTTP_EXPIRES,
|
TFE_HTTP_EXPIRES,
|
||||||
TFE_HTTP_ACCEPT_ENCODING,
|
TFE_HTTP_ACCEPT_ENCODING,
|
||||||
TFE_HTTP_CACHE_CONTROL,
|
TFE_HTTP_CACHE_CONTROL,
|
||||||
TLF_HTTP_IF_MATCH,
|
TFE_HTTP_IF_MATCH,
|
||||||
TLF_HTTP_IF_NONE_MATCH,
|
TFE_HTTP_IF_NONE_MATCH,
|
||||||
TLF_HTTP_IF_MODIFIED_SINCE,
|
TFE_HTTP_IF_MODIFIED_SINCE,
|
||||||
TLF_HTTP_IF_UNMODIFIED_SINCE,
|
TFE_HTTP_IF_UNMODIFIED_SINCE,
|
||||||
TLF_HTTP_LAST_MODIFIED
|
TFE_HTTP_LAST_MODIFIED
|
||||||
};
|
};
|
||||||
|
|
||||||
enum http_ev_bit_number
|
enum http_ev_bit_number
|
||||||
@@ -303,6 +303,13 @@ static inline const char * tfe_http_field_read(const struct tfe_http_half * half
|
|||||||
{
|
{
|
||||||
return half->ops->ops_http_field_read(half, name);
|
return half->ops->ops_http_field_read(half, name);
|
||||||
}
|
}
|
||||||
|
static inline const char * tfe_http_std_field_read(struct tfe_http_half * half, enum tfe_http_std_field field_id)
|
||||||
|
{
|
||||||
|
struct http_field_name tmp_name;
|
||||||
|
tmp_name.field_id=field_id;
|
||||||
|
tmp_name.field_name=NULL;
|
||||||
|
return tfe_http_field_read(half, &tmp_name);
|
||||||
|
}
|
||||||
|
|
||||||
static inline int tfe_http_field_write(struct tfe_http_half * half,
|
static inline int tfe_http_field_write(struct tfe_http_half * half,
|
||||||
const struct http_field_name * name, const char * value)
|
const struct http_field_name * name, const char * value)
|
||||||
@@ -376,6 +383,18 @@ static inline struct tfe_http_half * tfe_http_session_response_create(struct tfe
|
|||||||
{
|
{
|
||||||
return session->ops->ops_response_create(session, resp_code);
|
return session->ops->ops_response_create(session, resp_code);
|
||||||
}
|
}
|
||||||
|
static inline int tfe_http_in_request(enum tfe_http_event events)
|
||||||
|
{
|
||||||
|
if ((events & EV_HTTP_REQ_HDR) | (events & EV_HTTP_REQ_BODY_BEGIN) | (events & EV_HTTP_REQ_BODY_END)
|
||||||
|
| (events & EV_HTTP_REQ_BODY_CONT))
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//@flag EV_HTTP_RESP_BODY_END, EV_HTTP_RESP_BODY_FULL,
|
//@flag EV_HTTP_RESP_BODY_END, EV_HTTP_RESP_BODY_FULL,
|
||||||
|
|||||||
@@ -4,3 +4,6 @@ struct tfe_proxy;
|
|||||||
|
|
||||||
const char * tfe_proxy_default_conffile();
|
const char * tfe_proxy_default_conffile();
|
||||||
const char * tfe_proxy_default_logger();
|
const char * tfe_proxy_default_logger();
|
||||||
|
unsigned int tfe_proxy_get_thread_count();
|
||||||
|
struct event_base * tfe_proxy_get_evbase(unsigned int thread_id);
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,6 @@ struct tfe_thread_ctx
|
|||||||
struct event_base * evbase;
|
struct event_base * evbase;
|
||||||
unsigned char running;
|
unsigned char running;
|
||||||
|
|
||||||
struct cert_mgr * cert_mgr;
|
|
||||||
|
|
||||||
unsigned int nr_modules;
|
unsigned int nr_modules;
|
||||||
const struct tfe_plugin * modules;
|
const struct tfe_plugin * modules;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -221,7 +221,7 @@ int tfe_proxy_config(struct tfe_proxy * proxy, const char * profile)
|
|||||||
MESA_load_profile_uint_def(profile, "main", "nr_worker_threads", &proxy->nr_work_threads, 1);
|
MESA_load_profile_uint_def(profile, "main", "nr_worker_threads", &proxy->nr_work_threads, 1);
|
||||||
/* Debug */
|
/* Debug */
|
||||||
MESA_load_profile_uint_def(profile, "debug", "passthrough_all_tcp", &proxy->tcp_all_passthrough, 0);
|
MESA_load_profile_uint_def(profile, "debug", "passthrough_all_tcp", &proxy->tcp_all_passthrough, 0);
|
||||||
/* TCP options, -1 means unset, we should not call setsockopt */
|
/* TCP options, -1 means unset, we shall not call setsockopt */
|
||||||
MESA_load_profile_int_def(profile, "tcp", "sz_rcv_buffer", &proxy->tcp_options.sz_rcv_buffer, -1);
|
MESA_load_profile_int_def(profile, "tcp", "sz_rcv_buffer", &proxy->tcp_options.sz_rcv_buffer, -1);
|
||||||
MESA_load_profile_int_def(profile, "tcp", "sz_snd_buffer", &proxy->tcp_options.sz_snd_buffer, -1);
|
MESA_load_profile_int_def(profile, "tcp", "sz_snd_buffer", &proxy->tcp_options.sz_snd_buffer, -1);
|
||||||
MESA_load_profile_int_def(profile, "tcp", "so_keepalive", &proxy->tcp_options.so_keepalive, -1);
|
MESA_load_profile_int_def(profile, "tcp", "so_keepalive", &proxy->tcp_options.so_keepalive, -1);
|
||||||
@@ -276,6 +276,8 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
|
|
||||||
future_promise_library_init();
|
future_promise_library_init();
|
||||||
|
tango_cache_global_init();
|
||||||
|
|
||||||
/* PROXY INSTANCE */
|
/* PROXY INSTANCE */
|
||||||
g_default_proxy = ALLOC(struct tfe_proxy, 1);
|
g_default_proxy = ALLOC(struct tfe_proxy, 1);
|
||||||
assert(g_default_proxy);
|
assert(g_default_proxy);
|
||||||
@@ -339,3 +341,14 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
unsigned int tfe_proxy_get_thread_count(void)
|
||||||
|
{
|
||||||
|
return g_default_proxy->nr_work_threads;
|
||||||
|
}
|
||||||
|
struct event_base * tfe_proxy_get_evbase(unsigned int thread_id)
|
||||||
|
{
|
||||||
|
assert(thread_id<g_default_proxy->nr_work_threads);
|
||||||
|
return g_default_proxy->work_threads[thread_id].evbase;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user