From 29b9cf844686b84c5f19ee9b6d62fe921d68f3fc Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Mon, 30 Nov 2009 19:43:54 +0100 Subject: make use of new S_GLOBAL_SHUTDOWN signal to properly close pcap_fd This avoids broken pcap files with partial packets due to non-flushed buffers. --- openbsc/src/e1_input.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'openbsc/src/e1_input.c') diff --git a/openbsc/src/e1_input.c b/openbsc/src/e1_input.c index e46533838..15495fbbb 100644 --- a/openbsc/src/e1_input.c +++ b/openbsc/src/e1_input.c @@ -52,6 +52,7 @@ #include #include #include +#include #include #define NUM_E1_TS 32 @@ -523,8 +524,24 @@ int e1inp_line_update(struct e1inp_line *line) return mi_e1_line_update(line); } +static int e1i_sig_cb(unsigned int subsys, unsigned int signal, + void *handler_data, void *signal_data) +{ + if (subsys != SS_GLOBAL || + signal != S_GLOBAL_SHUTDOWN) + return 0; + + if (pcap_fd) { + close(pcap_fd); + pcap_fd = -1; + } + + return 0; +} + static __attribute__((constructor)) void on_dso_load_e1_inp(void) { tall_sigl_ctx = talloc_named_const(tall_bsc_ctx, 1, "e1inp_sign_link"); + register_signal_handler(SS_GLOBAL, e1i_sig_cb, NULL); } -- cgit v1.2.3