diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2020-07-10 22:45:12 +0200 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2020-07-10 22:45:12 +0200 |
commit | e1debd9198982e574240f3e84ff54ecadd186d86 (patch) | |
tree | 20ba41cc98081132fab252c0788cd82c5a207606 /nDPId.c | |
parent | d1739d97a8e01ebae3a93855d6ce13d280093ad1 (diff) |
fixed some race conditions
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'nDPId.c')
-rw-r--r-- | nDPId.c | 18 |
1 files changed, 16 insertions, 2 deletions
@@ -1589,6 +1589,8 @@ static void * processing_thread(void * const ndpi_thread_arg) struct nDPId_reader_thread * const reader_thread = (struct nDPId_reader_thread *)ndpi_thread_arg; #ifndef DISABLE_JSONIZER + reader_thread->json_sockfd = -1; + reader_thread->json_sock_reconnect = 1; if (connect_to_json_socket(reader_thread) != 0) { syslog(LOG_DAEMON | LOG_ERR, @@ -1709,13 +1711,24 @@ static int stop_reader_threads(void) { syslog(LOG_DAEMON | LOG_ERR, "pthread_join: %s\n", strerror(errno)); } - - free_workflow(&reader_threads[i].workflow); } return 0; } +static void free_reader_threads(void) +{ + for (int i = 0; i < reader_thread_count; ++i) + { + if (reader_threads[i].workflow == NULL) + { + continue; + } + + free_workflow(&reader_threads[i].workflow); + } +} + static void sighandler(int signum) { syslog(LOG_DAEMON | LOG_NOTICE, "Received SIGNAL %d\n", signum); @@ -1814,6 +1827,7 @@ int main(int argc, char ** argv) fprintf(stderr, "%s: stop_reader_threads\n", argv[0]); return 1; } + free_reader_threads(); closelog(); |