--------------------- PatchSet 886 Date: 2003/08/17 19:17:38 Author: serassio Branch: nt Tag: (none) Log: Forward port of 2.5 win32 select() loop optimization Members: port/win32/include/squid-mswin.h:1.3.18.7->1.3.18.8 src/comm_select.cc:1.9.2.5->1.9.2.6 src/fd.cc:1.6.2.1->1.6.2.2 src/fde.h:1.3.2.3->1.3.2.4 Index: squid3/port/win32/include/squid-mswin.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/port/win32/include/Attic/squid-mswin.h,v retrieving revision 1.3.18.7 retrieving revision 1.3.18.8 diff -u -r1.3.18.7 -r1.3.18.8 --- squid3/port/win32/include/squid-mswin.h 17 Aug 2003 18:17:44 -0000 1.3.18.7 +++ squid3/port/win32/include/squid-mswin.h 17 Aug 2003 19:21:03 -0000 1.3.18.8 @@ -1,5 +1,5 @@ /* - * $Id: squid-mswin.h,v 1.3.18.7 2003/08/17 18:17:44 serassio Exp $ + * $Id: squid-mswin.h,v 1.3.18.8 2003/08/17 19:21:03 serassio Exp $ * * AUTHOR: Guido Serassio & Andrey Shorin * @@ -537,15 +537,16 @@ } inline -int setsockopt(SOCKET s, int l, int o, const void * v, int n) +int setsockopt(SOCKET s, int l, int o, const char * v, int n) { - if (::setsockopt(_get_osfhandle(s), l, o, (const char *)v, n) == SOCKET_ERROR) { + if (::setsockopt(_get_osfhandle(s), l, o, v, n) == SOCKET_ERROR) { errno = WSAGetLastError(); return -1; } else return 0; } +#define setsockopt(s,l,o,v,n) Squid::setsockopt(s,l,o,v,n) inline int shutdown(int s, int h) Index: squid3/src/comm_select.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/comm_select.cc,v retrieving revision 1.9.2.5 retrieving revision 1.9.2.6 diff -u -r1.9.2.5 -r1.9.2.6 --- squid3/src/comm_select.cc 8 Jul 2003 16:57:52 -0000 1.9.2.5 +++ squid3/src/comm_select.cc 17 Aug 2003 19:17:38 -0000 1.9.2.6 @@ -1,6 +1,6 @@ /* - * $Id: comm_select.cc,v 1.9.2.5 2003/07/08 16:57:52 serassio Exp $ + * $Id: comm_select.cc,v 1.9.2.6 2003/08/17 19:17:38 serassio Exp $ * * DEBUG: section 5 Socket Functions * @@ -439,16 +439,19 @@ 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 ( static_cast(_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; @@ -548,7 +551,7 @@ 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); @@ -586,11 +589,15 @@ assert(pendingfds.fd_count <= (unsigned int) Biggest_FD); for (j = 0; j < (int) readfds.fd_count; j++) { + 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 (( static_cast(_get_osfhandle(fd)) == readfds.fd_array[j] ) || - ( static_cast(_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; @@ -683,8 +690,9 @@ 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 ( static_cast(_get_osfhandle(fd)) == errfds.fd_array[j] ) + if ( fd_table[fd].win32.handle == errfds_handle ) break; } @@ -703,10 +711,11 @@ 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 ( static_cast(_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: squid3/src/fd.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/fd.cc,v retrieving revision 1.6.2.1 retrieving revision 1.6.2.2 diff -u -r1.6.2.1 -r1.6.2.2 --- squid3/src/fd.cc 9 Aug 2003 07:46:03 -0000 1.6.2.1 +++ squid3/src/fd.cc 17 Aug 2003 19:17:38 -0000 1.6.2.2 @@ -1,6 +1,6 @@ /* - * $Id: fd.cc,v 1.6.2.1 2003/08/09 07:46:03 serassio Exp $ + * $Id: fd.cc,v 1.6.2.2 2003/08/17 19:17:38 serassio Exp $ * * DEBUG: section 51 Filedescriptor Functions * AUTHOR: Duane Wessels @@ -165,6 +165,7 @@ F->flags.open = 1; #ifdef _SQUID_MSWIN_ + F->win32.handle = _get_osfhandle(fd); switch (type) { case FD_SOCKET: Index: squid3/src/fde.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/fde.h,v retrieving revision 1.3.2.3 retrieving revision 1.3.2.4 diff -u -r1.3.2.3 -r1.3.2.4 --- squid3/src/fde.h 16 Jul 2003 08:09:09 -0000 1.3.2.3 +++ squid3/src/fde.h 17 Aug 2003 19:17:38 -0000 1.3.2.4 @@ -1,6 +1,6 @@ /* - * $Id: fde.h,v 1.3.2.3 2003/07/16 08:09:09 serassio Exp $ + * $Id: fde.h,v 1.3.2.4 2003/08/17 19:17:38 serassio Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -120,6 +120,17 @@ int ssl_shutdown: 1; #endif +#ifdef _SQUID_MSWIN_ + + struct + { + + long handle; + } + + win32; +#endif + }; #endif /* SQUID_FDE_H */