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

Anthony Baxter anthonybaxter@users.sourceforge.net
Thu, 01 Nov 2001 06:39:43 -0800


Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv10834

Modified Files:
      Tag: release21-maint
	selectmodule.c 
Log Message:
backport 2.56 from uncle tim:
  Stop adding 3 to FD_SETSIZE -- it makes no sense.  If it turns out it
  actually does <wink>, perhaps an Insure run will catch it.
  Also removed senseless Windows comment.


Index: selectmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/selectmodule.c,v
retrieving revision 2.50.4.3
retrieving revision 2.50.4.4
diff -C2 -d -r2.50.4.3 -r2.50.4.4
*** selectmodule.c	2001/11/01 14:37:48	2.50.4.3
--- selectmodule.c	2001/11/01 14:39:41	2.50.4.4
***************
*** 72,79 ****
  
  static void
! reap_obj(pylist fd2obj[FD_SETSIZE + 3])
  {
  	int i;
! 	for (i = 0; i < FD_SETSIZE + 3 && fd2obj[i].sentinel >= 0; i++) {
  		Py_XDECREF(fd2obj[i].obj);
  		fd2obj[i].obj = NULL;
--- 72,79 ----
  
  static void
! reap_obj(pylist fd2obj[FD_SETSIZE + 1])
  {
  	int i;
! 	for (i = 0; i < FD_SETSIZE + 1 && fd2obj[i].sentinel >= 0; i++) {
  		Py_XDECREF(fd2obj[i].obj);
  		fd2obj[i].obj = NULL;
***************
*** 87,91 ****
  */
  static int
! list2set(PyObject *list, fd_set *set, pylist fd2obj[FD_SETSIZE + 3])
  {
  	int i;
--- 87,91 ----
  */
  static int
! list2set(PyObject *list, fd_set *set, pylist fd2obj[FD_SETSIZE + 1])
  {
  	int i;
***************
*** 142,146 ****
  /* returns NULL and sets the Python exception if an error occurred */
  static PyObject *
! set2list(fd_set *set, pylist fd2obj[FD_SETSIZE + 3])
  {
  	int i, j, count=0;
--- 142,146 ----
  /* returns NULL and sets the Python exception if an error occurred */
  static PyObject *
! set2list(fd_set *set, pylist fd2obj[FD_SETSIZE + 1])
  {
  	int i, j, count=0;
***************
*** 191,201 ****
  {
  #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
--- 191,197 ----
  {
  #ifdef SELECT_USES_HEAP
  	pylist *rfd2obj, *wfd2obj, *efd2obj;
  #else  /* !SELECT_USES_HEAP */
! 	/* XXX: All this should probably be implemented as follows:
  	 * - find the highest descriptor we're interested in
  	 * - add one
***************
*** 203,209 ****
  	 * 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;
--- 199,205 ----
  	 * See: Stevens, APitUE, $12.5.1
  	 */
! 	pylist rfd2obj[FD_SETSIZE + 1];
! 	pylist wfd2obj[FD_SETSIZE + 1];
! 	pylist efd2obj[FD_SETSIZE + 1];
  #endif /* SELECT_USES_HEAP */
  	PyObject *ifdlist, *ofdlist, *efdlist;
***************
*** 253,259 ****
  #ifdef SELECT_USES_HEAP
  	/* Allocate memory for the lists */
! 	rfd2obj = PyMem_NEW(pylist, FD_SETSIZE + 3);
! 	wfd2obj = PyMem_NEW(pylist, FD_SETSIZE + 3);
! 	efd2obj = PyMem_NEW(pylist, FD_SETSIZE + 3);
  	if (rfd2obj == NULL || wfd2obj == NULL || efd2obj == NULL) {
  		if (rfd2obj) PyMem_DEL(rfd2obj);
--- 249,255 ----
  #ifdef SELECT_USES_HEAP
  	/* Allocate memory for the lists */
! 	rfd2obj = PyMem_NEW(pylist, FD_SETSIZE + 1);
! 	wfd2obj = PyMem_NEW(pylist, FD_SETSIZE + 1);
! 	efd2obj = PyMem_NEW(pylist, FD_SETSIZE + 1);
  	if (rfd2obj == NULL || wfd2obj == NULL || efd2obj == NULL) {
  		if (rfd2obj) PyMem_DEL(rfd2obj);