diff --git a/common/utils/T/tracer/config.c b/common/utils/T/tracer/config.c index 98085956a2306e54bcd6560d737f679b61bc5070..f88966ed79a111b2ab2d09d7110ae9da0c3781ea 100644 --- a/common/utils/T/tracer/config.c +++ b/common/utils/T/tracer/config.c @@ -17,6 +17,13 @@ static char *PUT(char *to, int tosize, char c) return to; } +void clear_remote_config(void) +{ + free(remote); + remote = NULL; + remote_size = 0; +} + void append_received_config_chunk(char *buf, int length) { int buflen = *(int *)buf; diff --git a/common/utils/T/tracer/config.h b/common/utils/T/tracer/config.h index 5234b0f5372940b7191bb23687059fb2f497d98a..f90869eb6621f89c5be80fc012e4edc7102a4652 100644 --- a/common/utils/T/tracer/config.h +++ b/common/utils/T/tracer/config.h @@ -1,6 +1,7 @@ #ifndef _CONFIG_H_ #define _CONFIG_H_ +void clear_remote_config(void); void append_received_config_chunk(char *buf, int length); void load_config_file(char *filename); void verify_config(void); diff --git a/common/utils/T/tracer/enb.c b/common/utils/T/tracer/enb.c index 3f1e8647633003796e3e6a231d37df4f1b188f4a..a8c42328925d30c894a326cc5054ecd02623b8ef 100644 --- a/common/utils/T/tracer/enb.c +++ b/common/utils/T/tracer/enb.c @@ -1,6 +1,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <unistd.h> #include <pthread.h> #include <signal.h> #include "database.h" @@ -43,10 +44,16 @@ void is_on_changed(void *_d) if (socket_send(d->socket, &t, 1) == -1 || socket_send(d->socket, &d->nevents, sizeof(int)) == -1 || socket_send(d->socket, d->is_on, d->nevents * sizeof(int)) == -1) - abort(); + goto connection_dies; no_connection: if (pthread_mutex_unlock(&d->lock)) abort(); + return; + +connection_dies: + close(d->socket); + d->socket = -1; + if (pthread_mutex_unlock(&d->lock)) abort(); } void usage(void) @@ -380,6 +387,8 @@ int main(int n, char **v) if (pthread_mutex_init(&enb_data.lock, NULL)) abort(); setup_event_selector(g, database, is_on, is_on_changed, &enb_data); +restart: + clear_remote_config(); enb_data.socket = connect_to(ip, port); /* send the first message - activate selected traces */ @@ -390,7 +399,7 @@ int main(int n, char **v) char v[T_BUFFER_MAX]; event e; e = get_event(enb_data.socket, v, database); - if (e.type == -1) abort(); + if (e.type == -1) goto restart; handle_event(h, e); }