Hello,

Paul Sonnenschein, le jeu. 05 déc. 2019 07:43:10 +0100, a ecrit:
> Am Mittwoch, den 04.12.2019, 23:26 +0100 schrieb Samuel Thibault:
> > Paul Sonnenschein, le mer. 04 déc. 2019 21:45:14 +0100, a ecrit:
> > > The test-http-bad-server.t fails due to an unexpected behaviour of
> > > local sockets in the Hurd. This seems to be a bug in the Hurd
> > > itself
> > > (pflocal specifically), being in violation of the POSIX
> > > specification
> > > Issue 6 and newer.
> > 
> > Which violation is happening here?
> 
> According to POSIX, both read and recv shall set errno to ECONNRESET if
> "[a] read was attempted on a socket and the connection was forcibly
> closed by its peer." As far as I can tell, pflocal will never return
> ECONNRESET.

Yes. The question is what "forcibly" means. On TCP connections, when the
peer sends a RST, ECONNRESET makes complete sense: the stream is not
finished, it was really interrupted. What would be the equivalent for a
local socket?

I played a bit with Linux, and found the attached case to be returning
ECONNRESET, but it's not clear to me why that precise case should do
this. In such case OpenBSD returns 0.

Samuel
#include <sys/socket.h>
#include <stdio.h>
#include <unistd.h>

int main(void) {
	int sv[2];
	char buf[128];

	socketpair(PF_LOCAL, SOCK_STREAM, 0, sv);
	if (fork()) {
		close(sv[1]);
		sleep(1);
		int ret = read(sv[0], buf, sizeof(buf));
		if (ret < 0)
			perror("read");
		else
			printf("got %d bytes\n", ret);
	} else {
		write(sv[0], buf, sizeof(buf));
	}
	return 0;
}

Reply via email to