diff options
author | Andreas Eversberg <jolly@eversberg.eu> | 2024-02-15 14:12:01 +0100 |
---|---|---|
committer | Andreas Eversberg <jolly@eversberg.eu> | 2024-02-22 11:14:52 +0100 |
commit | 02fcc89abd806bdae495a06fa566870149101bca (patch) | |
tree | 83ea8e9cc8b60bf3b6eebca11395f77a7e7efe09 | |
parent | 76e5123148b8ab7a805987c4dcff8ebaddf15ed6 (diff) |
stream_cli: Correctly setup and free osmo_io client instance
Completely free and setup osmo_io again when reconnecting.
osmo_iofd_notify_connected() must be called before any registration
of read or write, because osmo_io_iouring does not allow this.
Change-Id: I91a6a76b9ff96034a7b333edf87af27490202932
-rw-r--r-- | src/stream_cli.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/stream_cli.c b/src/stream_cli.c index 4a39166..bc19131 100644 --- a/src/stream_cli.c +++ b/src/stream_cli.c @@ -161,7 +161,8 @@ static void osmo_stream_cli_close_iofd(struct osmo_stream_cli *cli) if (!cli->iofd) return; - osmo_iofd_close(cli->iofd); + osmo_iofd_free(cli->iofd); + cli->iofd = NULL; } static void osmo_stream_cli_close_ofd(struct osmo_stream_cli *cli) @@ -904,19 +905,20 @@ int osmo_stream_cli_open(struct osmo_stream_cli *cli) goto error_close_socket; break; case OSMO_STREAM_MODE_OSMO_IO: + enum osmo_io_fd_mode iofd_mode = OSMO_IO_FD_MODE_READ_WRITE; + if (cli->proto == IPPROTO_SCTP) + iofd_mode = OSMO_IO_FD_MODE_SCTP_RECVMSG_SEND; + cli->iofd = osmo_iofd_setup(cli, fd, cli->name, iofd_mode, &osmo_stream_cli_ioops, cli); if (!cli->iofd) { - enum osmo_io_fd_mode iofd_mode = OSMO_IO_FD_MODE_READ_WRITE; - if (cli->proto == IPPROTO_SCTP) - iofd_mode = OSMO_IO_FD_MODE_SCTP_RECVMSG_SEND; - cli->iofd = osmo_iofd_setup(cli, fd, cli->name, iofd_mode, &osmo_stream_cli_ioops, cli); - } - if (!cli->iofd) goto error_close_socket; + } + + osmo_iofd_notify_connected(cli->iofd); + configure_cli_segmentation_cb(cli->iofd, cli->segmentation_cb); if (osmo_iofd_register(cli->iofd, fd) < 0) goto error_close_socket; - osmo_iofd_notify_connected(cli->iofd); break; default: OSMO_ASSERT(false); |