This is the mail archive of the cygwin mailing list for the Cygwin project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
It appears that opening a socket, and then calling connect() on it and from another thread calling close() on the socket while it's still in connect() results in a deadlock. Furthermore in this state the thread cannot be canceled and connect() will never return (my testcase uses pthread_cancel(), but it happens without that as well) This does not happen on linux. I tested this with the latest snapshot, same problem. I'm running Win7 and I've attached a test case.
#include <pthread.h> #include <string.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <unistd.h> #include <stdio.h> int sock; struct sockaddr_in addr; void* my_thread(void *arg); int main(int argc, char **argv){ printf("Test started\n"); pthread_t thread; sock = socket(AF_INET, SOCK_STREAM, 0); addr.sin_family = AF_INET; addr.sin_port = htons(8676); addr.sin_addr.s_addr = inet_addr("10.0.0.3"); pthread_create(&thread, NULL, my_thread, NULL); sleep(1); if (close(sock)){ perror("close"); } pthread_cancel(thread); pthread_join(thread, NULL); printf("no bug\n"); return 0; } void* my_thread(void *arg){ if (connect(sock, (struct sockaddr*)&addr, sizeof(addr)) == -1){ perror("connect"); } else { printf("Returned success\n"); } return NULL; }
Attachment:
cygcheck.out
Description: Text document
-- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |