New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
net: Dial fails on Solaris with gccgo #6828
Labels
Comments
I don't know what is happening here, but it would be much more interesting to try this on tip, since the polling mechanism has completely changed. EINVAL is a peculiar errno value to return. The man page only suggests one possibility: that the address length argument is wrong. I don't see how that could be the case here. Labels changed: added gccgo. Owner changed to @ianlancetaylor. |
This is a guess at the problem. /1: connect(6, 0xC20082EB4C, 16, SOV_XPG4_2) Err#150 EINPROGRESS /4: accept(3, 0xC200831310, 0xC200000168, SOV_DEFAULT, 0) = 7 /4: close(7) = 0 /4: connect(6, 0xC20082EB4C, 16, SOV_XPG4_2) Err#22 EINVAL In other words, I wonder if, while a connect is in progress, the connection is accepted and closed, the attempt to complete the connect returns EINVAL. Labels changed: removed priority-triage, gccgo. |
Confirmed. This program exits with success on GNU/Linux but on Solaris fails with "connect: Invalid argument." #include <errno.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <pthread.h> #include <unistd.h> #include <fcntl.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> static void die (const char *s) { perror (s); exit (EXIT_FAILURE); } static void * thread (void *arg) { int o1, o3; struct sockaddr_in asin; socklen_t slen; o1 = *(int *) arg; slen = sizeof asin; o3 = accept (o1, (struct sockaddr *) &asin, &slen); if (o3 < 0) die ("accept"); if (close (o3) < 0) die ("close"); return NULL; } int main () { struct sockaddr_in sin; int o1, o2, flags; socklen_t slen; pthread_t tid; int i; o1 = socket (AF_INET, SOCK_STREAM, 0); if (o1 < 0) die ("socket 1"); memset (&sin, 0, sizeof sin); sin.sin_family = AF_INET; sin.sin_addr.s_addr = htonl (INADDR_LOOPBACK); if (bind (o1, (struct sockaddr *) &sin, sizeof sin) < 0) die ("bind"); if (listen (o1, 5) < 0) die ("listen"); slen = sizeof sin; if (getsockname (o1, (struct sockaddr *) &sin, &slen) < 0) die ("getsockname"); o2 = socket (AF_INET, SOCK_STREAM, 0); if (o2 < 0) die ("socket 2"); flags = fcntl (o2, F_GETFL); if (flags < 0) die ("fcntl 1"); if (fcntl (o2, F_SETFL, flags | O_NONBLOCK) < 0) die ("fcntl 2"); if (connect (o2, (struct sockaddr *) &sin, sizeof sin) >= 0) die ("connect succeeded"); if (errno != EINPROGRESS) die ("bad connect errno"); i = pthread_create (&tid, NULL, thread, (void *) &o1); if (i != 0) { errno = i; die ("pthread_create"); } sleep (1); if (connect (o2, (struct sockaddr *) &sin, sizeof sin) < 0) die ("connect"); return 0; } |
This issue was updated by revision 672525a. R=golang-codereviews, bradfitz, dave CC=golang-codereviews https://golang.org/cl/46160043 |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Attachments:
The text was updated successfully, but these errors were encountered: