Skip to content
Snippets Groups Projects
Commit 268d0cb2 authored by dmitriy.gerasimov's avatar dmitriy.gerasimov
Browse files

Merge branch 'features-3398' into 'master'

Features 3398

See merge request !24
parents d234e400 9c83a31e
No related branches found
No related tags found
1 merge request!24Features 3398
...@@ -21,9 +21,32 @@ static bool s_init_cs_dag_pos = false; ...@@ -21,9 +21,32 @@ static bool s_init_cs_dag_pos = false;
static bool s_init_chain_net_srv = false; static bool s_init_chain_net_srv = false;
static bool s_init_ks = false; static bool s_init_ks = false;
static bool submodules_deint;
PyObject* CellFrame_error = NULL; PyObject* CellFrame_error = NULL;
#ifdef _WIN32
BOOL WINAPI consoleHandler(DWORD dwType){
if (dwType == CTRL_C_EVENT){
log_it(L_NOTICE, "Handler Ctrl+C");
dap_server_loop_stop();
deinit_modules();
}
return TRUE;
}
#else
void sigfunc(int sig){
if (sig == SIGINT){
log_it(L_NOTICE, "Handler Ctrl+C");
dap_server_loop_stop();
deinit_modules();
}
}
#endif
PyObject *python_cellframe_init(PyObject *self, PyObject *args){ PyObject *python_cellframe_init(PyObject *self, PyObject *args){
const char *app_name; const char *app_name;
const char *file_name_log; const char *file_name_log;
...@@ -32,6 +55,13 @@ PyObject *python_cellframe_init(PyObject *self, PyObject *args){ ...@@ -32,6 +55,13 @@ PyObject *python_cellframe_init(PyObject *self, PyObject *args){
const char *JSON_str; const char *JSON_str;
s_init_ks = true; s_init_ks = true;
submodules_deint = false;
#ifdef _WIN32
setConsoleCtrlHandler((PHANDLER_ROUTINE)consoleHandler, TRUE);
#else
signal(SIGINT, sigfunc);
#endif
if (!PyArg_ParseTuple(args, "s", &JSON_str)){ if (!PyArg_ParseTuple(args, "s", &JSON_str)){
PyErr_SetString(CellFrame_error, "ERROR in function call signature: can't get one String argument"); PyErr_SetString(CellFrame_error, "ERROR in function call signature: can't get one String argument");
...@@ -461,36 +491,44 @@ PyMODINIT_FUNC PyInit_libCellFrame(void){ ...@@ -461,36 +491,44 @@ PyMODINIT_FUNC PyInit_libCellFrame(void){
return module; return module;
} }
PyObject *python_cellframe_deinit(PyObject *self, PyObject *args){ void deinit_modules(void){
if (s_init_crypto){ if (!submodules_deint){
dap_crypto_deinit(); log_it(L_NOTICE, "Start deint submodules");
dap_cert_deinit(); if (s_init_crypto){
} dap_crypto_deinit();
if (s_init_chain){ dap_cert_deinit();
deinit_chain_py(); }
dap_chain_cs_deinit_py(); if (s_init_chain){
} deinit_chain_py();
if (s_init_stream){ dap_chain_cs_deinit_py();
dap_stream_deinit(); }
} if (s_init_stream){
if (s_init_stream_ctl){ dap_stream_deinit();
dap_stream_ctl_deinit(); }
} if (s_init_stream_ctl){
if (s_init_http_folder){ dap_stream_ctl_deinit();
dap_http_folder_deinit(); }
} if (s_init_http_folder){
if (s_init_http){ dap_http_folder_deinit();
dap_http_deinit(); }
} if (s_init_http){
if (s_init_server_core){ dap_http_deinit();
dap_server_core_deinit(); }
} if (s_init_server_core){
if (s_init_ks){ dap_server_core_deinit();
dap_enc_ks_deinit(); }
if (s_init_ks){
dap_enc_ks_deinit();
}
dap_config_close(g_config);
dap_config_deinit();
dap_common_deinit();
submodules_deint = true;
} }
dap_config_close(g_config); }
dap_config_deinit();
dap_common_deinit(); PyObject *python_cellframe_deinit(PyObject *self, PyObject *args){
deinit_modules();
return PyLong_FromLong(0); return PyLong_FromLong(0);
} }
......
Subproject commit f94212973623702bff498780fc2d0426e595d5ec Subproject commit c833958ae5e623292aa1d54617548cb4a42f9525
...@@ -59,9 +59,21 @@ ...@@ -59,9 +59,21 @@
#include "wrapping_dap_chain_gdb.h" #include "wrapping_dap_chain_gdb.h"
#include "dap_common.h" #include "dap_common.h"
#include "dap_server.h"
#ifdef _WIN32
#include "Windows.h"
BOOL WINAPI consoleHandler(DWORD);
#else
#include "signal.h"
void sigfunc(int sig);
#endif
PyObject *python_cellframe_init(PyObject *self, PyObject *args); PyObject *python_cellframe_init(PyObject *self, PyObject *args);
void deinit_modules(void);
PyObject *python_cellframe_deinit(PyObject *self, PyObject *args); PyObject *python_cellframe_deinit(PyObject *self, PyObject *args);
static PyMethodDef CellFramePythonMethods[] = { static PyMethodDef CellFramePythonMethods[] = {
......
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