diff options
author | Daniel Willmann <dwillmann@sysmocom.de> | 2023-06-15 21:47:10 +0200 |
---|---|---|
committer | Daniel Willmann <dwillmann@sysmocom.de> | 2023-06-15 22:07:21 +0200 |
commit | b08309a89088d605b8add26139a01158b84218b8 (patch) | |
tree | a0e6150e683ed04ed34653d9e5cf8e48e4490bac | |
parent | c873b62929adc1dcae75cc76197951c374614be5 (diff) |
stream: Setup ofd in osmo_stream_cli_open
Don't reset the osmo_fd data in osmo_stream_cli_set_read_cb().
osmo_ss7_asp_restart() in libosmo-sccp calls
osmo_stream_cli_set_read_cb() which causes the fd to be set to -1.
osmo_stream_cli_open() which is called after that then doesn't close the
old fd and opening the new one fails.
osmo_fd priv_nr, callback and data are never modified in osmo_stream_cli
so simply use these values in osmo_stream_cli_open()
Change-Id: Id9b4db06d5ea1f29cbd1817cab3c71765ab30a53
-rw-r--r-- | src/stream.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/src/stream.c b/src/stream.c index d52b7a0..b6ef92f 100644 --- a/src/stream.c +++ b/src/stream.c @@ -859,10 +859,6 @@ osmo_stream_cli_set_read_cb(struct osmo_stream_cli *cli, { OSMO_ASSERT(cli->mode != OSMO_STREAM_MODE_OSMO_IO); cli->mode = OSMO_STREAM_MODE_OSMO_FD; - cli->ofd.fd = -1; - cli->ofd.priv_nr = 0; - cli->ofd.cb = osmo_stream_cli_fd_cb; - cli->ofd.data = cli; cli->read_cb = read_cb; } @@ -926,7 +922,7 @@ int osmo_stream_cli_open2(struct osmo_stream_cli *cli, int reconnect) osmo_stream_cli_reconnect(cli); return ret; } - osmo_fd_setup(&cli->ofd, ret, OSMO_FD_READ | OSMO_FD_WRITE, cli->ofd.cb, cli->ofd.data, cli->ofd.priv_nr); + osmo_fd_setup(&cli->ofd, ret, OSMO_FD_READ | OSMO_FD_WRITE, osmo_stream_cli_fd_cb, cli, 0); if (cli->flags & OSMO_STREAM_CLI_F_NODELAY) { ret = setsockopt_nodelay(cli->ofd.fd, cli->proto, 1); @@ -1019,7 +1015,7 @@ int osmo_stream_cli_open(struct osmo_stream_cli *cli) switch (cli->mode) { case OSMO_STREAM_MODE_OSMO_FD: - osmo_fd_setup(&cli->ofd, fd, OSMO_FD_READ | OSMO_FD_WRITE, cli->ofd.cb, cli->ofd.data, cli->ofd.priv_nr); + osmo_fd_setup(&cli->ofd, fd, OSMO_FD_READ | OSMO_FD_WRITE, osmo_stream_cli_fd_cb, cli, 0); if (osmo_fd_register(&cli->ofd) < 0) goto error_close_socket; break; |