From 835ba470fb6a73b74e258e12678236106d0df09e Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Thu, 19 Aug 2010 18:19:53 +0100 Subject: [PATCH] lib-master: Fixed accepting FIFO connections with BSDI. --- src/lib-master/master-service.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/lib-master/master-service.c b/src/lib-master/master-service.c index 38f64a1c65..54d1d38686 100644 --- a/src/lib-master/master-service.c +++ b/src/lib-master/master-service.c @@ -709,16 +709,25 @@ static void master_service_listen(struct master_service_listener *l) conn.listen_fd = l->fd; conn.fd = net_accept(l->fd, &conn.remote_ip, &conn.remote_port); if (conn.fd < 0) { + struct stat st; + int orig_errno = errno; + if (conn.fd == -1) return; - if (errno != ENOTSOCK) { + if (errno == ENOTSOCK) { + /* it's not a socket. should be a fifo. */ + } else if (errno == EINVAL && + (fstat(l->fd, &st) < 0 || !S_ISFIFO(st.st_mode))) { + /* BSDI fails accept(fifo) with EINVAL. */ + } else { + errno = orig_errno; i_error("net_accept() failed: %m"); master_service_error(service); return; } - /* it's not a socket. probably a fifo. use the "listener" - as the connection fd and stop the listener. */ + /* use the "listener" as the connection fd and stop the + listener. */ conn.fd = l->fd; conn.listen_fd = l->fd; conn.fifo = TRUE; -- 2.47.3