--------------------- PatchSet 5877 Date: 2003/08/17 12:12:54 Author: serassio Branch: nt-2_5 Tag: (none) Log: Better win32 code optimization in select() loop Members: src/comm_select.c:1.8.10.12->1.8.10.13 src/fd.c:1.7.16.7->1.7.16.8 src/structs.h:1.48.6.19->1.48.6.20 Index: squid/src/comm_select.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/comm_select.c,v retrieving revision 1.8.10.12 retrieving revision 1.8.10.13 diff -u -r1.8.10.12 -r1.8.10.13 --- squid/src/comm_select.c 12 May 2003 08:12:21 -0000 1.8.10.12 +++ squid/src/comm_select.c 17 Aug 2003 12:12:54 -0000 1.8.10.13 @@ -1,6 +1,6 @@ /* - * $Id: comm_select.c,v 1.8.10.12 2003/05/12 08:12:21 serassio Exp $ + * $Id: comm_select.c,v 1.8.10.13 2003/08/17 12:12:54 serassio Exp $ * * DEBUG: section 5 Socket Functions * @@ -706,13 +706,15 @@ #ifdef _SQUID_MSWIN_ xmemcpy(&readfds, &global_readfds, sizeof(global_readfds)); xmemcpy(&writefds, &global_writefds, sizeof(global_writefds)); + xmemcpy(&errfds, &global_writefds, sizeof(global_writefds)); /* remove stalled FDs, and deal with pending descriptors */ pending = 0; FD_ZERO(&pendingfds); for (j = 0; j < (int) readfds.fd_count; j++) { + register int readfds_handle = readfds.fd_array[j]; no_bits = 1; for ( fd = Biggest_FD; fd; fd-- ) { - if ( _get_osfhandle(fd) == readfds.fd_array[j] ) { + if ( fd_table[fd].win32.handle == readfds_handle ) { if (fd_table[fd].flags.open) { no_bits = 0; break; @@ -816,7 +818,7 @@ break; if (ignoreErrno(errno)) break; - debug(50, 0) ("comm_select: select failure: %s\n", + debug(5, 0) ("comm_select: select failure: %s\n", xstrerror()); examine_select(&readfds, &writefds); return COMM_ERROR; @@ -840,10 +842,14 @@ assert(readfds.fd_count <= (unsigned int) Biggest_FD); assert(pendingfds.fd_count <= (unsigned int) Biggest_FD); for (j = 0; j < (int) readfds.fd_count; j++) { - no_bits = 1; + register int readfds_handle = readfds.fd_array[j]; + register int pendingfds_handle = pendingfds.fd_array[j]; + register int osfhandle; + no_bits = 1; for ( fd = Biggest_FD; fd; fd-- ) { - if (( _get_osfhandle(fd) == readfds.fd_array[j] ) || - ( _get_osfhandle(fd) == pendingfds.fd_array[j] )) { + osfhandle = fd_table[fd].win32.handle; + if (( osfhandle == readfds_handle ) || + ( osfhandle == pendingfds_handle )) { if (fd_table[fd].flags.open) { no_bits = 0; break; @@ -908,8 +914,9 @@ #ifdef _SQUID_MSWIN_ assert(errfds.fd_count <= (unsigned int) Biggest_FD); for (j = 0; j < (int) errfds.fd_count; j++) { + register int errfds_handle = errfds.fd_array[j]; for ( fd = Biggest_FD; fd; fd-- ) { - if ( _get_osfhandle(fd) == errfds.fd_array[j] ) + if ( fd_table[fd].win32.handle == errfds_handle ) break; } if (fd_table[fd].flags.open) { @@ -919,14 +926,15 @@ commUpdateWriteBits(fd, NULL); hdl(fd, F->write_data); statCounter.select_fds++; - } + } } } assert(writefds.fd_count <= (unsigned int) Biggest_FD); for (j = 0; j < (int) writefds.fd_count; j++) { + register int writefds_handle = writefds.fd_array[j]; no_bits = 1; for ( fd = Biggest_FD; fd; fd-- ) { - if ( _get_osfhandle(fd) == writefds.fd_array[j] ) { + if ( fd_table[fd].win32.handle == writefds_handle ) { if (fd_table[fd].flags.open) { no_bits = 0; break; Index: squid/src/fd.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/fd.c,v retrieving revision 1.7.16.7 retrieving revision 1.7.16.8 diff -u -r1.7.16.7 -r1.7.16.8 --- squid/src/fd.c 27 Oct 2002 10:46:14 -0000 1.7.16.7 +++ squid/src/fd.c 17 Aug 2003 12:14:06 -0000 1.7.16.8 @@ -1,6 +1,6 @@ /* - * $Id: fd.c,v 1.7.16.7 2002/10/27 10:46:14 serassio Exp $ + * $Id: fd.c,v 1.7.16.8 2003/08/17 12:14:06 serassio Exp $ * * DEBUG: section 51 Filedescriptor Functions * AUTHOR: Duane Wessels @@ -151,6 +151,7 @@ F->type = type; F->flags.open = 1; #ifdef _SQUID_MSWIN_ + F->win32.handle = _get_osfhandle(fd); switch (type) { case FD_SOCKET: case FD_PIPE: Index: squid/src/structs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/structs.h,v retrieving revision 1.48.6.19 retrieving revision 1.48.6.20 diff -u -r1.48.6.19 -r1.48.6.20 --- squid/src/structs.h 7 Aug 2003 07:27:57 -0000 1.48.6.19 +++ squid/src/structs.h 17 Aug 2003 12:14:06 -0000 1.48.6.20 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.48.6.19 2003/08/07 07:27:57 serassio Exp $ + * $Id: structs.h,v 1.48.6.20 2003/08/17 12:14:06 serassio Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -802,6 +802,11 @@ SSL *ssl; int ssl_shutdown:1; #endif +#ifdef _SQUID_MSWIN_ +struct { + long handle; + } win32; +#endif }; struct _fileMap {