[PATCH] osmo-trx[master]: Depend on libosmocore and enable talloc reports

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Tue Feb 20 19:07:43 UTC 2018


Review at  https://gerrit.osmocom.org/6618

Depend on libosmocore and enable talloc reports

Change-Id: If345c89293fcd7d1ad4f17214eea339951f25a5d
---
M Transceiver52M/Makefile.am
M Transceiver52M/osmo-trx.cpp
M configure.ac
3 files changed, 39 insertions(+), 14 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/18/6618/1

diff --git a/Transceiver52M/Makefile.am b/Transceiver52M/Makefile.am
index f36f4d4..21104dc 100644
--- a/Transceiver52M/Makefile.am
+++ b/Transceiver52M/Makefile.am
@@ -22,7 +22,7 @@
 include $(top_srcdir)/Makefile.common
 
 AM_CPPFLAGS = -Wall $(STD_DEFINES_AND_INCLUDES) -I${srcdir}/common
-AM_CXXFLAGS = -lpthread
+AM_CXXFLAGS = -lpthread $(LIBOSMOCORE_CFLAGS)
 
 SUBDIRS = arm x86
 
@@ -92,7 +92,8 @@
 	$(ARCH_LA) \
 	$(GSM_LA) \
 	$(COMMON_LA) \
-	$(FFTWF_LIBS)
+	$(FFTWF_LIBS) \
+	$(LIBOSMOCORE_LIBS)
 
 if USRP1
 libtransceiver_la_SOURCES += USRPDevice.cpp
diff --git a/Transceiver52M/osmo-trx.cpp b/Transceiver52M/osmo-trx.cpp
index 16866f4..40269e1 100644
--- a/Transceiver52M/osmo-trx.cpp
+++ b/Transceiver52M/osmo-trx.cpp
@@ -37,6 +37,9 @@
 #include <Logger.h>
 
 extern "C" {
+#include <osmocom/core/talloc.h>
+#include <osmocom/core/application.h>
+#include <osmocom/core/msgb.h>
 #include "convolve.h"
 #include "convert.h"
 }
@@ -88,6 +91,8 @@
 };
 
 volatile bool gshutdown = false;
+
+static void *tall_trx_ctx;
 
 /* Setup configuration values
  *     Don't query the existence of the Log.Level because it's a
@@ -240,20 +245,35 @@
 
 static void sig_handler(int signo)
 {
-	fprintf(stdout, "Received shutdown signal");
-	gshutdown = true;
+	fprintf(stdout, "signal %d received\n", signo);
+	switch (signo) {
+	case SIGINT:
+	case SIGTERM:
+		fprintf(stdout, "SIGINT received, shutting down\n");
+		gshutdown = true;
+		break;
+	case SIGABRT:
+	case SIGUSR1:
+		talloc_report(tall_trx_ctx, stderr);
+		talloc_report_full(tall_trx_ctx, stderr);
+		break;
+	case SIGUSR2:
+		talloc_report_full(tall_trx_ctx, stderr);
+		break;
+	default:
+		break;
+	}
 }
 
 static void setup_signal_handlers()
 {
-	if (signal(SIGINT, sig_handler) == SIG_ERR) {
-		fprintf(stderr, "Failed to install SIGINT signal handler\n");
-		exit(EXIT_FAILURE);
-	}
-	if (signal(SIGTERM, sig_handler) == SIG_ERR) {
-		fprintf(stderr, "Couldn't install SIGTERM signal handler\n");
-		exit( EXIT_FAILURE);
-	}
+	/* Handle keyboard interrupt SIGINT */
+	signal(SIGINT, &sig_handler);
+	signal(SIGTERM, &sig_handler);
+	signal(SIGABRT, &sig_handler);
+	signal(SIGUSR1, &sig_handler);
+	signal(SIGUSR2, &sig_handler);
+	osmo_init_ignore_signals();
 }
 
 
@@ -478,6 +498,10 @@
 	RadioDevice::InterfaceType iface = RadioDevice::NORMAL;
 	struct trx_config config;
 
+	tall_trx_ctx = talloc_named_const(NULL, 0, "OsmoTRX");
+	msgb_talloc_ctx_init(tall_trx_ctx, 0);
+	setup_signal_handlers();
+
 #ifdef HAVE_SSE3
 	printf("Info: SSE3 support compiled in");
 #ifdef HAVE___BUILTIN_CPU_SUPPORTS
@@ -511,8 +535,6 @@
 		if (set_sched_rr(config.sched_rr) < 0)
 			return EXIT_FAILURE;
 	}
-
-	setup_signal_handlers();
 
 	/* Check database sanity */
 	if (!trx_setup_config(&config)) {
diff --git a/configure.ac b/configure.ac
index 5c034e5..cba4a0c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -73,6 +73,8 @@
 AC_HEADER_TIME
 AC_C_BIGENDIAN
 
+PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 0.10.0)
+
 AC_ARG_WITH(usrp1, [
     AS_HELP_STRING([--with-usrp1],
         [enable USRP1 gnuradio based transceiver])

-- 
To view, visit https://gerrit.osmocom.org/6618
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If345c89293fcd7d1ad4f17214eea339951f25a5d
Gerrit-PatchSet: 1
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list