socket-util: Don't try to listen to a UDP socket.
authorBen Pfaff <blp@nicira.com>
Tue, 6 Dec 2011 23:57:15 +0000 (15:57 -0800)
committerBen Pfaff <blp@nicira.com>
Mon, 19 Dec 2011 22:53:31 +0000 (14:53 -0800)
The "listen" system call doesn't work and isn't necessary for UDP, but
inet_open_passive() would still try to call it (and fail).

This doesn't fix a real bug because the two existing callers both use
inet_open_passive() to listen for TCP connections.

Signed-off-by: Ben Pfaff <blp@nicira.com>
lib/socket-util.c

index 219433f..12f0432 100644 (file)
@@ -702,7 +702,7 @@ inet_open_passive(int style, const char *target, int default_port,
     }
 
     /* Listen. */
-    if (listen(fd, 10) < 0) {
+    if (style == SOCK_STREAM && listen(fd, 10) < 0) {
         error = errno;
         VLOG_ERR("%s: listen: %s", target, strerror(error));
         goto error;