pespin has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmo-netif/+/33343 )

Change subject: stream: Drop name param from recently added API 
osmo_stream_srv_create2()
......................................................................

stream: Drop name param from recently added API osmo_stream_srv_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_srv_set_name() API if needed (otherwise a dynamic name
based on socket is selected)

Change-Id: I5d677ef57b7db0aedd8c43282568c845097cb12b
---
M examples/ipa-stream-server.c
M examples/stream-server.c
M include/osmocom/netif/stream.h
M src/stream.c
4 files changed, 21 insertions(+), 9 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, approved




diff --git a/examples/ipa-stream-server.c b/examples/ipa-stream-server.c
index e490ff6..c72ed9a 100644
--- a/examples/ipa-stream-server.c
+++ b/examples/ipa-stream-server.c
@@ -75,12 +75,13 @@
                return -1;
        }

-       conn = osmo_stream_srv_create2(tall_test, "ipa_srv", srv, fd, NULL);
+       conn = osmo_stream_srv_create2(tall_test, srv, fd, NULL);
        if (conn == NULL) {
                LOGP(DSTREAMTEST, LOGL_ERROR,
                        "error while creating connection\n");
                return -1;
        }
+       osmo_stream_srv_set_name(conn, "ipa_srv");
        osmo_stream_srv_set_read_cb(conn, read_cb);
        osmo_stream_srv_set_closed_cb(conn, close_cb);

diff --git a/examples/stream-server.c b/examples/stream-server.c
index d7c2aff..8aa8b9b 100644
--- a/examples/stream-server.c
+++ b/examples/stream-server.c
@@ -69,12 +69,13 @@
                return -1;
        }

-       conn = osmo_stream_srv_create2(tall_test, "stream_server", srv, fd, 
NULL);
+       conn = osmo_stream_srv_create2(tall_test, srv, fd, NULL);
        if (conn == NULL) {
                LOGP(DSTREAMTEST, LOGL_ERROR,
                        "error while creating connection\n");
                return -1;
        }
+       osmo_stream_srv_set_name(conn, "stream_server");
        osmo_stream_srv_set_read_cb(conn, read_cb);
        osmo_stream_srv_set_closed_cb(conn, close_cb);

diff --git a/include/osmocom/netif/stream.h b/include/osmocom/netif/stream.h
index c56b9a6..057815b 100644
--- a/include/osmocom/netif/stream.h
+++ b/include/osmocom/netif/stream.h
@@ -46,7 +46,7 @@
 struct osmo_stream_srv;

 struct osmo_stream_srv *osmo_stream_srv_create(void *ctx, struct 
osmo_stream_srv_link *link, int fd, int (*read_cb)(struct osmo_stream_srv 
*conn), int (*closed_cb)(struct osmo_stream_srv *conn), void *data);
-struct osmo_stream_srv *osmo_stream_srv_create2(void *ctx, const char *name, 
struct osmo_stream_srv_link *link, int fd, void *data);
+struct osmo_stream_srv *osmo_stream_srv_create2(void *ctx, struct 
osmo_stream_srv_link *link, int fd, void *data);
 void osmo_stream_srv_set_name(struct osmo_stream_srv *conn, const char *name);
 void osmo_stream_srv_set_read_cb(struct osmo_stream_srv *conn, int 
(*read_cb)(struct osmo_stream_srv *conn, struct msgb *msg));
 void osmo_stream_srv_set_closed_cb(struct osmo_stream_srv *conn, int 
(*closed_cb)(struct osmo_stream_srv *conn));
diff --git a/src/stream.c b/src/stream.c
index 8771614..b646c3d 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -1703,14 +1703,12 @@

 /*! \brief Create a Stream Server inside the specified link
  *  \param[in] ctx talloc allocation context from which to allocate
- *  \param[in] name name of the connection
  *  \param[in] link Stream Server Link to which we belong
  *  \param[in] fd system file descriptor of the new connection
  *  \param[in] data User data to save in the new Stream Server struct
  *  \returns Stream Server in case of success; NULL on error */
 struct osmo_stream_srv *
-osmo_stream_srv_create2(void *ctx, const char *name,
-       struct osmo_stream_srv_link *link, int fd, void *data)
+osmo_stream_srv_create2(void *ctx, struct osmo_stream_srv_link *link, int fd, 
void *data)
 {
        struct osmo_stream_srv *conn;
 
@@ -1723,11 +1721,9 @@
        conn->mode = OSMO_STREAM_MODE_OSMO_IO;
        conn->srv = link;

-       if (name)
-               conn->name = talloc_strdup(conn, name);
        osmo_sock_get_name_buf(conn->sockname, sizeof(conn->sockname), fd);

-       conn->iofd = osmo_iofd_setup(conn, fd, conn->name ? : conn->sockname,
+       conn->iofd = osmo_iofd_setup(conn, fd, conn->sockname,
                                     OSMO_IO_FD_MODE_READ_WRITE, &srv_ioops, 
conn);
        if (!conn->iofd) {
                talloc_free(conn);

--
To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/33343
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Change-Id: I5d677ef57b7db0aedd8c43282568c845097cb12b
Gerrit-Change-Number: 33343
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <[email protected]>
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>
Gerrit-MessageType: merged

Reply via email to