[#1094] Re: [ruby-cvs] ruby, ruby/lib: * eval.c (ev_const_defined, ev_const_get), variable.c — Dave Thomas <dave@...>

> * eval.c (rb_mod_autoload, rb_mod_autoload_p): new method;

12 messages 2003/05/29
[#1095] Re: [ruby-cvs] ruby, ruby/lib: * eval.c (ev_const_defined, ev_const_get), variable.c — nobu.nokada@... 2003/05/29

Hi,

Re: ping.rb

From: nobu.nokada@...
Date: 2003-05-15 23:48:47 UTC
List: ruby-core #1053
Hi,

At Fri, 16 May 2003 01:10:54 +0900,
Dave Thomas wrote:
> >>I just tried using the Cygwin code under OSX, and it doesn't seem to
> >>fix it: I just get EINVAL back 10 times in a row.
> > Mmmm, how do other programs (telnet, ping ...) handle that
> > condition?
> 
> I'm guessing the problem is caused by the socket being opened in
> nowait mode. I'm trying to find some source that also does that.

Although it's ad hoc, what about treating EINVAL preceded by
EINPROGRESS as ECONNREFUSED?


Index: ext/socket/socket.c
===================================================================
RCS file: /cvs/ruby/src/ruby/ext/socket/socket.c,v
retrieving revision 1.92
diff -u -2 -p -r1.92 socket.c
--- ext/socket/socket.c	7 Apr 2003 06:58:31 -0000	1.92
+++ ext/socket/socket.c	15 May 2003 23:37:47 -0000
@@ -734,5 +734,5 @@ ruby_connect(fd, sockaddr, len, socks)
     int status;
     int mode;
-#if defined __CYGWIN__
+#if defined __CYGWIN__ || defined __MACOSX__
     int wait_in_progress = -1;
 #endif
@@ -775,10 +775,13 @@ ruby_connect(fd, sockaddr, len, socks)
 		wait_in_progress = 10;
 #endif
+#ifdef __MACOSX__
+		wait_in_progress = 1;
+#endif
 #endif
 		thread_write_select(fd);
 		continue;
 
-#if defined __CYGWIN__
 	      case EINVAL:
+#if defined __CYGWIN__
 		if (wait_in_progress-- > 0) {
 		    struct timeval tv = {0, 100000};
@@ -786,6 +789,11 @@ ruby_connect(fd, sockaddr, len, socks)
 		    continue;
 		}
-		break;
 #endif
+#if defined __MACOSX__
+		if (wait_in_progress > 0) {
+		    errno = ECONNREFUSED;
+		}
+#endif
+		break;
 
 #ifdef EISCONN


-- 
Nobu Nakada

In This Thread