OCT 更正进程退出时资源清理逻辑
This commit is contained in:
parent
c072c8bc08
commit
7f6a59f562
srcs
|
@ -41,12 +41,12 @@ static struct sockaddr_in listen_address;
|
|||
|
||||
uv_loop_t *uv_loop;
|
||||
void *routes;
|
||||
//hw_string* http_v1_0;
|
||||
hw_string* http_v1_0;
|
||||
hw_string *http_v1_1;
|
||||
hw_string *server_name;
|
||||
int listener_count;
|
||||
uv_async_t *listener_async_handles;
|
||||
//uv_loop_t* listener_event_loops;
|
||||
uv_loop_t* listener_event_loops;
|
||||
uv_barrier_t *listeners_created_barrier;
|
||||
|
||||
int hw_init_with_config(configuration *c) {
|
||||
|
@ -132,7 +132,7 @@ void hw_http_add_route(char *route, http_request_callback callback, void *user_d
|
|||
routes = kh_init(string_hashmap);
|
||||
}
|
||||
set_route(routes, route, route_entry);
|
||||
dzlog_debug("Added route %s\n", route);// TODO: Replace with logging instead.
|
||||
dzlog_debug("Added route path: [%s]\n", route);// TODO: Replace with logging instead.
|
||||
}
|
||||
|
||||
void free_http_server() {
|
||||
|
@ -145,6 +145,8 @@ void free_http_server() {
|
|||
free((char *)v);
|
||||
});
|
||||
kh_destroy(string_hashmap, routes);
|
||||
|
||||
dzlog_debug("HTTP Server Close http://%s:%d\n", config->http_listen_address, config->http_listen_port);
|
||||
}
|
||||
|
||||
int hw_http_open() {
|
||||
|
@ -216,7 +218,7 @@ int hw_http_open() {
|
|||
|
||||
uv_listen((uv_stream_t *)&server, (int)config->listen_backlog, http_stream_on_connect);
|
||||
print_configuration();
|
||||
dzlog_debug("Listening...\n");
|
||||
dzlog_debug("HTTP Server Listening at http://%s:%d\n", config->http_listen_address, config->http_listen_port);
|
||||
//uv_run(uv_loop, UV_RUN_DEFAULT);
|
||||
} else if (listener_count > 0 && strcmp(config->balancer, "ipc") == 0) {
|
||||
int i;
|
||||
|
|
|
@ -26,7 +26,8 @@ static pid_t g_pid;
|
|||
|
||||
static void catch_system_interupt(int UNUSED(sig_num)) {
|
||||
if (g_pid == uv_os_getpid()) {
|
||||
printf("\nSystem close, clearing system resources..........\n");
|
||||
printf("\n");
|
||||
dzlog_warn("System close, clearing system resources..........\n\n");
|
||||
task_manager_exit();
|
||||
sleep(1);
|
||||
}
|
||||
|
@ -124,7 +125,8 @@ int user_init(const char *pAppCfgFile, const char *pCfgDirectory, const char *pK
|
|||
void user_uninit() {
|
||||
task_manager_exit();
|
||||
free_http_server();
|
||||
zlog_fini();
|
||||
uv_sleep(1000);
|
||||
mq_uninit();
|
||||
zlog_fini();
|
||||
uv_loop_close(get_task_manager());
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
//
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <zlog.h>
|
||||
#include "task_manager.h"
|
||||
#include "misc.h"
|
||||
#include "uthash/utlist.h"
|
||||
|
@ -36,7 +37,7 @@ int is_system_cleanup() {
|
|||
}
|
||||
|
||||
static int is_task_exit() {
|
||||
return (g_taskManagerExit == TRUE);
|
||||
return g_taskManagerExit;
|
||||
}
|
||||
|
||||
int task_add_exit_event_handler(system_exit_cb cb, void *userdata) {
|
||||
|
@ -83,7 +84,6 @@ void task_manager_run() {
|
|||
free(pCtx);
|
||||
}
|
||||
|
||||
dzlog_info("Main task exited..............\n");
|
||||
g_isSystemExit = TRUE;
|
||||
|
||||
printf("main task exit..............\n");
|
||||
}
|
|
@ -586,11 +586,9 @@ void on_system_exit(void *p) {
|
|||
|
||||
close(cfig.fixedSocket);
|
||||
|
||||
sprintf(logBuff, "Open DHCP Server Stopped !\n");
|
||||
sprintf(logBuff, "Open DHCP Server Stopped !");
|
||||
logDHCPMess(logBuff, 1);
|
||||
sleep(1);
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -81,7 +81,6 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
|
||||
user_uninit();
|
||||
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue