From bdc954b77ada430ca4897c4adc1b25e2103a4450 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Wed, 14 Aug 2013 19:17:23 +0200 Subject: [PATCH] lib: fix notification by reading one byte at a time from Unix socket Internally, several bytes will be read at once and the notification should be detected earlier. This fixes a regression introduced in 5aeda65433fd41b7bb67f908d8c4741f045ce508 because we relied on datagram boundary semantics. This was not important when pulling information but we still used this semantic when pushing information. Closes: #43. --- src/lib/atom.c | 7 ++----- src/lib/connection.c | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/lib/atom.c b/src/lib/atom.c index 1486b1fa..667796a6 100644 --- a/src/lib/atom.c +++ b/src/lib/atom.c @@ -369,8 +369,7 @@ lldpctl_watch_callback(lldpctl_conn_t *conn, int lldpctl_watch(lldpctl_conn_t *conn) { - int rc; - size_t much; + int rc = 0; RESET_ERROR(conn); @@ -378,10 +377,8 @@ lldpctl_watch(lldpctl_conn_t *conn) return SET_ERROR(conn, LLDPCTL_ERR_INVALID_STATE); conn->watch_triggered = 0; - much = 512; while (!conn->watch_triggered) { - rc = _lldpctl_needs(conn, much); - much += 512; + rc = _lldpctl_needs(conn, 1); if (rc < 0) return SET_ERROR(conn, rc); } diff --git a/src/lib/connection.c b/src/lib/connection.c index a5baeaf5..05bd5c61 100644 --- a/src/lib/connection.c +++ b/src/lib/connection.c @@ -61,7 +61,7 @@ sync_send(lldpctl_conn_t *lldpctl, return nb; } -/* Statiscally receive data from remote end. */ +/* Statically receive data from remote end. */ static ssize_t sync_recv(lldpctl_conn_t *lldpctl, const uint8_t *data, size_t length, void *user_data) -- 2.39.5