diff --git a/ipc.c b/ipc.c index 354ccad..06b2793 100644 --- a/ipc.c +++ b/ipc.c @@ -183,8 +183,7 @@ ipcconnect(void) if(until < 0) goto Bad; if(connect(fd, (struct sockaddr*)&addr, sizeof addr) < 0){ - if(errno != EINPROGRESS && errno != EALREADY && errno != EINTR && - errno != EAGAIN && errno != EWOULDBLOCK) + if(errno != EINPROGRESS && errno != EALREADY && errno != EINTR) goto Bad; if(waitfd(fd, POLLOUT, until) < 0) goto Bad; diff --git a/tests/ipc_test.c b/tests/ipc_test.c index 4ff67cc..b48543a 100644 --- a/tests/ipc_test.c +++ b/tests/ipc_test.c @@ -385,9 +385,9 @@ ipcconnectcloexec(struct ct *t) struct sockaddr_un addr; char root[] = "/tmp/strans-ipc.XXXXXX"; char *old, *saved; - int accepted, client, flags, listener; + int accepted, client, flags, full, listener; - accepted = client = listener = -1; + accepted = client = full = listener = -1; old = getenv("XDG_RUNTIME_DIR"); saved = old == nil ? nil : strdup(old); if(mkdtemp(root) == nil){ @@ -401,19 +401,25 @@ ipcconnectcloexec(struct ct *t) if(ipcpath(addr.sun_path, sizeof addr.sun_path) < 0 || (listener = socket(AF_UNIX, SOCK_STREAM, 0)) < 0 || bind(listener, (struct sockaddr*)&addr, sizeof addr) < 0 || - listen(listener, 1) < 0){ + listen(listener, 0) < 0){ CT_ERRORF(t, "listen failed: %s", strerror(errno)); goto Out; } client = ipcconnect(); if(!CT_CHECK(t, client >= 0)) goto Out; + flags = fcntl(client, F_GETFD); + CT_CHECK(t, flags >= 0 && (flags & FD_CLOEXEC) != 0); + errno = 0; + full = ipcconnect(); + CT_EQ_INT(t, -1, full); + CT_CHECK(t, errno == EAGAIN || errno == EWOULDBLOCK); accepted = accept(listener, nil, nil); if(!CT_CHECK(t, accepted >= 0)) goto Out; - flags = fcntl(client, F_GETFD); - CT_CHECK(t, flags >= 0 && (flags & FD_CLOEXEC) != 0); Out: + if(full >= 0) + close(full); if(accepted >= 0) close(accepted); if(client >= 0)