pespin has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmo-netif/+/41857?usp=email )


Change subject: stream_cli: Add stream sockname to iofd name
......................................................................

stream_cli: Add stream sockname to iofd name

Change-Id: If6f42afefdc61f3ce8c3387c22ac6867c21cb87b
---
M src/stream_cli.c
1 file changed, 23 insertions(+), 4 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/57/41857/1

diff --git a/src/stream_cli.c b/src/stream_cli.c
index befa3e1..b098e4a 100644
--- a/src/stream_cli.c
+++ b/src/stream_cli.c
@@ -411,6 +411,26 @@
 #endif
 }

+/* Update cli->sockname based on socket info: */
+static void stream_cli_update_iofd_name(struct osmo_stream_cli *cli)
+{
+       if (!(cli->mode == OSMO_STREAM_MODE_OSMO_IO && cli->iofd))
+               return;
+
+       char *tmp = talloc_asprintf(cli, "%s,%s", cli->name, cli->sockname);
+       osmo_iofd_set_name(cli->iofd, tmp);
+       talloc_free(tmp);
+}
+
+/* Update cli->sockname based on socket info: */
+static void stream_cli_update_sockname(struct osmo_stream_cli *cli)
+{
+       osmo_sock_get_name_buf(cli->sockname, sizeof(cli->sockname), 
osmo_stream_cli_get_fd(cli));
+       /* Update stream iofd with the new cli->sockname too: */
+       stream_cli_update_iofd_name(cli);
+
+}
+
 /* returns true if cli is freed */
 static bool stream_cli_handle_connecting(struct osmo_stream_cli *cli, int res)
 {
@@ -435,8 +455,7 @@
        if (cli->mode == OSMO_STREAM_MODE_OSMO_FD && 
llist_empty(&cli->tx_queue))
                osmo_fd_write_disable(&cli->ofd);

-       /* Update sockname based on socket info: */
-       osmo_sock_get_name_buf(cli->sockname, sizeof(cli->sockname), 
osmo_stream_cli_get_fd(cli));
+       stream_cli_update_sockname(cli);

        LOGSCLI(cli, LOGL_INFO, "connection established\n");
        cli->state = STREAM_CLI_STATE_CONNECTED;
@@ -691,8 +710,8 @@
                talloc_free((void *)cli->name);
        cli->name = name;

-       if (cli->mode == OSMO_STREAM_MODE_OSMO_IO && cli->iofd)
-               osmo_iofd_set_name(cli->iofd, cli->name);
+       /* Update stream iofd with the new cli->name too: */
+       stream_cli_update_iofd_name(cli);
 }

 /*! Retrieve name previously set on the cli object (see 
osmo_stream_cli_set_name()).

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

Gerrit-MessageType: newchange
Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Change-Id: If6f42afefdc61f3ce8c3387c22ac6867c21cb87b
Gerrit-Change-Number: 41857
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <[email protected]>

Reply via email to