Skip to content
Snippets Groups Projects
Commit be2f801e authored by armatusmiles's avatar armatusmiles
Browse files

[+] dap_http_simple_module_deinit

parent c2dbb288
No related branches found
No related tags found
No related merge requests found
...@@ -73,24 +73,30 @@ user_agents_item_t *user_agents_list = NULL; ...@@ -73,24 +73,30 @@ user_agents_item_t *user_agents_list = NULL;
static struct ev_loop* http_simple_loop; static struct ev_loop* http_simple_loop;
static ev_async async_watcher_http_simple; static ev_async async_watcher_http_simple;
static pthread_mutex_t mutex_on_queue_http_response = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t mutex_on_queue_http_response = PTHREAD_MUTEX_INITIALIZER;
static pthread_t http_simple_loop_thread;
// uint64_t s_TTL_session_key=3600; // uint64_t s_TTL_session_key=3600;
int dap_http_simple_module_init() int dap_http_simple_module_init()
{ {
pthread_mutex_init(&mutex_on_queue_http_response, NULL);
http_simple_loop = ev_loop_new(0); http_simple_loop = ev_loop_new(0);
TAILQ_INIT(&tailq_head); TAILQ_INIT(&tailq_head);
pthread_t thread;
ev_async_init(&async_watcher_http_simple, async_control_proc); ev_async_init(&async_watcher_http_simple, async_control_proc);
ev_async_start(http_simple_loop, &async_watcher_http_simple); ev_async_start(http_simple_loop, &async_watcher_http_simple);
pthread_create(&thread, NULL, loop_http_simple_proc, NULL); pthread_create(&http_simple_loop_thread, NULL, loop_http_simple_proc, NULL);
return 0; return 0;
} }
void dap_http_simple_module_deinit(void)
{
ev_async_stop(http_simple_loop, &async_watcher_http_simple);
pthread_mutex_destroy(&mutex_on_queue_http_response);
pthread_join(http_simple_loop_thread, NULL);
ev_loop_destroy(http_simple_loop);
}
static void async_control_proc (EV_P_ ev_async *w, int revents) static void async_control_proc (EV_P_ ev_async *w, int revents)
{ {
......
#include "dap_http_simple_test.h" #include "dap_http_simple_test.h"
#include "dap_http_simple.c" #include "dap_http_simple.c"
static void test_init_deinit() static void test_user_agent_support()
{ {
dap_http_simple_set_supported_user_agents("DapVpn/2.2", "SecondVpn/3.3", NULL); dap_http_simple_set_supported_user_agents("DapVpn/2.2", "SecondVpn/3.3", NULL);
...@@ -28,8 +28,15 @@ static void test_init_deinit() ...@@ -28,8 +28,15 @@ static void test_init_deinit()
_free_user_agents_list(); _free_user_agents_list();
} }
void dap_http_simple_test_init_deinit()
{
dap_http_simple_module_init();
dap_http_simple_module_deinit();
}
void dap_http_http_simple_test_run() void dap_http_http_simple_test_run()
{ {
dap_print_module_name("dap_http_http_simple_test"); dap_print_module_name("dap_http_http_simple_test");
test_init_deinit(); test_user_agent_support();
dap_http_simple_test_init_deinit();
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment