client: Ensure the "file" header is sent on connect

A non-blocking STREAM socket connect() will mark the socket as
write-able once the connection succeeds.  However, as we first
call osmo_fd_setup() and then osmo_sock_init2_ofd(), the latter
will force the 'when' to OSMO_FD_READ and hence the write callback
will not be called.

Change-Id: I44c484b48966a985a9b85fb16122a17df5666bc1
This commit is contained in:
Harald Welte 2021-04-23 13:25:09 +02:00
parent 831494ed34
commit 9148d49841
1 changed files with 4 additions and 4 deletions

View File

@ -293,10 +293,8 @@ void osmo_client_connect(struct osmo_pcap_client_conn *conn)
break;
}
osmo_fd_setup(&conn->wqueue.bfd, -1, when, conn_cb, conn, 0);
rc = osmo_sock_init2_ofd(&conn->wqueue.bfd, AF_INET, sock_type, sock_proto,
conn->source_ip, 0, conn->srv_ip, srv_port,
OSMO_SOCK_F_BIND | OSMO_SOCK_F_CONNECT | OSMO_SOCK_F_NONBLOCK);
rc = osmo_sock_init2(AF_INET, sock_type, sock_proto, conn->source_ip, 0, conn->srv_ip, srv_port,
OSMO_SOCK_F_BIND | OSMO_SOCK_F_CONNECT | OSMO_SOCK_F_NONBLOCK);
if (rc < 0) {
LOGP(DCLIENT, LOGL_ERROR,
"Failed to connect conn=%s to %s:%d\n",
@ -304,6 +302,8 @@ void osmo_client_connect(struct osmo_pcap_client_conn *conn)
lost_connection(conn);
return;
}
osmo_fd_setup(&conn->wqueue.bfd, rc, when, conn_cb, conn, 0);
osmo_fd_register(&conn->wqueue.bfd);
rate_ctr_inc(&conn->client->ctrg->ctr[CLIENT_CTR_CONNECT]);
}