[#26266] pragma on ripper — nobuyoshi nakada <nobuyoshi.nakada@...>

なかだです。

15 messages 2005/06/02

[#26312] rb_gc_mark_threads spin — Tanaka Akira <akr@...17n.org>

最近、とあるプログラム(五月雨)が、無限ループに陥ることが何回かありました。

32 messages 2005/06/09
[#26323] Re: rb_gc_mark_threads spin — Tanaka Akira <akr@...17n.org> 2005/06/10

In article <TYOMLEM04Rqf69aZbLA0000002d@tyomlvem02.e2k.ad.ge.com>,

[#26329] Re: rb_gc_mark_threads spin — nobu@... 2005/06/10

なかだです。

[#26331] Re: rb_gc_mark_threads spin — Tanaka Akira <akr@...17n.org> 2005/06/11

In article <200506101543.j5AFhToG009328@sharui.nakada.niregi.kanuma.tochigi.jp>,

[#26333] Re: rb_gc_mark_threads spin — Tanaka Akira <akr@...17n.org> 2005/06/11

In article <8764wlil9l.fsf@m17n.org>,

[#26334] Re: rb_gc_mark_threads spin — nobu@... 2005/06/11

なかだです。

[#26337] Re: rb_gc_mark_threads spin — Tanaka Akira <akr@...17n.org> 2005/06/11

In article <200506111335.j5BDZkoG019423@sharui.nakada.niregi.kanuma.tochigi.jp>,

[#26405] WEBrick DoS vulnerability — Tanaka Akira <akr@...17n.org>

NetBSD 2.0 で WEBrick を使って HTTP サーバを動かした場合、クライアント

24 messages 2005/06/29
[#26477] Re: WEBrick DoS vulnerability — GOTOU Yuuzou <gotoyuzo@...> 2005/07/08

ごとうゆうぞうです。

[#26480] Re: WEBrick DoS vulnerability — Tanaka Akira <akr@...17n.org> 2005/07/08

In article <20050708.175802.957830318.gotoyuzo@sawara.does.notwork.org>,

[#26481] Re: WEBrick DoS vulnerability — GOTOU Yuuzou <gotoyuzo@...> 2005/07/08

In message <87fyupzgcq.fsf@m17n.org>,

[#26421] Subversion — Shugo Maeda <shugo@...>

前田です。

24 messages 2005/06/30
[#26422] Re: Subversion — Yukihiro Matsumoto <matz@...> 2005/06/30

まつもと ゆきひろです

[#26423] Re: Subversion — "U.Nakamura" <usa@...> 2005/06/30

こんにちは、なかむら(う)です。

[ruby-dev:26264] Re: IO.select dumps core

From: nobu@...
Date: 2005-06-02 00:45:34 UTC
List: ruby-dev #26264
なかだです。

At Thu, 2 Jun 2005 04:18:40 +0900,
Tanaka Akira wrote in [ruby-dev:26262]:
> 基本的な方針は「なぜか余計にメモリを確保しておいて動いたらラッキー」な
> ので、今まで参照していなかった FD_SETSIZE は今さら参照しなくても書ける
> はずなんじゃないかと思います。

[ruby-dev:26255]からのパッチです。


diff -U2 eval.c eval.c
--- eval.c	31 May 2005 06:45:05 -0000
+++ eval.c	2 Jun 2005 00:38:29 -0000
@@ -9782,5 +9782,6 @@
 {
     fds->maxfd = 0;
-    fds->maskp = 0;
+    fds->fdset = ALLOC(fd_set);
+    FD_ZERO(fds->fdset);
 }
 
@@ -9789,6 +9790,7 @@
     rb_fdset_t *fds;
 {
-    if (fds->maskp) free(fds->maskp);
-    rb_fd_init(fds);
+    if (fds->fdset) free(fds->fdset);
+    fds->maxfd = 0;
+    fds->fdset = 0;
 }
 
@@ -9797,6 +9799,7 @@
     rb_fdset_t *fds;
 {
-    if (fds->maskp) {
-	MEMZERO(fds->maskp, fd_mask, howmany(fds->maxfd, NFDBITS));
+    if (fds->fdset) {
+	MEMZERO(fds->fdset, fd_mask, howmany(fds->maxfd, NFDBITS));
+	FD_ZERO(fds->fdset);
     }
 }
@@ -9807,12 +9810,16 @@
     rb_fdset_t *fds;
 {
-    int m = howmany(n + 1, NFDBITS), o = howmany(fds->maxfd, NFDBITS);
+    int m = howmany(n + 1, NFDBITS) * NFDBITS;
+    int o = howmany(fds->maxfd, NFDBITS) * NFDBITS;
+
+    if (m < sizeof(fd_set)) m = sizeof(fd_set);
+    if (o < sizeof(fd_set)) o = sizeof(fd_set);
 
     if (m > o) {
-	REALLOC_N(fds->maskp, fd_mask, m);
-	MEMZERO(fds->maskp + howmany(fds->maxfd, NFDBITS), fd_mask, m - o);
+	fds->fdset = realloc(fds->fdset, m);
+	memset((char *)fds->fdset + o, 0, m - o);
     }
     if (n >= fds->maxfd) fds->maxfd = n + 1;
-    FD_SET(n, (fd_set *)fds->maskp);
+    FD_SET(n, fds->fdset);
 }
 
@@ -9823,5 +9830,5 @@
 {
     if (n >= fds->maxfd) return;
-    FD_CLR(n, (fd_set *)fds->maskp);
+    FD_CLR(n, fds->fdset);
 }
 
@@ -9832,5 +9839,5 @@
 {
     if (n >= fds->maxfd) return 0;
-    return FD_ISSET(n, (fd_set *)fds->maskp);
+    return FD_ISSET(n, fds->fdset);
 }
 
@@ -9841,13 +9848,10 @@
     int max;
 {
-    if ((dst->maxfd = max) > 0) {
-	int n = howmany(max, NFDBITS);
-	REALLOC_N(dst->maskp, fd_mask, n);
-	MEMCPY(dst->maskp, src, fd_mask, n);
-    }
-    else {
-	xfree(dst->maskp);
-	dst->maskp = 0;
-    }
+    int size = howmany(max, NFDBITS) * NFDBITS;
+
+    if (size < sizeof(fd_set)) size = sizeof(fd_set);
+    dst->maxfd = max;
+    dst->fdset = realloc(dst->fdset, size);
+    memcpy(dst->fdset, src, size);
 }
 
@@ -10206,4 +10210,7 @@
 	if (th->next) th->next->prev = th->prev;
     }
+    rb_fd_term(&th->readfds);
+    rb_fd_term(&th->writefds);
+    rb_fd_term(&th->exceptfds);
     if (th != main_thread) free(th);
 }
diff -U2 intern.h intern.h
--- intern.h	31 May 2005 06:44:32 -0000
+++ intern.h	1 Jun 2005 01:05:26 -0000
@@ -149,5 +149,5 @@
 typedef struct {
     int maxfd;
-    fd_mask *maskp;
+    fd_set *fdset;
 } rb_fdset_t;
 
@@ -162,5 +162,5 @@
 void rb_fd_copy _((rb_fdset_t *, const fd_set *, int));
 
-#define rb_fd_ptr(f)	((fd_set *)(f)->maskp)
+#define rb_fd_ptr(f)	((f)->fdset)
 #define rb_fd_max(f)	((f)->maxfd)
 
diff -U2 ext/socket/socket.c ext/socket/socket.c
--- ext/socket/socket.c	31 May 2005 07:02:27 -0000
+++ ext/socket/socket.c	2 Jun 2005 00:40:00 -0000
@@ -889,23 +889,23 @@
 
 static int
-wait_connectable0(fd, fds)
+wait_connectable0(fd, fds_w, fds_e)
     int fd;
-    rb_fdset_t *fds;
+    rb_fdset_t *fds_w, *fds_e;
 {
     int sockerr, sockerrlen;
 
     for (;;) {
-	rb_fd_zero(&fds[0]);
-	rb_fd_zero(&fds[1]);
+	rb_fd_zero(fds_w);
+	rb_fd_zero(fds_e);
 
-	rb_fd_set(fd, &fds[0]);
-	rb_fd_set(fd, &fds[1]);
+	rb_fd_set(fd, fds_w);
+	rb_fd_set(fd, fds_e);
 
-	rb_thread_select(fd+1, 0, rb_fd_ptr(&fds[0]), rb_fd_ptr(&fds[1]), 0);
+	rb_thread_select(fd+1, 0, rb_fd_ptr(fds_w), rb_fd_ptr(fds_e), 0);
 
-	if (rb_fd_isset(fd, &fds[0])) {
+	if (rb_fd_isset(fd, fds_w)) {
 	    return 0;
 	}
-	else if (rb_fd_isset(fd, &fds[1])) {
+	else if (rb_fd_isset(fd, fds_e)) {
 	    sockerrlen = sizeof(sockerr);
 	    if (getsockopt(fd, SOL_SOCKET, SO_ERROR, (void *)&sockerr,
@@ -924,5 +924,6 @@
 struct wait_connectable_arg {
     int fd;
-    rb_fdset_t *fds;
+    rb_fdset_t fds_w;
+    rb_fdset_t fds_e;
 };
 
@@ -933,5 +934,5 @@
 {
     struct wait_connectable_arg *p = (struct wait_connectable_arg *)arg;
-    return (VALUE)wait_connectable0(p->fd, p->fds);
+    return (VALUE)wait_connectable0(p->fd, &p->fds_w, &p->fds_e);
 }
 
@@ -941,6 +942,6 @@
 {
     struct wait_connectable_arg *p = (struct wait_connectable_arg *)arg;
-    rb_fd_term(&p->fds[0]);
-    rb_fd_term(&p->fds[1]);
+    rb_fd_term(&p->fds_w);
+    rb_fd_term(&p->fds_e);
     return Qnil;
 }
@@ -953,6 +954,6 @@
     struct wait_connectable_arg arg;
 
-    rb_fd_init(&arg.fds[0]);
-    rb_fd_init(&arg.fds[1]);
+    rb_fd_init(&arg.fds_w);
+    rb_fd_init(&arg.fds_e);
 #ifdef HAVE_RB_FD_INIT
     arg.fd = fd;
@@ -960,5 +961,5 @@
 			  wait_connectable_ensure,(VALUE)&arg);
 #else
-    return wait_connectable0(fd, arg.fds);
+    return wait_connectable0(fd, &arg.fds_w, &arg.fds_e);
 #endif
 }
@@ -1776,17 +1777,4 @@
 }
 
-#if defined(HAVE_RECVMSG) && (FD_PASSING_BY_MSG_CONTROL || FD_PASSING_BY_MSG_ACCRIGHTS)
-static void
-thread_read_select(fd)
-    int fd;
-{
-    rb_fdset_t fds;
-
-    rb_fd_init(&fds);
-    rb_fd_set(fd, &fds);
-    rb_thread_select(fd+1, rb_fd_ptr(&fds), 0, 0, 0);
-}
-#endif
-
 static VALUE
 unix_recv_io(argc, argv, sock)
@@ -1818,5 +1806,5 @@
     GetOpenFile(sock, fptr);
 
-    thread_read_select(fptr->fd);
+    rb_io_wait_readable(fptr->fd);
 
     msg.msg_name = NULL;


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

In This Thread