]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
lib: fix notification by reading one byte at a time from Unix socket
authorVincent Bernat <bernat@luffy.cx>
Wed, 14 Aug 2013 17:17:23 +0000 (19:17 +0200)
committerVincent Bernat <bernat@luffy.cx>
Wed, 14 Aug 2013 17:17:23 +0000 (19:17 +0200)
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
src/lib/connection.c

index 1486b1faa94cdb1657a16d4cff205345b0604e63..667796a6fdf119a38a9017c2738ac7c10a069525 100644 (file)
@@ -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);
        }
index a5baeaf5283d61cfe32fbd896b6f0c789ec6a9a5..05bd5c61d11eb40390b79c2c0733170f1e9d5083 100644 (file)
@@ -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)