On 10/30/01(16:01) you "Mike State" <pmycqbdyi-2pim4lyk2stw.ml@delegate.org> wrote in <_A1382@delegate-en.ML_> |I'm using the TCPRELAY to connect a client to a server and am wondering |if the TIMEOUT=io:90 will timeout in both directions? In otherwords, |will it timeout if either side is inactive for 90 seconds or do both |sides need to be inactive for the connection to timeout. [Manual.htm] > io -- general I/O (no data transmission) [600] TIMEOUT=io specify the generic timeout caused when no data tranmission is done via DeleGate in the period. Thus when relaying between a client and a server, it timeouts when no transmission is done from both sides. |I need to make |sure that if either side doesn't respond in 90 seconds that the |connection is dropped, regardless of the other side still trying to pass |data. Is this possible? Since most of application protocols relayed by DeleGate are of "question/answer" or "request/response" type, simple TIMEOUT=io like above has been sufficient for use. But I suppose some kind of symmetric protocols, Telnet for example, might have to be controlled as you requested. So I made a tentative extension to cause timeout when either client or server is silent for specified period by TIMEOUT=silent. Two files were modified like enclosed patch, and it is applicable only to SERVER=tcprelay. Cheers, Yutaka -- @ @ Yutaka Sato <pfqcabdyi-2pim4lyk2stw.ml@delegate.org> http://www.delegate.org/y.sato/ ( - ) National Institute of Advanced Industrial Science and Technology (AIST) _< >_ 1-1-4 Umezono, Tsukuba, Ibaraki, 305-8568 Japan diff -cr ../delegate7.6.0/rary/nbio.c ./rary/nbio.c *** ../delegate7.6.0/rary/nbio.c Tue Jun 13 16:51:16 2000 --- ./rary/nbio.c Wed Oct 31 02:24:07 2001 *************** *** 263,268 **** --- 263,270 ---- #define IGN_EOF 1 int RELAYS_IGNEOF; + int SILENCE_TIMEOUT; + relaysx(timeout,sdc,sdv,sdx,rccs,funcv,argv) int sdv[][2]; int sdx[]; *************** *** 278,284 **** --- 280,292 ---- IFUNC funcvb[32]; char *argvb[32]; int nready; + double Lastin[32],Now,Timeout,Idlest,Time(); + int timeouti; + if( SILENCE_TIMEOUT ) + syslog_ERROR("relays(%d) start: TIMEOUT=io:%ds,silence:%ds\n", + sdc,timeout/1000,SILENCE_TIMEOUT); + else syslog_ERROR("relays(%d) start: timeout=%dmsec\n",sdc,timeout); if( funcv == NULL ){ *************** *** 292,302 **** --- 300,312 ---- argv[fi] = NULL; } + Now = Time(); for( fi = 0; fi < sdc; fi++ ){ fds[fi] = sdv[fi][0]; errv[fi] = 0; rccs[fi] = 0; cntv[fi] = 0; + Lastin[fi] = Now; if( funcv[fi] == NULL ) funcv[fi] = relay1; *************** *** 313,330 **** --- 323,354 ---- for(;;){ pc = 0; + Idlest = Now = Time(); for( fi = 0; fi < sdc; fi++ ){ if( errv[fi] == 0 ){ pfv[pc] = fds[fi]; pxv[pc] = fi; pc++; } + if( Lastin[fi] < Idlest ){ + Idlest = Lastin[fi]; + } } if( pc == 0 ) break; errno = 0; + if( SILENCE_TIMEOUT ){ + timeouti = 1000*(SILENCE_TIMEOUT - (Now-Idlest)); + if( timeouti <= 0 ) + break; + if( timeouti <= timeout ){ + nready = PollIns(timeouti,pc,pfv,rfds); + goto POLLED; + } + } nready = PollIns(timeout,pc,pfv,rfds); + POLLED: if( nready == 0 && errno == 0 ){ int fi,sync; *************** *** 348,353 **** --- 372,378 ---- if( 0 < rfds[pi] ){ fi = pxv[pi]; rcode = (*funcv[fi])(argv[fi],sdv[fi][0],sdv[fi][1],&rcc,&wcc); + Lastin[fi] = Time(); rccs[fi] += wcc; cntv[fi] += 1; if( rcode <= 0 ){ diff -cr ../delegate7.6.0/src/service.c ./src/service.c *** ../delegate7.6.0/src/service.c Wed Oct 24 07:01:52 2001 --- ./src/service.c Wed Oct 31 01:54:04 2001 *************** *** 1962,1967 **** --- 1962,1968 ---- extern double HTTP_TOUT_CKA; extern double HTTP_TOUT_CKA_MARGIN; extern int RSLV_INV_TIMEOUT; + extern int SILENCE_TIMEOUT; /* no transmission from server or client */ extern double Scan_period(); static timeout1(to) *************** *** 1981,1986 **** --- 1982,1988 ---- if( streq(name,"con") ) CON_TIMEOUT = secs; else if( streq(name,"lin") ) LIN_TIMEOUT = secs; else if( streq(name,"ident")) IDENT_TIMEOUT = secs; else + if( streq(name,"silence")) SILENCE_TIMEOUT = secs; else if( streq(name,"io") ) IO_TIMEOUT = secs; else if( streq(name,"idle")) IO_TIMEOUT = secs; else if( streq(name,"restart")) SERVER_RESTART = secs; else