pespin has uploaded this change for review.
stream: Support overwriting tx_queue_max_length per srv conn
This allows setting different tx_queue_max_length per server connection.
This is useful where known clients (eg. matching specific addresses) may
have totally different link properties among them towards the server.
Related: SYS#7693
Change-Id: Ibc68612bd8dee4f9b8031ce2c3f5c7ff6bb639e3
---
M TODO-RELEASE
M include/osmocom/netif/stream.h
M src/stream_srv.c
3 files changed, 23 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/34/41434/1
diff --git a/TODO-RELEASE b/TODO-RELEASE
index 6340cdf..87e1b95 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -9,3 +9,4 @@
#library what description / commit summary line
stream add OSMO_STREAM_{CLI,SRV,SRV_LINK}_TCP_SOCKOPT_KEEP*, osmo_stream_srv_set_param()
stream add OSMO_STREAM_{CLI,SRV,SRV_LINK}_TCP_SOCKOPT_USER_TIMEOUT
+stream add osmo_stream_srv_set_tx_queue_max_length()
diff --git a/include/osmocom/netif/stream.h b/include/osmocom/netif/stream.h
index 8c3fad5..b04ebb9 100644
--- a/include/osmocom/netif/stream.h
+++ b/include/osmocom/netif/stream.h
@@ -137,6 +137,7 @@
void osmo_stream_srv_set_read_cb(struct osmo_stream_srv *conn, osmo_stream_srv_read_cb2_t read_cb);
void osmo_stream_srv_set_closed_cb(struct osmo_stream_srv *conn, osmo_stream_srv_closed_cb_t close_cb);
void *osmo_stream_srv_get_data(struct osmo_stream_srv *conn);
+int osmo_stream_srv_set_tx_queue_max_length(struct osmo_stream_srv *conn, unsigned int size);
struct osmo_stream_srv_link *osmo_stream_srv_get_master(struct osmo_stream_srv *conn);
const char *osmo_stream_srv_get_sockname(const struct osmo_stream_srv *conn);
struct osmo_fd *osmo_stream_srv_get_ofd(struct osmo_stream_srv *srv);
diff --git a/src/stream_srv.c b/src/stream_srv.c
index cc32dc7..695a46f 100644
--- a/src/stream_srv.c
+++ b/src/stream_srv.c
@@ -743,6 +743,7 @@
};
struct llist_head tx_queue; /* osmo_ofd mode (only): Queue of msgbs */
unsigned int tx_queue_count; /* osmo_ofd mode (only): Current amount of msgbs queued */
+ unsigned int tx_queue_max_length; /* Max amount of msgbs which can be enqueued */
osmo_stream_srv_closed_cb_t closed_cb;
osmo_stream_srv_read_cb_t read_cb;
osmo_stream_srv_read_cb2_t iofd_read_cb;
@@ -996,6 +997,8 @@
osmo_sock_get_name_buf(conn->sockname, sizeof(conn->sockname), fd);
+ conn->tx_queue_max_length = conn->srv->tx_queue_max_length;
+
if (osmo_fd_register(&conn->ofd) < 0) {
LOGSSRV(conn, LOGL_ERROR, "could not register FD\n");
talloc_free(conn);
@@ -1049,7 +1052,8 @@
return NULL;
}
- osmo_iofd_set_txqueue_max_length(conn->iofd, conn->srv->tx_queue_max_length);
+ conn->tx_queue_max_length = conn->srv->tx_queue_max_length;
+ osmo_iofd_set_txqueue_max_length(conn->iofd, conn->tx_queue_max_length);
if (conn->srv->msgb_alloc.set_by_user)
osmo_iofd_set_alloc_info(conn->iofd, conn->srv->msgb_alloc.size, conn->srv->msgb_alloc.headroom);
@@ -1233,6 +1237,21 @@
return conn->data;
}
+/*! Set the maximum length queue of the stream server connection.
+ * \param[in] conn Stream Server to modify
+ * \param[in] size maximum amount of msgbs which can be queued in the internal tx queue.
+ * \returns 0 on success, negative on error.
+ *
+ * The default queue size of a osmo_stream_srv is inherited during creation time from
+ * osmo_stream_srv_link. */
+int osmo_stream_srv_set_tx_queue_max_length(struct osmo_stream_srv *conn, unsigned int size)
+{
+ conn->tx_queue_max_length = size;
+ if (conn->mode == OSMO_STREAM_MODE_OSMO_IO && conn->iofd)
+ osmo_iofd_set_txqueue_max_length(conn->iofd, conn->tx_queue_max_length);
+ return 0;
+}
+
/*! Retrieve the stream server socket description.
* The returned name is stored in a static buffer; it is hence not re-entrant or thread-safe!
* \param[in] conn Stream Server to examine
@@ -1341,7 +1360,7 @@
switch (conn->mode) {
case OSMO_STREAM_MODE_OSMO_FD:
- if (conn->tx_queue_count >= conn->srv->tx_queue_max_length) {
+ if (conn->tx_queue_count >= conn->tx_queue_max_length) {
LOGSSRV(conn, LOGL_ERROR, "send: tx queue full, dropping msg!\n");
msgb_free(msg);
return;
To view, visit change 41434. To unsubscribe, or for help writing mail filters, visit settings.