Harald Welte has submitted this change and it was merged.

Change subject: client: Move to osmo_sock_init2_ofd()
......................................................................


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(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



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: merged
Gerrit-Change-Id: Ibf1480e7dee287db77a19bb9f0254edddf7706ab
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcap
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <[email protected]>
Gerrit-Reviewer: Harald Welte <[email protected]>
Gerrit-Reviewer: Jenkins Builder

Reply via email to