This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Harald Welte gerrit-no-reply at lists.osmocom.org
Review at https://gerrit.osmocom.org/3336
client: Move to osmo_sock_init2_ofd()
We can simplify the code even further by using the osmo_fd version
of osmo_sock_init2() called osmo_sock_init2_ofd(), which takes care
of filling the osmo_fd.fd member and registering the socket in the
select loop.
Change-Id: Ibf1480e7dee287db77a19bb9f0254edddf7706ab
---
M src/osmo_client_network.c
1 file changed, 3 insertions(+), 12 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-pcap refs/changes/36/3336/1
diff --git a/src/osmo_client_network.c b/src/osmo_client_network.c
index 03cb281..402e1cb 100644
--- a/src/osmo_client_network.c
+++ b/src/osmo_client_network.c
@@ -228,31 +228,22 @@
void osmo_client_connect(struct osmo_pcap_client_conn *conn)
{
- int fd;
+ int rc;
osmo_client_disconnect(conn);
conn->wqueue.read_cb = read_cb;
conn->wqueue.write_cb = write_cb;
- conn->wqueue.bfd.when = BSC_FD_READ;
osmo_wqueue_clear(&conn->wqueue);
- fd = osmo_sock_init2(AF_INET, SOCK_STREAM, IPPROTO_TCP,
+ rc = osmo_sock_init2_ofd(&conn->wqueue.bfd, AF_INET, SOCK_STREAM, IPPROTO_TCP,
conn->source_ip, 0,
conn->srv_ip, conn->srv_port,
OSMO_SOCK_F_BIND | OSMO_SOCK_F_CONNECT | OSMO_SOCK_F_NONBLOCK);
- if (fd < 0) {
+ if (rc < 0) {
LOGP(DCLIENT, LOGL_ERROR,
"Failed to connect conn=%s to %s:%d\n",
conn->name, conn->srv_ip, conn->srv_port);
- lost_connection(conn);
- return;
- }
-
- conn->wqueue.bfd.fd = fd;
- if (osmo_fd_register(&conn->wqueue.bfd) != 0) {
- LOGP(DCLIENT, LOGL_ERROR,
- "Failed to register to BFD conn=%s\n", conn->name);
lost_connection(conn);
return;
}
--
To view, visit https://gerrit.osmocom.org/3336
To unsubscribe, visit https://gerrit.osmocom.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibf1480e7dee287db77a19bb9f0254edddf7706ab
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcap
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>