--------------------- PatchSet 982 Date: 2000/12/22 12:41:25 Author: nikitadanilov Branch: raid Tag: (none) Log: Ciociosan initialization separated into two pieces. Checks for fd and bitmap validness inserted. Nasty bug with lostIOBitmap allocation corrected: lostIOBitmap was allocated with enough sizeof (long long) chunks to accomodate for Biggest_FD files. Under light load this worked ok, but started to crash in random places as number of active fds grew. Fortunately, some glibc list (tzstring_list) was allocated right after lostIOBitmap. This list is traversed on each call to localtime(), in particular from each _db_print. This allowed find error rather quickly. As lostIOBitmap have to be allocated rather early, one cannot relay on Squid_MaxFD to be correct and SQUID_MAXFD is used in stead. Members: src/comm_cio.c:1.1.2.1.2.1->1.1.2.1.2.2 Index: squid/src/comm_cio.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/comm_cio.c,v retrieving revision 1.1.2.1.2.1 retrieving revision 1.1.2.1.2.2 diff -u -r1.1.2.1.2.1 -r1.1.2.1.2.2 --- squid/src/comm_cio.c 17 Dec 2000 14:36:23 -0000 1.1.2.1.2.1 +++ squid/src/comm_cio.c 22 Dec 2000 12:41:25 -0000 1.1.2.1.2.2 @@ -1,5 +1,5 @@ /* - * $Id: comm_cio.c,v 1.1.2.1.2.1 2000/12/17 14:36:23 hno Exp $ + * $Id: comm_cio.c,v 1.1.2.1.2.2 2000/12/22 12:41:25 nikitadanilov Exp $ * * DEBUG: section 90 Signal-driven network IO * AUTHOR: Nikita Danilov @@ -238,6 +238,30 @@ /** initialize Cio Cio San */ int initCommCio() { + /* prepare global data structures */ + memset( callbacks, 0, sizeof callbacks ); + sigemptyset( &listenOn ); + statCounter.syscalls.async.signals = 0; + statCounter.syscalls.async.read_sigs = 0; + statCounter.syscalls.async.write_sigs = 0; + statCounter.syscalls.async.loops = 0; + statCounter.syscalls.async.avg_ready_read = 0.0; + statCounter.syscalls.async.avg_ready_write = 0.0; + statCounter.syscalls.async.tail_reads = 0; + statCounter.syscalls.async.tail_writes = 0; + statCounter.syscalls.async.drain_reads = 0; + statCounter.syscalls.async.drain_writes = 0; + + lostIOBitmap = + xcalloc( SQUID_MAXFD / sizeof lostIOBitmap[ 0 ] / 8 + 1, + sizeof lostIOBitmap[ 0 ] ); + assert( lostIOBitmap != NULL ); + commCioAddCB( SIGCIOCIOSAN, cioStdCallback ); + return 1; +} + +int initCommCio2() +{ #if !defined( CIOCIOSAN_USE_SIGHANDLER ) int i; @@ -277,29 +301,13 @@ /* CIOCIOSAN_USE_SIGHANDLER */ #endif - /* prepare global data structures */ - memset( callbacks, 0, sizeof callbacks ); - sigemptyset( &listenOn ); - statCounter.syscalls.async.signals = 0; - statCounter.syscalls.async.read_sigs = 0; - statCounter.syscalls.async.write_sigs = 0; - statCounter.syscalls.async.loops = 0; - statCounter.syscalls.async.avg_ready_read = 0.0; - statCounter.syscalls.async.avg_ready_write = 0.0; - statCounter.syscalls.async.tail_reads = 0; - statCounter.syscalls.async.tail_writes = 0; - statCounter.syscalls.async.drain_reads = 0; - statCounter.syscalls.async.drain_writes = 0; - - lostIOBitmap = - xcalloc( Biggest_FD / sizeof lostIOBitmap[ 0 ] / 8 + 1, - sizeof lostIOBitmap[ 0 ] ); - commCioAddCB( SIGCIOCIOSAN, cioStdCallback ); return 1; } static void processOneSiginfo( siginfo_t *info ) { + CHECK_FD( info -> si_fd ); + if( callbacks[ info -> si_signo ] != NULL ) { if( fd_table[ info -> si_fd ].flags.async_tcp ) @@ -422,6 +430,8 @@ { fde *F = &fd_table[fd]; + CHECK_FD( fd ); + if( F->defer_check == NULL ) { return 0; @@ -440,6 +450,8 @@ { int j; + CHECK_FD( fd ); + for( j = 0 ; j < NHttpSockets ; j++ ) { if( fd == HttpSockets[ j ] ) @@ -452,16 +464,22 @@ static inline int fdIsIcp( int fd ) { + CHECK_FD( fd ); + return( ( fd == theInIcpConnection ) || ( fd == theOutIcpConnection ) ); } static inline int fdIsDns( int fd ) { + CHECK_FD( fd ); + return( fd == DnsSocket ); } static int inline isDatalessSocket( int fd ) { + CHECK_FD( fd ); + return( fdIsHttp( fd ) || fdIsIcp( fd ) || fdIsDns( fd ) ); } @@ -471,7 +489,7 @@ PF *handler; int dummy; - assert( ( 0 <= index ) && ( index <= Biggest_FD ) ); + CHECK_FD( index ); assert( fd_table[ index ].flags.can_read ); F = &fd_table[ index ]; @@ -490,7 +508,7 @@ PF *handler; int dummy; - assert( ( 0 <= index ) && ( index <= Biggest_FD ) ); + CHECK_FD( index ); assert( fd_table[ index ].flags.can_write ); F = &fd_table[ index ]; @@ -513,6 +531,7 @@ fd = info -> si_fd; f = &fd_table[ fd ]; + CHECK_FD( fd ); assert( fd >= 0 ); assert( f -> flags.open ); @@ -590,6 +609,7 @@ } F = &fd_table[ i ]; + CHECK_FD( i ); /* skip internal descriptors */ @@ -630,11 +650,19 @@ void clearLostIOBitmap( int fd ) { + assert( lostIOBitmap != NULL ); CLN_BIT_IN_BITMAP( fd ); } void setLostIOBitmap( int fd ) { + assert( lostIOBitmap != NULL ); + debug( 91, 9 )( "setLostIOBitmap: fd: %i, index: %i, " + "offset: %i, mask: %x, bitmap: %p\n", + ( int )fd, + ( int ) INDEX_IN_BITMAP( fd ), + ( int ) OFFSET_IN_BYTE( fd ), + ( int ) MASK_IN_BITMAP( fd ), lostIOBitmap ); SET_BIT_IN_BITMAP( fd ); } @@ -648,6 +676,19 @@ /* * $Log: comm_cio.c,v $ + * Revision 1.1.2.1.2.2 2000/12/22 12:41:25 nikitadanilov + * Ciociosan initialization separated into two pieces. + * Checks for fd and bitmap validness inserted. + * Nasty bug with lostIOBitmap allocation corrected: + * lostIOBitmap was allocated with enough sizeof (long long) chunks to + * accomodate for Biggest_FD files. Under light load this worked ok, but started + * to crash in random places as number of active fds grew. Fortunately, some + * glibc list (tzstring_list) was allocated right after lostIOBitmap. This list + * is traversed on each call to localtime(), in particular from each _db_print. + * This allowed find error rather quickly. As lostIOBitmap have to be allocated + * rather early, one cannot relay on Squid_MaxFD to be correct and SQUID_MAXFD is + * used in stead. + * * Revision 1.1.2.1.2.1 2000/12/17 14:36:23 hno * Imported raid from squidng *