diff options
author | Guido van Rossum <guido@python.org> | 1995-03-29 16:47:45 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1995-03-29 16:47:45 (GMT) |
commit | 07432c0ef60635739151160f626d222bed45cf2c (patch) | |
tree | 4d9cf16bcc7a1a9fbffecbc02c2ef92dde1a4164 /Modules | |
parent | 5ae34bfd0bd6f8184ad4d41abda96f736e16addc (diff) | |
download | cpython-07432c0ef60635739151160f626d222bed45cf2c.zip cpython-07432c0ef60635739151160f626d222bed45cf2c.tar.gz cpython-07432c0ef60635739151160f626d222bed45cf2c.tar.bz2 |
fix subtle refcnt bug
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/selectmodule.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c index a9f55c3..5c83588 100644 --- a/Modules/selectmodule.c +++ b/Modules/selectmodule.c @@ -41,6 +41,10 @@ list2set(list, set, fd2obj) { int i, len, v, max = -1; object *o, *filenomethod, *fno; + + for ( i=0; i<FD_SETSIZE; i++ ) { + fd2obj[i] = (object*)0; + } FD_ZERO(set); len = getlistsize(list); @@ -70,7 +74,6 @@ list2set(list, set, fd2obj) } if ( v > max ) max = v; FD_SET(v, set); - XDECREF(fd2obj[v]); fd2obj[v] = o; } return max+1; @@ -115,7 +118,7 @@ select_select(self, args) object *self; object *args; { - object *fd2obj[FD_SETSIZE]; + object *rfd2obj[FD_SETSIZE], *wfd2obj[FD_SETSIZE], *efd2obj[FD_SETSIZE]; object *ifdlist, *ofdlist, *efdlist; object *ret, *tout; fd_set ifdset, ofdset, efdset; @@ -152,14 +155,12 @@ select_select(self, args) return 0; } - memset((char *)fd2obj, '\0', sizeof(fd2obj)); - /* Convert lists to fd_sets, and get maximum fd number */ - if( (imax=list2set(ifdlist, &ifdset, fd2obj)) < 0 ) + if( (imax=list2set(ifdlist, &ifdset, rfd2obj)) < 0 ) return 0; - if( (omax=list2set(ofdlist, &ofdset, fd2obj)) < 0 ) + if( (omax=list2set(ofdlist, &ofdset, wfd2obj)) < 0 ) return 0; - if( (emax=list2set(efdlist, &efdset, fd2obj)) < 0 ) + if( (emax=list2set(efdlist, &efdset, efd2obj)) < 0 ) return 0; max = imax; if ( omax > max ) max = omax; @@ -177,9 +178,9 @@ select_select(self, args) if ( n == 0 ) imax = omax = emax = 0; /* Speedup hack */ - ifdlist = set2list(&ifdset, imax, fd2obj); - ofdlist = set2list(&ofdset, omax, fd2obj); - efdlist = set2list(&efdset, emax, fd2obj); + ifdlist = set2list(&ifdset, imax, rfd2obj); + ofdlist = set2list(&ofdset, omax, wfd2obj); + efdlist = set2list(&efdset, emax, efd2obj); ret = mkvalue("OOO", ifdlist, ofdlist, efdlist); XDECREF(ifdlist); XDECREF(ofdlist); |