Some more clear

This commit is contained in:
Vysheng 2014-09-23 17:18:42 +04:00
parent c03d91a574
commit df06d0858b
5 changed files with 21 additions and 9 deletions

View File

@ -967,6 +967,7 @@ extern char *downloads_directory;
extern char *config_directory;
extern char *binlog_file_name;
extern char *lua_file;
extern struct event *term_ev;
void do_clear (int arg_num, struct arg args[], struct in_ev *ev) {
tgl_free_all ();
@ -980,6 +981,9 @@ void do_clear (int arg_num, struct arg args[], struct in_ev *ev) {
free (config_directory);
free (binlog_file_name);
free (lua_file);
clear_history ();
event_free (term_ev);
event_base_free (tgl_state.ev_base);
do_halt (0);
}

18
loop.c
View File

@ -153,28 +153,28 @@ static void stdin_read_callback_line (evutil_socket_t fd, short what, void *arg)
stdin_read_callback_all (2, what, arg);
}
struct event *term_ev = 0;
void net_loop (int flags, int (*is_end)(void)) {
delete_stdin_event = 0;
if (verbosity >= E_DEBUG) {
logprintf ("Starting netloop\n");
}
struct event *ev = 0;
if (flags & 3) {
if (flags & 1) {
ev = event_new (tgl_state.ev_base, 0, EV_READ | EV_PERSIST, stdin_read_callback_char, 0);
term_ev = event_new (tgl_state.ev_base, 0, EV_READ | EV_PERSIST, stdin_read_callback_char, 0);
} else {
ev = event_new (tgl_state.ev_base, 0, EV_READ | EV_PERSIST, stdin_read_callback_line, 0);
term_ev = event_new (tgl_state.ev_base, 0, EV_READ | EV_PERSIST, stdin_read_callback_line, 0);
}
event_add (ev, 0);
event_add (term_ev, 0);
}
int last_get_state = time (0);
while (!is_end || !is_end ()) {
event_base_loop (tgl_state.ev_base, EVLOOP_ONCE);
if (ev && delete_stdin_event) {
event_free (ev);
ev = 0;
if (term_ev && delete_stdin_event) {
event_free (term_ev);
term_ev = 0;
}
#ifdef USE_LUA
@ -202,8 +202,8 @@ void net_loop (int flags, int (*is_end)(void)) {
}
}
if (ev) {
event_free (ev);
if (term_ev) {
event_free (term_ev);
}
if (verbosity >= E_DEBUG) {

View File

@ -1443,3 +1443,7 @@ void tgls_free_dc (struct tgl_dc *DC) {
if (DC->ev) { event_free (DC->ev); }
tfree (DC, sizeof (*DC));
}
void tgls_free_pubkey (void) {
RSA_free (pubKey);
}

View File

@ -56,4 +56,5 @@ void tgln_insert_msg_id (struct tgl_session *S, long long id);
void tglmp_on_start (void);
void tgl_dc_authorize (struct tgl_dc *DC);
void tgls_free_dc (struct tgl_dc *DC);
void tgls_free_pubkey (void);
#endif

View File

@ -30,6 +30,7 @@
#include "tree.h"
#include "loop.h"
#include <openssl/aes.h>
#include <openssl/bn.h>
#include <openssl/sha.h>
#include "queries.h"
#include "binlog.h"
@ -1882,6 +1883,8 @@ void tgl_free_all (void) {
for (i = 0; i <= tgl_state.max_dc_num; i++) if (tgl_state.DC_list[i]) {
tgls_free_dc (tgl_state.DC_list[i]);
}
BN_CTX_free (tgl_state.BN_ctx);
tgls_free_pubkey ();
}
int tgl_print_stat (char *s, int len) {