diff options
| author | luqiuwen <[email protected]> | 2018-12-14 03:06:34 +0600 |
|---|---|---|
| committer | luqiuwen <[email protected]> | 2018-12-14 03:06:34 +0600 |
| commit | 8713da2d810c9b93520c0966a893d156eddda3a0 (patch) | |
| tree | bcbe684fba3a0b04d868289425c5a15276999938 /platform/src/proxy.cpp | |
| parent | 8c93f7203d7c2d4a6d3b7809249273cf555d4e22 (diff) | |
修正Http-kill位置过完的问题,增加TCP链接摘要日志功能
Diffstat (limited to 'platform/src/proxy.cpp')
| -rw-r--r-- | platform/src/proxy.cpp | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/platform/src/proxy.cpp b/platform/src/proxy.cpp index c5beda0..2ba022f 100644 --- a/platform/src/proxy.cpp +++ b/platform/src/proxy.cpp @@ -79,17 +79,19 @@ struct tfe_thread_ctx * tfe_proxy_thread_ctx_acquire(struct tfe_proxy * ctx) for (unsigned int tid = 0; tid < ctx->nr_work_threads; tid++) { struct tfe_thread_ctx * thread_ctx = ctx->work_threads[tid]; - min_thread_id = min_load > thread_ctx->load ? tid : min_thread_id; - min_load = min_load > thread_ctx->load ? thread_ctx->load : min_load; + unsigned int thread_load = ATOMIC_READ(&thread_ctx->load); + + min_thread_id = min_load > thread_load ? tid : min_thread_id; + min_load = min_load > thread_load ? thread_load : min_load; } - ctx->work_threads[min_thread_id]->load++; + ATOMIC_INC(&ctx->work_threads[min_thread_id]->load); return ctx->work_threads[min_thread_id]; } void tfe_proxy_thread_ctx_release(struct tfe_thread_ctx * thread_ctx) { - thread_ctx->load--; + ATOMIC_DEC(&thread_ctx->load); } int tfe_proxy_fds_accept(struct tfe_proxy * ctx, const struct tfe_proxy_accept_para * para) @@ -274,18 +276,20 @@ int tfe_proxy_config(struct tfe_proxy * proxy, const char * profile) static const char * __str_stat_spec_map[] = { [STAT_SIGPIPE] = "SIGPIPE", - [STAT_FD_OPEN_BY_KNI_ACCEPT] = "FdOpenKNI", - [STAT_FD_CLOSE_BY_KNI_ACCEPT_FAIL] = "FdCloseKNI", - [STAT_FD_CLOSE_BY_EVENT_WRITE] = "FdCloseUser", - [STAT_FD_CLOSE_BY_EVENT_EOF] = "FdCloseEOF", - [STAT_FD_CLOSE_BY_EVENT_ERROR] = "FdCloseError", - [STAT_FD_INSTANT_CLOSE] = "FdCloseInstant", - [STAT_FD_DEFER_CLOSE_IN_QUEUE] = "FdCloseDeferInQ", - [STAT_FD_DEFER_CLOSE_SUCCESS] = "FdCloseDeferSuc", - [STAT_STREAM_CREATE] = "StreamCreate", - [STAT_STREAM_DESTROY] = "StreamDestroy", - [STAT_STREAM_TCP_PLAIN] = "StreamTCPPlain", - [STAT_STREAM_TCP_SSL] = "StreamTCPSSL", + [STAT_FD_OPEN_BY_KNI_ACCEPT] = "FdRcv", + [STAT_FD_CLOSE_BY_KNI_ACCEPT_FAIL] = "FdRcvFail", + [STAT_FD_INSTANT_CLOSE] = "FdClsInstant", + [STAT_FD_DEFER_CLOSE_IN_QUEUE] = "FdClsDefInQ", + [STAT_FD_DEFER_CLOSE_SUCCESS] = "FdClsDefSuc", + [STAT_STREAM_OPEN] = "StrOpen", + [STAT_STREAM_CLS] = "StrCls", + [STAT_STREAM_CLS_DOWN_EOF] = "StrDownEOF", + [STAT_STREAM_CLS_UP_EOF] = "StrUpEOF", + [STAT_STREAM_CLS_DOWN_ERR] = "StrDownErr", + [STAT_STREAM_CLS_UP_ERR] = "StrUpErr", + [STAT_STREAM_CLS_KILL] = "StrKill", + [STAT_STREAM_TCP_PLAIN] = "Plain", + [STAT_STREAM_TCP_SSL] = "SSL", [TFE_STAT_MAX] = NULL }; @@ -334,6 +338,10 @@ int main(int argc, char * argv[]) { const char * main_profile = "./conf/tfe/tfe.conf"; const char * future_profile= "./conf/tfe/future.conf"; + + /* adds locking, only required if accessed from separate threads */ + evthread_use_pthreads(); + unsigned int __log_level = RLOG_LV_INFO; MESA_load_profile_uint_def(main_profile, "log", "level", &__log_level, RLOG_LV_INFO); @@ -364,9 +372,6 @@ int main(int argc, char * argv[]) /* LOGGER */ g_default_proxy->logger = g_default_logger; - /* adds locking, only required if accessed from separate threads */ - evthread_use_pthreads(); - /* MAIN THREAD EVBASE */ g_default_proxy->evbase = event_base_new(); CHECK_OR_EXIT(g_default_proxy->evbase, "Failed at creating evbase for main thread. Exit."); |
