laforge has submitted this change. (
https://gerrit.osmocom.org/c/libosmocore/+/36190?usp=email )
Change subject: osmo_io: Log error message in case call-backs incompatible with mode
......................................................................
osmo_io: Log error message in case call-backs incompatible with mode
Change-Id: I50ba6a76c0144f249d67488874a6c4edf01ec6f2
---
M include/osmocom/core/osmo_io.h
M src/core/libosmocore.map
M src/core/osmo_io.c
3 files changed, 29 insertions(+), 2 deletions(-)
Approvals:
Jenkins Builder: Verified
jolly: Looks good to me, but someone else must approve
pespin: Looks good to me, approved
diff --git a/include/osmocom/core/osmo_io.h b/include/osmocom/core/osmo_io.h
index 8a7e53a..8e613fa 100644
--- a/include/osmocom/core/osmo_io.h
+++ b/include/osmocom/core/osmo_io.h
@@ -36,6 +36,10 @@
static inline const char *osmo_io_backend_name(enum osmo_io_backend val)
{ return get_value_string(osmo_io_backend_names, val); }
+extern const struct value_string osmo_iofd_mode_names[];
+static inline const char *osmo_iofd_mode_name(enum osmo_io_fd_mode val)
+{ return get_value_string(osmo_iofd_mode_names, val); }
+
struct osmo_io_ops {
/* mode OSMO_IO_FD_MODE_READ_WRITE: */
struct {
diff --git a/src/core/libosmocore.map b/src/core/libosmocore.map
index 72a6038..072efee 100644
--- a/src/core/libosmocore.map
+++ b/src/core/libosmocore.map
@@ -264,6 +264,7 @@
osmo_iofd_set_name;
osmo_iofd_get_priv_nr;
osmo_iofd_init;
+osmo_iofd_mode_names;
osmo_iofd_ops;
osmo_iofd_register;
osmo_iofd_sendto_msgb;
diff --git a/src/core/osmo_io.c b/src/core/osmo_io.c
index f0d213c..bcd4add 100644
--- a/src/core/osmo_io.c
+++ b/src/core/osmo_io.c
@@ -51,6 +51,13 @@
{ 0, NULL }
};
+const struct value_string osmo_iofd_mode_names[] = {
+ { OSMO_IO_FD_MODE_READ_WRITE, "read/write" },
+ { OSMO_IO_FD_MODE_RECVFROM_SENDTO, "recvfrom/sendto" },
+ { OSMO_IO_FD_MODE_RECVMSG_SENDMSG, "recvmsg/sendmsg" },
+ { 0, NULL }
+};
+
static enum osmo_io_backend g_io_backend;
/* Used by some tests, can't be static */
@@ -619,8 +626,11 @@
return NULL;
}
- if (ioops && !check_mode_callback_compat(mode, ioops))
+ if (ioops && !check_mode_callback_compat(mode, ioops)) {
+ LOGP(DLIO, LOGL_ERROR, "iofd(%s): rejecting call-backs incompatible with mode
%s\n",
+ name ? name : "unknown", osmo_iofd_mode_name(mode));
return NULL;
+ }
iofd = talloc_zero(ctx, struct osmo_io_fd);
if (!iofd)
@@ -868,8 +878,11 @@
* \param[in] ioops osmo_io_ops structure to be set */
int osmo_iofd_set_ioops(struct osmo_io_fd *iofd, const struct osmo_io_ops *ioops)
{
- if (!check_mode_callback_compat(iofd->mode, ioops))
+ if (!check_mode_callback_compat(iofd->mode, ioops)) {
+ LOGPIO(iofd, LOGL_ERROR, "rejecting call-backs incompatible with mode %s\n",
+ osmo_iofd_mode_name(iofd->mode));
return -EINVAL;
+ }
iofd->io_ops = *ioops;
--
To view, visit
https://gerrit.osmocom.org/c/libosmocore/+/36190?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: I50ba6a76c0144f249d67488874a6c4edf01ec6f2
Gerrit-Change-Number: 36190
Gerrit-PatchSet: 3
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