Close #72 修正在HTTP-REQ/RESP-BEGIN事件执行detach动作时段错误。

This commit is contained in:
Lu Qiuwen
2018-11-07 14:14:03 +08:00
parent 2d02343b50
commit 571f7cd12e
5 changed files with 24 additions and 13 deletions

View File

@@ -490,7 +490,9 @@ struct http_frame_plugin_status
unsigned int preempt_by; unsigned int preempt_by;
}; };
struct http_frame_session_ctx * http_frame_raise_session_begin(const tfe_stream * stream, struct http_frame_session_ctx * http_frame_alloc();
int http_frame_raise_session_begin(struct http_frame_session_ctx * ht_frame, const tfe_stream * stream,
struct tfe_http_session * ht_session, unsigned int thread_id); struct tfe_http_session * ht_session, unsigned int thread_id);
void http_frame_raise_session_end(struct http_frame_session_ctx * ht_frame, const tfe_stream * stream, void http_frame_raise_session_end(struct http_frame_session_ctx * ht_frame, const tfe_stream * stream,

View File

@@ -30,6 +30,7 @@
#define likely(expr) __builtin_expect((expr), 1) #define likely(expr) __builtin_expect((expr), 1)
#define unlikely(expr) __builtin_expect((expr), 0) #define unlikely(expr) __builtin_expect((expr), 0)
extern void * g_default_logger;
#define TFE_LOG_ERROR(handler, fmt, ...) \ #define TFE_LOG_ERROR(handler, fmt, ...) \
do { fprintf(stderr, fmt "\n" , ##__VA_ARGS__); \ do { fprintf(stderr, fmt "\n" , ##__VA_ARGS__); \
MESA_handle_runtime_log(handler, RLOG_LV_FATAL, "tfe", fmt, ##__VA_ARGS__); } while(0) MESA_handle_runtime_log(handler, RLOG_LV_FATAL, "tfe", fmt, ##__VA_ARGS__); } while(0)

View File

@@ -134,13 +134,17 @@ struct http_frame_plugin_status * http_frame_current_plugin_status(struct http_f
return ht_frame->calling_plugin_status; return ht_frame->calling_plugin_status;
} }
struct http_frame_session_ctx * http_frame_raise_session_begin(const struct tfe_stream * stream, struct http_frame_session_ctx * http_frame_alloc()
struct tfe_http_session * ht_session, unsigned int thread_id)
{ {
struct http_frame_session_ctx * ht_frame = ALLOC(struct http_frame_session_ctx, 1); struct http_frame_session_ctx * ht_frame = ALLOC(struct http_frame_session_ctx, 1);
ht_frame->nr_plugin_status = tfe_plugin_total_counts(); ht_frame->nr_plugin_status = tfe_plugin_total_counts();
ht_frame->plugin_status = ALLOC(struct http_frame_plugin_status, ht_frame->nr_plugin_status); ht_frame->plugin_status = ALLOC(struct http_frame_plugin_status, ht_frame->nr_plugin_status);
return ht_frame;
}
int http_frame_raise_session_begin(struct http_frame_session_ctx * ht_frame,
const struct tfe_stream * stream, struct tfe_http_session * ht_session, unsigned int thread_id)
{
unsigned int __for_each_iterator = 0; unsigned int __for_each_iterator = 0;
unsigned int __plugin_id = 0; unsigned int __plugin_id = 0;
@@ -161,7 +165,7 @@ struct http_frame_session_ctx * http_frame_raise_session_begin(const struct tfe_
/* Clear calling ctx */ /* Clear calling ctx */
ht_frame->calling_plugin = NULL; ht_frame->calling_plugin = NULL;
ht_frame->calling_plugin_status = NULL; ht_frame->calling_plugin_status = NULL;
return ht_frame; return 0;
}; };
void http_frame_raise_session_end(struct http_frame_session_ctx * ht_frame, const tfe_stream * stream, void http_frame_raise_session_end(struct http_frame_session_ctx * ht_frame, const tfe_stream * stream,

View File

@@ -95,8 +95,7 @@ struct ssl_trusted_cert_storage
static X509_STORE* _X509_store_create(const char* pem_bundle, const char* pem_dir) static X509_STORE* _X509_store_create(const char* pem_bundle, const char* pem_dir)
{ {
int ret=0, n=0, i=0; int ret=0, n=0, i=0;
struct dirent **namelist;
X509_STORE* store=X509_STORE_new(); X509_STORE* store=X509_STORE_new();
char path[TFE_STRING_MAX]={0}; char path[TFE_STRING_MAX]={0};
if (store == NULL) if (store == NULL)
@@ -120,7 +119,12 @@ static X509_STORE* _X509_store_create(const char* pem_bundle, const char* pem_di
X509_STORE_set1_param(store, param); X509_STORE_set1_param(store, param);
X509_VERIFY_PARAM_free(param); X509_VERIFY_PARAM_free(param);
struct dirent **namelist = NULL;
n=tfe_scandir(pem_dir, &namelist, NULL, (int (*)(const void*, const void*))alphasort); n=tfe_scandir(pem_dir, &namelist, NULL, (int (*)(const void*, const void*))alphasort);
if(n < 0)
{
return store;
}
for(i=0;i<n;i++) for(i=0;i<n;i++)
{ {
@@ -133,12 +137,15 @@ static X509_STORE* _X509_store_create(const char* pem_bundle, const char* pem_di
{ {
_X509_add_cert_or_crl_add(store, SSL_X509_OBJ_CRL, path); _X509_add_cert_or_crl_add(store, SSL_X509_OBJ_CRL, path);
} }
TFE_LOG_INFO(g_default_logger, "Found X509 additive trust CA: %s", path);
free(namelist[i]); free(namelist[i]);
} }
free(namelist);
free(namelist);
return store; return store;
} }
static MESA_htable_handle _create_mesa_htable(void) static MESA_htable_handle _create_mesa_htable(void)
{ {
int ret=0; int ret=0;

View File

@@ -298,13 +298,10 @@ static int __on_request_prepare_context(const struct tfe_stream * stream, unsign
hf_private_set_callback(hf_private_req_in, __user_event_dispatch, __closure, free); hf_private_set_callback(hf_private_req_in, __user_event_dispatch, __closure, free);
/* Call business plugin */ /* Call business plugin */
hs_private->ht_frame = http_frame_raise_session_begin(stream, &hs_private->hs_public, thread_id); hs_private->ht_frame = http_frame_alloc();
if (hs_private->ht_frame == NULL) assert(hs_private->ht_frame != NULL);
{
TFE_STREAM_LOG_ERROR(stream, "Failed at raising session begin event. ");
return -1;
}
http_frame_raise_session_begin(hs_private->ht_frame, stream, &hs_private->hs_public, thread_id);
TAILQ_INSERT_TAIL(&hc_private->hs_private_list, hs_private, next); TAILQ_INSERT_TAIL(&hc_private->hs_private_list, hs_private, next);
} }