aboutsummaryrefslogtreecommitdiffstats
path: root/src/stream.c
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2017-04-27 10:59:31 +0200
committerHarald Welte <laforge@gnumonks.org>2017-05-14 21:51:26 +0200
commit31b1dbd894d6c4b1f1abf38b2816cca920e894f9 (patch)
tree7a936e46d258e988b59dc69805bbd05b762cedcb /src/stream.c
parent56add1e78064698fdf909cf000d413357303af8a (diff)
somo_stream_srv_fd_cb(): close socket if NODELAY fails
We didn't check for cases where setsockopt_nodelay() fails. Let's check for that and bail out + close the socket. Change-Id: I0adbc4cec35be7c36bdf01d4d8fefd6097e9be5d Fixes: coverity CID#166970
Diffstat (limited to 'src/stream.c')
-rw-r--r--src/stream.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/stream.c b/src/stream.c
index add08b8..b96293e 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -431,17 +431,23 @@ int osmo_stream_cli_open2(struct osmo_stream_cli *cli, int reconnect)
osmo_stream_cli_reconnect(cli);
return ret;
}
-
- if (cli->flags & OSMO_STREAM_CLI_F_NODELAY)
- setsockopt_nodelay(cli->ofd.fd, cli->proto, 1);
-
cli->ofd.fd = ret;
- if (osmo_fd_register(&cli->ofd) < 0) {
- close(ret);
- cli->ofd.fd = -1;
- return -EIO;
+
+ if (cli->flags & OSMO_STREAM_CLI_F_NODELAY) {
+ ret = setsockopt_nodelay(cli->ofd.fd, cli->proto, 1);
+ if (ret < 0)
+ goto error_close_socket;
}
+
+ if (osmo_fd_register(&cli->ofd) < 0)
+ goto error_close_socket;
+
return 0;
+
+error_close_socket:
+ close(ret);
+ cli->ofd.fd = -1;
+ return -EIO;
}
/*! \brief Set the NODELAY socket option to avoid Nagle-like behavior