[Python-checkins] CVS: python/dist/src/Modules selectmodule.c,2.53,2.54

Barry Warsaw bwarsaw@users.sourceforge.net
2001年8月16日 09:53:01 -0700


Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv14019
Modified Files:
	selectmodule.c 
Log Message:
select_select(): Closing bug #448351 the easy way, i.e. by changing
 the "#ifdef MS_WINDOWS" to "#ifdef SELECT_USES_HEAP" and by
 setting SELECT_USES_HEAP when FD_SETSIZE > 1024.
 The indirection seems useful since this subtly changes the path
 that "normal" Windows programs take (where Timmie sez FD_SETSIZE =
 512). If that's a problem for Windows, he has only one place to
 change.
Index: selectmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/selectmodule.c,v
retrieving revision 2.53
retrieving revision 2.54
diff -C2 -d -r2.53 -r2.54
*** selectmodule.c	2001年07月19日 21:29:49	2.53
--- selectmodule.c	2001年08月16日 16:52:59	2.54
***************
*** 182,197 ****
 }
 
! 
 static PyObject *
 select_select(PyObject *self, PyObject *args)
 {
! #ifdef MS_WINDOWS
 	/* This would be an awful lot of stack space on Windows! */
 	pylist *rfd2obj, *wfd2obj, *efd2obj;
! #else
 	pylist rfd2obj[FD_SETSIZE + 3];
 	pylist wfd2obj[FD_SETSIZE + 3];
 	pylist efd2obj[FD_SETSIZE + 3];
! #endif
 	PyObject *ifdlist, *ofdlist, *efdlist;
 	PyObject *ret = NULL;
--- 182,210 ----
 }
 
! #undef SELECT_USES_HEAP
! #if FD_SETSIZE > 1024
! #define SELECT_USES_HEAP
! #endif /* FD_SETSIZE > 1024 */
! 
 static PyObject *
 select_select(PyObject *self, PyObject *args)
 {
! #ifdef SELECT_USES_HEAP
 	/* This would be an awful lot of stack space on Windows! */
 	pylist *rfd2obj, *wfd2obj, *efd2obj;
! #else /* !SELECT_USES_HEAP */
! 	/* XXX: Why, oh why does this add 3?! As far as anyone can tell,
! 	 * it should only add 1 for the sentinel.
! 	 *
! 	 * XXX: All this should probably be implemented as follows:
! 	 * - find the highest descriptor we're interested in
! 	 * - add one
! 	 * - that's the size
! 	 * See: Stevens, APitUE, 12ドル.5.1
! 	 */
 	pylist rfd2obj[FD_SETSIZE + 3];
 	pylist wfd2obj[FD_SETSIZE + 3];
 	pylist efd2obj[FD_SETSIZE + 3];
! #endif /* SELECT_USES_HEAP */
 	PyObject *ifdlist, *ofdlist, *efdlist;
 	PyObject *ret = NULL;
***************
*** 238,242 ****
 	}
 
! #ifdef MS_WINDOWS
 	/* Allocate memory for the lists */
 	rfd2obj = PyMem_NEW(pylist, FD_SETSIZE + 3);
--- 251,255 ----
 	}
 
! #ifdef SELECT_USES_HEAP
 	/* Allocate memory for the lists */
 	rfd2obj = PyMem_NEW(pylist, FD_SETSIZE + 3);
***************
*** 249,253 ****
 		return NULL;
 	}
! #endif
 	/* Convert lists to fd_sets, and get maximum fd number
 	 * propagates the Python exception set in list2set()
--- 262,266 ----
 		return NULL;
 	}
! #endif /* SELECT_USES_HEAP */
 	/* Convert lists to fd_sets, and get maximum fd number
 	 * propagates the Python exception set in list2set()
***************
*** 303,311 ****
 	reap_obj(wfd2obj);
 	reap_obj(efd2obj);
! #ifdef MS_WINDOWS
 	PyMem_DEL(rfd2obj);
 	PyMem_DEL(wfd2obj);
 	PyMem_DEL(efd2obj);
! #endif
 	return ret;
 }
--- 316,324 ----
 	reap_obj(wfd2obj);
 	reap_obj(efd2obj);
! #ifdef SELECT_USES_HEAP
 	PyMem_DEL(rfd2obj);
 	PyMem_DEL(wfd2obj);
 	PyMem_DEL(efd2obj);
! #endif /* SELECT_USES_HEAP */
 	return ret;
 }

AltStyle によって変換されたページ (->オリジナル) /