diff options
author | Harald Welte <laforge@osmocom.org> | 2024-03-07 10:39:05 +0100 |
---|---|---|
committer | Harald Welte <laforge@osmocom.org> | 2024-03-07 15:51:50 +0100 |
commit | 257e7898c5d40039731712fc7a4948476701be64 (patch) | |
tree | bb66930e7cce68ca7880068f810d197a6581444f /src | |
parent | e1d48582775749eee599194fe4ef3d4a2492a68e (diff) |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/core/osmo_io.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/core/osmo_io.c b/src/core/osmo_io.c index 8b53aa68..d52d6012 100644 --- a/src/core/osmo_io.c +++ b/src/core/osmo_io.c @@ -105,6 +105,13 @@ static __attribute__((constructor(103))) void on_dso_load_osmo_io(void) 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 @@ int osmo_iofd_close(struct osmo_io_fd *iofd) iofd->pending = NULL; - OSMO_ASSERT(osmo_iofd_ops.close); rc = osmo_iofd_ops.close(iofd); iofd->fd = -1; return rc; @@ -927,7 +933,6 @@ void osmo_iofd_notify_connected(struct osmo_io_fd *iofd) { 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); } |