[#11357] [PATCH] an analogue of `long long' — "Nobuyoshi.Nakada" <nobu.nakada@...>

なかだです。

18 messages 2000/11/01
[#11358] Re: [PATCH] an analogue of `long long' — matz@... (Yukihiro Matsumoto) 2000/11/01

まつもと ゆきひろです

[#11364] Re: [PATCH] an analogue of `long long' — EGUCHI Osamu <eguchi@...> 2000/11/02

えぐち@エスアンドイー です。

[#11440] class Character (was: Ruby I18N) — Yasushi Shoji <yashi@...>

[ruby-dev:11428] からの続きですが、threadは切りました。

14 messages 2000/11/08
[#11442] Re: class Character (was: Ruby I18N) — TAKAHASHI Masayoshi <maki@...> 2000/11/08

高橋征義です。用語について。

[#11443] Re: class Character (was: Ruby I18N) — Yasushi Shoji <yashi@...> 2000/11/08

At Wed, 8 Nov 2000 20:44:55 +0900,

[#11520] A problem of Socket methods on Windows — OKA Toshiyuki <oka@...>

岡と申します。

22 messages 2000/11/15
[#11523] Re: A problem of Socket methods on Windows — "Nobuyoshi.Nakada" <nobu.nakada@...> 2000/11/15

なかだです。

[#11528] Re: A problem of Socket methods on Windows — matz@... (Yukihiro Matsumoto) 2000/11/15

まつもと ゆきひろです

[#11532] Re: A problem of Socket methods on Windows — "Nobuyoshi.Nakada" <nobu.nakada@...> 2000/11/15

なかだです。

[#11534] Re: A problem of Socket methods on Windows — OKA Toshiyuki <oka@...> 2000/11/15

岡です。

[#11535] Re: A problem of Socket methods on Windows — "Nobuyoshi.Nakada" <nobu.nakada@...> 2000/11/15

なかだです。

[#11538] Re: A problem of Socket methods on Windows — "Nobuyoshi.Nakada" <nobu.nakada@...> 2000/11/15

なかだです。

[#11662] IO (Re: fork problem?) — Tanaka Akira <akr@...17n.org>

In article <E140cR3-0002ls-00@ev.netlab.zetabits.co.jp>,

22 messages 2000/11/28
[#11663] Re: IO (Re: fork problem?) — matz@... (Yukihiro Matsumoto) 2000/11/28

まつもと ゆきひろです

[#11664] Re: IO (Re: fork problem?) — Tanaka Akira <akr@...17n.org> 2000/11/28

In article <E140fxW-0002u9-00@ev.netlab.zetabits.co.jp>,

[#11665] Re: IO (Re: fork problem?) — Tanaka Akira <akr@...17n.org> 2000/11/28

In article <hvor93w5wb8.fsf@coulee.m17n.org>,

[#11669] Re: IO (Re: fork problem?) — Tanaka Akira <akr@...17n.org> 2000/11/29

In article <hvoofz05uwz.fsf@coulee.m17n.org>,

[#11672] Re: IO (Re: fork problem?) — matz@... (Yukihiro Matsumoto) 2000/11/29

まつもと ゆきひろです

[#11675] Re: IO (Re: fork problem?) — Koji Arai <JCA02266@...> 2000/11/30

新井です。

[#11677] Re: IO (Re: fork problem?) — matz@... (Yukihiro Matsumoto) 2000/12/01

まつもと ゆきひろです

[ruby-dev:11538] Re: A problem of Socket methods on Windows

From: "Nobuyoshi.Nakada" <nobu.nakada@...>
Date: 2000-11-15 10:42:52 UTC
List: ruby-dev #11538
なかだです。

At Wed, 15 Nov 2000 16:21:55 +0900
"Nobuyoshi.Nakada" <nobu.nakada@nifty.ne.jp> wrote:
>   てことは、myfdopen(), myfdclose() からして不要ということになりますが、
> ext/socket/socket.c を見るとどうも close() と closesocket() とで分けてる
> らしいので、#undef getsockopt を is_socket() の前に持ってきて、こうすれ
> ばいいのかもしれません。

  どうにも HANDLE と descritor が錯綜しててややこしいんですが、descritor 
だけ dup して HANDLE はしない、という方がよさそうな。


diff -pruPX ./.excludes current/ext/socket/socket.c devel/ext/socket/socket.c
--- current/ext/socket/socket.c	Wed Nov  8 14:29:35 2000
+++ devel/ext/socket/socket.c	Wed Nov 15 18:41:13 2000
@@ -182,6 +182,7 @@ sock_new(class, fd)
     fp->f = rb_fdopen(fd, "r");
 #ifdef NT
     fp->finalize = sock_finalize;
+    fd = myfddup(fd);
 #else
     fd = dup(fd);
 #endif
diff -pruPX ./.excludes current/win32/win32.c devel/win32/win32.c
--- current/win32/win32.c	Tue Nov 14 16:10:31 2000
+++ devel/win32/win32.c	Wed Nov 15 19:04:21 2000
@@ -1726,6 +1726,8 @@ my_open_osfhandle(long osfhandle, int fl
     return fh;			/* return handle */
 }
 
+#undef getsockopt
+
 static int
 is_socket(SOCKET fd)
 {
@@ -1750,18 +1752,15 @@ is_socket(SOCKET fd)
     return TRUE;
 }
 
-FILE *
-myfdopen (int fd, const char *mode)
+int
+myfddup (int fd)
 {
-    if (is_socket((SOCKET)fd)) {
-	int fh;
+    SOCKET s = TO_SOCKET(fd);
 
-	fh = my_open_osfhandle((SOCKET)fd, O_RDWR|O_BINARY);
-	return _fdopen(fh, mode);		// return file pointer
-    }
-    else {
-	return (_fdopen(fd, mode));
-    }
+    if (s == -1)
+	return -1;
+
+    return my_open_osfhandle(s, O_RDWR|O_BINARY);
 }
 
 
@@ -2056,14 +2055,13 @@ SOCKET
 myaccept (SOCKET s, struct sockaddr *addr, int *addrlen)
 {
     SOCKET r;
-    int trap_immediate = rb_trap_immediate;
 
     if (!NtSocketsInitialized++) {
 	StartSockets();
     }
     if ((r = accept (TO_SOCKET(s), addr, addrlen)) == INVALID_SOCKET)
 	errno = WSAGetLastError();
-    return r;
+    return my_open_osfhandle(r, O_RDWR|O_BINARY);
 }
 
 #undef bind
@@ -2076,7 +2074,7 @@ mybind (SOCKET s, struct sockaddr *addr,
     if (!NtSocketsInitialized++) {
 	StartSockets();
     }
-    if ((r = bind (s, addr, addrlen)) == SOCKET_ERROR)
+    if ((r = bind (TO_SOCKET(s), addr, addrlen)) == SOCKET_ERROR)
 	errno = WSAGetLastError();
     return r;
 }
@@ -2090,7 +2088,7 @@ myconnect (SOCKET s, struct sockaddr *ad
     if (!NtSocketsInitialized++) {
 	StartSockets();
     }
-    if ((r = connect (s, addr, addrlen)) == SOCKET_ERROR)
+    if ((r = connect (TO_SOCKET(s), addr, addrlen)) == SOCKET_ERROR)
 	errno = WSAGetLastError();
     return r;
 }
@@ -2124,8 +2122,6 @@ mygetsockname (SOCKET s, struct sockaddr
     return r;
 }
 
-#undef getsockopt
-
 int 
 mygetsockopt (SOCKET s, int level, int optname, char *optval, int *optlen)
 {
@@ -2133,7 +2129,7 @@ mygetsockopt (SOCKET s, int level, int o
     if (!NtSocketsInitialized++) {
 	StartSockets();
     }
-    if ((r = getsockopt (s, level, optname, optval, optlen)) == SOCKET_ERROR)
+    if ((r = getsockopt (TO_SOCKET(s), level, optname, optval, optlen)) == SOCKET_ERROR)
 	errno = WSAGetLastError();
     return r;
 }
@@ -2161,7 +2157,7 @@ mylisten (SOCKET s, int backlog)
     if (!NtSocketsInitialized++) {
 	StartSockets();
     }
-    if ((r = listen (s, backlog)) == SOCKET_ERROR)
+    if ((r = listen (TO_SOCKET(s), backlog)) == SOCKET_ERROR)
 	errno = WSAGetLastError();
     return r;
 }
@@ -2233,7 +2229,7 @@ mysetsockopt (SOCKET s, int level, int o
     if (!NtSocketsInitialized++) {
 	StartSockets();
     }
-    if ((r = setsockopt (s, level, optname, optval, optlen))
+    if ((r = setsockopt (TO_SOCKET(s), level, optname, optval, optlen))
     		 == SOCKET_ERROR)
 	errno = WSAGetLastError();
     return r;
@@ -2266,7 +2262,7 @@ mysocket (int af, int type, int protocol
 	errno = WSAGetLastError();
 	//fprintf(stderr, "socket fail (%d)", WSAGetLastError());
     }
-    return s;
+    return my_open_osfhandle(s, O_RDWR|O_BINARY);
 }
 
 #undef gethostbyaddr
diff -pruPX ./.excludes current/win32/win32.h devel/win32/win32.h
--- current/win32/win32.h	Tue Nov 14 16:10:31 2000
+++ devel/win32/win32.h	Wed Nov 15 18:42:39 2000
@@ -177,7 +177,7 @@ extern char *NtGetBin(void);
 extern FILE *mypopen(char *, char *);
 extern int   mypclose(FILE *);
 extern int  flock(int fd, int oper);
-extern FILE *  myfdopen(int, const char *);
+extern int  myfddup(int);
 extern void  myfdclose(FILE *);
 extern SOCKET  myaccept(SOCKET, struct sockaddr *, int *);
 extern int  mybind(SOCKET, struct sockaddr *, int);
@@ -266,11 +266,6 @@ extern char *mystrerror(int);
 
 /* #undef va_start */
 /* #undef va_end */
-
-#ifdef fdopen
-#undef fdopen
-#endif
-#define fdopen myfdopen
 
 #ifdef accept
 #undef accept


-- 
--- 僕の前にBugはない。
--- 僕の後ろにBugはできる。
    中田 伸悦


In This Thread