Thread (138 messages) 138 messages, 9 authors, 2015-11-06

Re: [Bug 106241] New: shutdown(3)/close(3) behaviour is incorrect for sockets in accept(3)

From: Eric Dumazet <hidden>
Date: 2015-10-23 16:00:13

On Fri, 2015-10-23 at 16:46 +0100, Alan Burlison wrote:
On 23/10/2015 15:21, Eric Dumazet wrote:
quoted
I claim nothing. If you believe a man page should be fixed, please send
a patch to man page maintainer.
Ermm, you *really* want me to submit a patch removing 'Conforms to 
POSIX.1-2001' from *every* Linux manpage?
Only on the pages you think there is an error that matters.
quoted
Have you tested the patch I sent ?
The AF_UNIX poll one? No, I don't have the means to do so, and in any 
case that's not a POSIX issue, just a plain bug. I'm happy to log a bug 
if that helps.
We submit patches when someone needs a fix.

If not, we have more urgent issues to solve first.

I wrote following test case, and confirmed the patch fixes the issue.

I will submit it formally.

Thanks.

#include <pthread.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <poll.h>

static void fail(const char *str)
{
	perror(str);
	printf("FAIL\n");
	exit(1);
}

int main(int argc, char *argv[])
{
	int listener = socket(AF_UNIX, SOCK_STREAM, 0);
	struct pollfd pfd;
	struct sockaddr_un addr;
	int res;

	if (listener == -1)
		perror("socket()");
	memset(&addr, 0, sizeof(addr));
	addr.sun_family = AF_UNIX;
	if (bind(listener, (struct sockaddr *)&addr, sizeof(addr)) == -1)
		fail("bind()");  
	if (listen(listener, 10) == -1)
		fail("listen()");
	pfd.fd = listener;
	pfd.events = -1;
	res = poll(&pfd, 1, 10);
	if (res == -1)
		fail("poll()");
	if (res == 1 && pfd.revents & (POLLOUT|POLLWRNORM|POLLWRBAND)) {
		fprintf(stderr, "poll(af_unix listener) returned a POLLOUT status !\n");
		printf("FAIL\n");
		return 1;
	}
	printf("OK\n");
	return 0;
}
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help