laforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/36192?usp=email )
Change subject: osmo_io: avoid OSMO_ASSERT one each API call
......................................................................
osmo_io: avoid OSMO_ASSERT one each API call
There's only one way to set the osmo_iofd_ops, which is by environment
variable during the constructor time at shared library load time.
There's hence no point in doing OSMO_ASSERT() on each and every call to
osmo_iofd_notify_connected() at runtime. We can move those kind of
asserts to the one-time load-time constructor instead.
At the same time, we can extend those asserts to all the mandatory
call-backs to be provided by the backend.
Change-Id: Id9005ac6bb260236c88670373816bf7ee6a627f1
---
M src/core/osmo_io.c
1 file changed, 26 insertions(+), 2 deletions(-)
Approvals:
pespin: Looks good to me, but someone else must approve
jolly: Looks good to me, but someone else must approve
laforge: Looks good to me, approved
Jenkins Builder: Verified
diff --git a/src/core/osmo_io.c b/src/core/osmo_io.c
index 8b53aa6..d52d601 100644
--- a/src/core/osmo_io.c
+++ b/src/core/osmo_io.c
@@ -105,6 +105,13 @@
exit(1);
}
+ OSMO_ASSERT(osmo_iofd_ops.close);
+ OSMO_ASSERT(osmo_iofd_ops.write_enable);
+ OSMO_ASSERT(osmo_iofd_ops.write_disable);
+ OSMO_ASSERT(osmo_iofd_ops.read_enable);
+ OSMO_ASSERT(osmo_iofd_ops.read_disable);
+ OSMO_ASSERT(osmo_iofd_ops.notify_connected);
+
osmo_iofd_init();
}
@@ -787,7 +794,6 @@
iofd->pending = NULL;
- OSMO_ASSERT(osmo_iofd_ops.close);
rc = osmo_iofd_ops.close(iofd);
iofd->fd = -1;
return rc;
@@ -927,7 +933,6 @@
{
OSMO_ASSERT(iofd->mode == OSMO_IO_FD_MODE_READ_WRITE ||
iofd->mode == OSMO_IO_FD_MODE_RECVMSG_SENDMSG);
- OSMO_ASSERT(osmo_iofd_ops.notify_connected);
osmo_iofd_ops.notify_connected(iofd);
}
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/36192?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Id9005ac6bb260236c88670373816bf7ee6a627f1
Gerrit-Change-Number: 36192
Gerrit-PatchSet: 2
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: jolly <andreas(a)eversberg.eu>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: merged
laforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/36193?usp=email )
Change subject: osmo_io: Avoid implementing non-existant situations
......................................................................
osmo_io: Avoid implementing non-existant situations
Both of our back-ends have a register_fd and unregister_fd back-end.
Let's simplify the code by not treating them as optional, which
introduces code paths that we never take, adds small runtime overhead
and makes the code harder to follow.
Should we ever introduce more backends which might not need those
call-backs, we can either have empty functions or think about how to
make them optional.
Change-Id: I0077151eb676f61320b3fa2124448852aa8fd4a9
---
M src/core/osmo_io.c
1 file changed, 23 insertions(+), 7 deletions(-)
Approvals:
pespin: Looks good to me, but someone else must approve
Jenkins Builder: Verified
jolly: Looks good to me, but someone else must approve
laforge: Looks good to me, approved
diff --git a/src/core/osmo_io.c b/src/core/osmo_io.c
index d52d601..57eba6c 100644
--- a/src/core/osmo_io.c
+++ b/src/core/osmo_io.c
@@ -106,6 +106,8 @@
}
OSMO_ASSERT(osmo_iofd_ops.close);
+ OSMO_ASSERT(osmo_iofd_ops.register_fd);
+ OSMO_ASSERT(osmo_iofd_ops.unregister_fd);
OSMO_ASSERT(osmo_iofd_ops.write_enable);
OSMO_ASSERT(osmo_iofd_ops.write_disable);
OSMO_ASSERT(osmo_iofd_ops.read_enable);
@@ -695,8 +697,7 @@
return -EBADF;
}
- if (osmo_iofd_ops.register_fd)
- rc = osmo_iofd_ops.register_fd(iofd);
+ rc = osmo_iofd_ops.register_fd(iofd);
if (rc)
return rc;
@@ -720,11 +721,7 @@
*/
int osmo_iofd_unregister(struct osmo_io_fd *iofd)
{
- if (osmo_iofd_ops.unregister_fd)
- return osmo_iofd_ops.unregister_fd(iofd);
- IOFD_FLAG_SET(iofd, IOFD_FLAG_CLOSED);
-
- return 0;
+ return osmo_iofd_ops.unregister_fd(iofd);
}
/*! Get the number of messages in the tx queue.
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/36193?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I0077151eb676f61320b3fa2124448852aa8fd4a9
Gerrit-Change-Number: 36193
Gerrit-PatchSet: 2
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: jolly <andreas(a)eversberg.eu>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: merged
Attention is currently required from: daniel.
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/36192?usp=email )
Change subject: osmo_io: avoid OSMO_ASSERT one each API call
......................................................................
Patch Set 2: Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/36192?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Id9005ac6bb260236c88670373816bf7ee6a627f1
Gerrit-Change-Number: 36192
Gerrit-PatchSet: 2
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: jolly <andreas(a)eversberg.eu>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: daniel <dwillmann(a)sysmocom.de>
Gerrit-Comment-Date: Thu, 07 Mar 2024 16:39:24 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: daniel.
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/36191?usp=email )
Change subject: osmo_io: Don't pretend to support backends without close_cb
......................................................................
Patch Set 2: Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/36191?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Id285f1d7b73ae5805aa618897016ae8b73bf892d
Gerrit-Change-Number: 36191
Gerrit-PatchSet: 2
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: jolly <andreas(a)eversberg.eu>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: daniel <dwillmann(a)sysmocom.de>
Gerrit-Comment-Date: Thu, 07 Mar 2024 16:39:20 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-hnbgw/+/36203?usp=email )
Change subject: osmo_hnbgw_main: Install our usual SIGUSR1/SIGUSR2/SIGABRT handlers
......................................................................
osmo_hnbgw_main: Install our usual SIGUSR1/SIGUSR2/SIGABRT handlers
I just wanted to get a talloc report from osmo-hnbgw by sending SIGUSR1
and the process terminated. Clearly not the desired behaviour...
Change-Id: I1209a2fadacf62afd5027480426285f527249788
---
M src/osmo-hnbgw/osmo_hnbgw_main.c
1 file changed, 45 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-hnbgw refs/changes/03/36203/1
diff --git a/src/osmo-hnbgw/osmo_hnbgw_main.c b/src/osmo-hnbgw/osmo_hnbgw_main.c
index d371914..377ee47 100644
--- a/src/osmo-hnbgw/osmo_hnbgw_main.c
+++ b/src/osmo-hnbgw/osmo_hnbgw_main.c
@@ -1,6 +1,6 @@
/* OsmoHNBGW main routine */
-/* (C) 2015 by Harald Welte <laforge(a)gnumonks.org>
+/* (C) 2015-2024 by Harald Welte <laforge(a)gnumonks.org>
* (C) 2016-2023 by sysmocom s.f.m.c. GmbH <info(a)sysmocom.de>
* All Rights Reserved
*
@@ -19,6 +19,7 @@
*
*/
+#include <signal.h>
#include <getopt.h>
#include "config.h"
@@ -64,6 +65,32 @@
NULL,
};
+static void signal_handler(int signum)
+{
+ fprintf(stdout, "signal %u received\n", signum);
+
+ switch (signum) {
+ case SIGABRT:
+ /* in case of abort, we want to obtain a talloc report and
+ * then run default SIGABRT handler, who will generate coredump
+ * and abort the process. abort() should do this for us after we
+ * return, but program wouldn't exit if an external SIGABRT is
+ * received.
+ */
+ talloc_report(tall_vty_ctx, stderr);
+ talloc_report_full(g_hnbgw, stderr);
+ signal(SIGABRT, SIG_DFL);
+ raise(SIGABRT);
+ break;
+ case SIGUSR1:
+ talloc_report(tall_vty_ctx, stderr);
+ talloc_report_full(g_hnbgw, stderr);
+ break;
+ default:
+ break;
+ }
+}
+
static void print_usage(void)
{
printf("Usage: osmo-hnbgw\n");
@@ -313,6 +340,11 @@
}
}
+ signal(SIGABRT, &signal_handler);
+ signal(SIGUSR1, &signal_handler);
+ signal(SIGUSR2, &signal_handler);
+ osmo_init_ignore_signals();
+
while (1) {
rc = osmo_select_main_ctx(0);
if (rc < 0)
--
To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/36203?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-hnbgw
Gerrit-Branch: master
Gerrit-Change-Id: I1209a2fadacf62afd5027480426285f527249788
Gerrit-Change-Number: 36203
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: newchange