osmo_io: Remove osmo_iofd_read/write_enable/disable
This API is not really used or needed, so remove it.
See discussion in https://gerrit.osmocom.org/c/libosmocore/+/33084
Change-Id: I0dbc14a8cbbdc7b6e4688942c0dac865bbd72c8b
diff --git a/src/core/osmo_io.c b/src/core/osmo_io.c
index 9960fb4..d260da4 100644
--- a/src/core/osmo_io.c
+++ b/src/core/osmo_io.c
@@ -170,7 +170,7 @@
llist_add_tail(&msghdr->list, &iofd->tx_queue.msg_queue);
iofd->tx_queue.current_length++;
- if (iofd->write_enabled && iofd->tx_queue.current_length == 1)
+ if (iofd->tx_queue.current_length == 1)
osmo_iofd_ops.write_enable(iofd);
return 0;
@@ -368,46 +368,6 @@
return 0;
}
-/*! Enable reading from this iofd
- *
- * \param[in] iofd the file descriptor
- */
-void osmo_iofd_read_enable(struct osmo_io_fd *iofd)
-{
- iofd->read_enabled = true;
- osmo_iofd_ops.read_enable(iofd);
-}
-
-/*! Disable reading from this iofd
- *
- * \param[in] iofd the file descriptor
- */
-void osmo_iofd_read_disable(struct osmo_io_fd *iofd)
-{
- iofd->read_enabled = false;
- osmo_iofd_ops.read_disable(iofd);
-}
-
-/*! Enable writing to this iofd
- *
- * \param[in] iofd the file descriptor
- */
-void osmo_iofd_write_enable(struct osmo_io_fd *iofd)
-{
- iofd->write_enabled = true;
- osmo_iofd_ops.write_enable(iofd);
-}
-
-/*! Disable writing to this iofd
- *
- * \param[in] iofd the file descriptor
- */
-void osmo_iofd_write_disable(struct osmo_io_fd *iofd)
-{
- iofd->write_enabled = false;
- osmo_iofd_ops.write_disable(iofd);
-}
-
/*! Allocate and setup a new iofd
* \param[in] ctx the parent context from which to allocate
* \param[in] fd the underlying system file descriptor
@@ -454,14 +414,19 @@
*/
int osmo_iofd_register(struct osmo_io_fd *iofd, int fd)
{
+ int rc = 0;
+
if (fd >= 0)
iofd->fd = fd;
iofd->closed = false;
if (osmo_iofd_ops.register_fd)
- return osmo_iofd_ops.register_fd(iofd);
+ rc = osmo_iofd_ops.register_fd(iofd);
- return 0;
+ osmo_iofd_ops.read_enable(iofd);
+ osmo_iofd_ops.write_enable(iofd);
+
+ return rc;
}
/*! Unregister the fd from the underlying backend
diff --git a/src/core/osmo_io_internal.h b/src/core/osmo_io_internal.h
index 7fc4b6b..bdd2ac5 100644
--- a/src/core/osmo_io_internal.h
+++ b/src/core/osmo_io_internal.h
@@ -38,13 +38,11 @@
enum osmo_io_fd_mode mode;
/*! flags to guard closing/freeing of iofd */
+ /* TODO: Move to bitfield */
bool closed;
bool in_callback;
bool to_free;
- bool write_enabled;
- bool read_enabled;
-
/*! human-readable name to associte with fd */
const char *name;
diff --git a/src/gb/gprs_ns2_udp.c b/src/gb/gprs_ns2_udp.c
index 0fc1b4b..f24eae6 100644
--- a/src/gb/gprs_ns2_udp.c
+++ b/src/gb/gprs_ns2_udp.c
@@ -337,9 +337,6 @@
osmo_iofd_register(priv->iofd, rc);
osmo_iofd_set_alloc_info(priv->iofd, 4096, 128);
- osmo_iofd_read_enable(priv->iofd);
- osmo_iofd_write_enable(priv->iofd);
-
/* IPv4: max fragmented payload can be (13 bit) * 8 byte => 65535.
* IPv6: max payload can be 65535 (RFC 2460).
* UDP header = 8 byte */