osmo_stream_cli_open2(): Fix bogus EINPROGRESS handling

osmo_sock_init() never returns -1 + errno EINPROGRESS. It will return a
positive fd in case the connect operation is in progress. Therefore,
the related code in osmo_stream_cli_open2() was impossible to execute.

Change-Id: Id3483d1d1d4d2eabba94729ea29e5c93b33abff0
Fixes: Coverity CID 57861
This commit is contained in:
Harald Welte 2016-11-26 15:53:35 +01:00
parent 3dd57f737c
commit 29d6cd4134
1 changed files with 3 additions and 10 deletions

View File

@ -308,16 +308,9 @@ int osmo_stream_cli_open2(struct osmo_stream_cli *cli, int reconnect)
ret = osmo_sock_init(AF_INET, SOCK_STREAM, cli->proto,
cli->addr, cli->port,
OSMO_SOCK_F_CONNECT);
if (ret < 0) {
if (errno != EINPROGRESS) {
if (reconnect) {
osmo_timer_schedule(&cli->timer, cli->reconnect_timeout, 0);
cli->state = STREAM_CLI_STATE_CONNECTING;
return 0;
} else
return ret;
}
}
if (ret < 0)
return ret;
cli->ofd.fd = ret;
if (osmo_fd_register(&cli->ofd) < 0) {
close(ret);