pespin has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-netif/+/33342 )
(
2 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: stream: Drop recently added API osmo_stream_cli_create2 ......................................................................
stream: Drop recently added API osmo_stream_cli_create2
It was later decided that since setting a name is not really required, it is best to leave it out of the create() function and let the user use the osmo_stream_cli_set_name() API if needed (otherwise a dynamic name based on socket is selected).
Change-Id: I2a2fad318ef22c2ac117f95588a078ca3beccea5 --- M examples/ipa-stream-client.c M examples/stream-client.c M include/osmocom/netif/stream.h M src/stream.c 4 files changed, 37 insertions(+), 35 deletions(-)
Approvals: daniel: Looks good to me, but someone else must approve laforge: Looks good to me, approved Jenkins Builder: Verified
diff --git a/examples/ipa-stream-client.c b/examples/ipa-stream-client.c index 91abfac..b66d93a 100644 --- a/examples/ipa-stream-client.c +++ b/examples/ipa-stream-client.c @@ -164,11 +164,12 @@ * initialize stream client. */
- conn = osmo_stream_cli_create2(tall_test, "ipa_test_client"); + conn = osmo_stream_cli_create(tall_test); if (conn == NULL) { fprintf(stderr, "cannot create client\n"); exit(EXIT_FAILURE); } + osmo_stream_cli_set_name(conn, "ipa_test_client"); osmo_stream_cli_set_addr(conn, "127.0.0.1"); osmo_stream_cli_set_port(conn, 10000); osmo_stream_cli_set_connect_cb(conn, connect_cb); diff --git a/examples/stream-client.c b/examples/stream-client.c index 350535d..6781c72 100644 --- a/examples/stream-client.c +++ b/examples/stream-client.c @@ -103,11 +103,12 @@ * initialize stream cli. */
- conn = osmo_stream_cli_create2(tall_test, "stream_client"); + conn = osmo_stream_cli_create(tall_test); if (conn == NULL) { fprintf(stderr, "cannot create cli\n"); exit(EXIT_FAILURE); } + osmo_stream_cli_set_name(conn, "stream_client"); osmo_stream_cli_set_addr(conn, "127.0.0.1"); osmo_stream_cli_set_port(conn, 10000); osmo_stream_cli_set_connect_cb(conn, connect_cb); diff --git a/include/osmocom/netif/stream.h b/include/osmocom/netif/stream.h index 11e9070..c56b9a6 100644 --- a/include/osmocom/netif/stream.h +++ b/include/osmocom/netif/stream.h @@ -90,7 +90,6 @@ bool osmo_stream_cli_is_connected(struct osmo_stream_cli *cli);
struct osmo_stream_cli *osmo_stream_cli_create(void *ctx); -struct osmo_stream_cli *osmo_stream_cli_create2(void *ctx, const char *name); void osmo_stream_cli_destroy(struct osmo_stream_cli *cli);
int osmo_stream_cli_open(struct osmo_stream_cli *cli); diff --git a/src/stream.c b/src/stream.c index a5a5bf1..8771614 100644 --- a/src/stream.c +++ b/src/stream.c @@ -576,7 +576,23 @@ */ struct osmo_stream_cli *osmo_stream_cli_create(void *ctx) { - return osmo_stream_cli_create2(ctx, ""); + struct osmo_stream_cli *cli; + + cli = talloc_zero(ctx, struct osmo_stream_cli); + if (!cli) + return NULL; + + cli->mode = OSMO_STREAM_MODE_UNKNOWN; + cli->sk_domain = AF_UNSPEC; + cli->sk_type = SOCK_STREAM; + cli->proto = IPPROTO_TCP; + + cli->state = STREAM_CLI_STATE_CLOSED; + osmo_timer_setup(&cli->timer, cli_timer_cb, cli); + cli->reconnect_timeout = 5; /* default is 5 seconds. */ + INIT_LLIST_HEAD(&cli->tx_queue); + + return cli; }
static void stream_cli_iofd_read_cb(struct osmo_io_fd *iofd, int res, struct msgb *msg) @@ -624,35 +640,6 @@ .segmentation_cb = NULL, };
-/*! \brief Create an Osmocom stream client - * \param[in] ctx talloc context from which to allocate memory - * This function allocates a new \ref osmo_stream_cli and initializes - * it with default values (5s reconnect timer, TCP protocol) - * \param[in] name a description of the stream client. Will be used in logging - * \return allocated stream client, or NULL in case of error - */ -struct osmo_stream_cli *osmo_stream_cli_create2(void *ctx, const char *name) -{ - struct osmo_stream_cli *cli; - - cli = talloc_zero(ctx, struct osmo_stream_cli); - if (!cli) - return NULL; - - cli->name = talloc_strdup(cli, name); - cli->mode = OSMO_STREAM_MODE_UNKNOWN; - cli->sk_domain = AF_UNSPEC; - cli->sk_type = SOCK_STREAM; - cli->proto = IPPROTO_TCP; - - cli->state = STREAM_CLI_STATE_CLOSED; - osmo_timer_setup(&cli->timer, cli_timer_cb, cli); - cli->reconnect_timeout = 5; /* default is 5 seconds. */ - INIT_LLIST_HEAD(&cli->tx_queue); - - return cli; -} - /*! \brief Set a name on the cli object (used during logging) * \param[in] cli stream_cli whose name is to be set * \param[in] name the name to be set on cli @@ -875,7 +862,7 @@ }
/*! \brief Set the call-back function called to read from the stream client socket - * Only for osmo_stream_cli created with osmo_stream_cli_create() + * This function will configure osmo_stream_cli to use osmo_ofd internally. * \param[in] cli Stream Client to modify * \param[in] read_cb Call-back function to be called when we want to read */ void @@ -888,7 +875,7 @@ }
/*! \brief Set the call-back function called to read from the stream client socket - * Only use this function for osmo_stream_cli created with osmo_stream_cli_create2() + * This function will configure osmo_stream_cli to use osmo_iofd internally. * \param[in] cli Stream Client to modify * \param[in] read_cb Call-back function to be called when data was read from the socket */ void