diff options
author | Stefan Sperling <ssperling@sysmocom.de> | 2018-02-22 17:17:04 +0100 |
---|---|---|
committer | Stefan Sperling <ssperling@sysmocom.de> | 2018-02-22 17:17:04 +0100 |
commit | ca5ac9a5ef8bf78e62767eca103ffb62200109bc (patch) | |
tree | 847a38486e4afa12098015748977ee38069360f0 | |
parent | 2cbaf4139ae768ff5a79c79d389045b4ef4dd0e6 (diff) |
add a txflush callback to osmo_stream_srv_send()stsp/destroy_conn_with_txflush_callback
Define a txlush() callback which can be set on a connection and
which will be invoked whenever the tx queue is empty upon entry
to osmo_stream_srv_send().
Change-Id: I4c63584af69f9a1ee5622a709756916bfef474ee
-rw-r--r-- | include/osmocom/netif/stream.h | 1 | ||||
-rw-r--r-- | src/stream.c | 12 |
2 files changed, 13 insertions, 0 deletions
diff --git a/include/osmocom/netif/stream.h b/include/osmocom/netif/stream.h index 4e1beb6..27a1be2 100644 --- a/include/osmocom/netif/stream.h +++ b/include/osmocom/netif/stream.h @@ -41,6 +41,7 @@ struct osmo_stream_srv_link *osmo_stream_srv_get_master(struct osmo_stream_srv * struct osmo_fd *osmo_stream_srv_get_ofd(struct osmo_stream_srv *srv); void osmo_stream_srv_destroy(struct osmo_stream_srv *conn); +void osmo_stream_srv_set_txflushed_cb(struct osmo_stream_srv *conn, void (*txflushed_cb)(struct osmo_stream_srv *conn, void *data)); void osmo_stream_srv_set_data(struct osmo_stream_srv *conn, void *data); void osmo_stream_srv_send(struct osmo_stream_srv *conn, struct msgb *msg); diff --git a/src/stream.c b/src/stream.c index 8a1be38..1cd1a85 100644 --- a/src/stream.c +++ b/src/stream.c @@ -778,6 +778,7 @@ struct osmo_stream_srv { struct llist_head tx_queue; int (*closed_cb)(struct osmo_stream_srv *peer); int (*cb)(struct osmo_stream_srv *peer); + void (*txflushed_cb)(struct osmo_stream_srv *conn, void *data); void *data; }; @@ -804,6 +805,8 @@ static void osmo_stream_srv_write(struct osmo_stream_srv *conn) if (llist_empty(&conn->tx_queue)) { conn->ofd.when &= ~BSC_FD_WRITE; + if (conn->txflushed_cb) + conn->txflushed_cb(conn, conn->data); return; } lh = conn->tx_queue.next; @@ -880,6 +883,15 @@ osmo_stream_srv_create(void *ctx, struct osmo_stream_srv_link *link, return conn; } +/*! \brief Set a callback which will be called once the stream's TX queue has been flushed. + * \param[in] conn Stream Server to set the callback on + * \param[in] data User-specific data (available in call-back functions) */ +void +osmo_stream_srv_set_txflushed_cb(struct osmo_stream_srv *conn, void (*txflushed_cb)(struct osmo_stream_srv *conn, void *data)) +{ + conn->txflushed_cb = txflushed_cb; +} + /*! \brief Set application private data of the stream server * \param[in] conn Stream Server to modify * \param[in] data User-specific data (available in call-back functions) */ |