aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2009-11-30 19:43:54 +0100
committerHarald Welte <laforge@gnumonks.org>2009-12-01 17:58:32 +0530
commit29b9cf844686b84c5f19ee9b6d62fe921d68f3fc (patch)
treec306c878add1d0d73fe32349c5c1c3eae81753f9 /openbsc
parent3961fcc0313f1d87ab64806638e416f2603e7345 (diff)
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.
Diffstat (limited to 'openbsc')
-rw-r--r--openbsc/src/e1_input.c17
1 files changed, 17 insertions, 0 deletions
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 <openbsc/trau_frame.h>
#include <openbsc/trau_mux.h>
#include <openbsc/talloc.h>
+#include <openbsc/signal.h>
#include <openbsc/misdn.h>
#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);
}