Article delegate-en/527 of [1-5169] on the server localhost:119
  upper oldest olders older1 this newer1 newers latest
search
[Top/Up] [oldest] - [Older+chunk] - [Newer+chunk] - [newest + Check]
[Reference:<_A526@delegate-en.ML_>]
Newsgroups: mail-lists.delegate-en

[DeleGate-En] Re: Sync error?
23 Jul 1999 08:39:59 GMT ysato@etl.go.jp (Yutaka Sato)


Hi,

In message <_A526@delegate-en.ML_> on 07/23/99(18:19:00)
you po4aabdyi-uwzfqiqk6zxr.ml@ml.delegate.org (Oliver Hertel) wrote:
 |May be that delegate has an sync error when starting more than one
 |'get'-processes?
 |
 |I use delegate as filter for incoming web pages. Sometimes I get the
 |banner image of a page on more that one locations on that web page
 |where other images should be etc.

The problem might be caused by a temporary file (for response message)
which is accidentally shared among DeleGate processes.  I've fixed the
bug in DeleGate/6.0.0 which will be released by the end of this summer...
Enclosed patch for src/http.c of DeleGate/5.9.3 may be useful till the
next release.

Cheers,
Yutaka
--
Yutaka Sato <ysato@etl.go.jp> http://www.etl.go.jp/~ysato/   @ @ 
Computer Science Division, Electrotechnical Laboratory      ( - )
1-1-4 Umezono, Tsukuba, Ibaraki, 305-8568 Japan            _<   >_


*** ../../delegate5.9.3/src/http.c	Tue Jun 22 16:31:41 1999
--- http.c	Fri Jul 23 17:32:43 1999
***************
*** 1566,1572 ****
  static int emulateNCSA;
  
  extern FILE *TMPFILE();
- static int respBuffer = -1;
  HTTP_putMIMEmsg(Conn,in,out)
  	Connection *Conn;
  	FILE *in,*out;
--- 1566,1571 ----
***************
*** 1777,1782 ****
--- 1776,1783 ----
  	}
  }
  
+ extern FILE *getTmpFile();
+ static char *HttpRespTmpFile = "HTTP-respBuff";
  static relay_response(Conn,cpid,proto,server,iport,req,cpath,fromcache,
  fs,tc,fc,cachefp,cache_rdok)
  	Connection *Conn;
***************
*** 2085,2097 ****
  	if( !nobody && !oldver && WithHeader )
  	if( withConversion(Conn,0)
  	 || WillKeepAlive && (!fromcache || fromcache && !HTTP_ContLengOk(fs)) ){
! 		if( respBuffer < 0 ){
! 			respBuff = TMPFILE("HTTP-respBuff");
! 			respBuffer = dup(fileno(respBuff));
! 		}else{
! 			respBuff = fdopen(dup(respBuffer),"r+");
! 			fseek(respBuff,0,0);
! 		}
  		tc_sav = tc;
  		tc = respBuff;
  		tcd = -1;
--- 2086,2092 ----
  	if( !nobody && !oldver && WithHeader )
  	if( withConversion(Conn,0)
  	 || WillKeepAlive && (!fromcache || fromcache && !HTTP_ContLengOk(fs)) ){
! 		respBuff = getTmpFile(HttpRespTmpFile,Conn);
  		tc_sav = tc;
  		tc = respBuff;
  		tcd = -1;
***************
*** 2505,2512 ****
  		}else{
  			sv1log("## HTTP RESPONSE CLOSE: NO (client dead)\n");
  			setClientEOF(Conn,tc,"flush_respbuff.FAILED");
! 			close(respBuffer);
! 			respBuffer = -1;
  		}
  		fclose(tc);
  		tc = tc_sav;
--- 2500,2506 ----
  		}else{
  			sv1log("## HTTP RESPONSE CLOSE: NO (client dead)\n");
  			setClientEOF(Conn,tc,"flush_respbuff.FAILED");
! 			freeTmpFile(HttpRespTmpFile,Conn);
  		}
  		fclose(tc);
  		tc = tc_sav;
***************
*** 4376,4378 ****
--- 4370,4419 ----
  	fclose(fp);
  }
  
+ /*
+  * the following stuff is in rary/file.c in DeleGate/6.0,
+  * it is here just to simplify the patch for older versions (5.9)
+  */
+ static int tmpFileFd = -1;
+ static int tmpFilePid = -1;
+ static char *tmpFileWhat = "";
+ 
+ freeTmpFile(what)
+ 	char *what;
+ {
+ 	if( 0 <= tmpFileFd ){
+ 		close(tmpFileFd);
+ 		tmpFileFd = -1;
+ 		tmpFilePid = -1;
+ 		tmpFileWhat = "";
+ 	}
+ }
+ FILE *getTmpFile(what)
+ 	char *what;
+ {	FILE *fp;
+ 	int pid;
+ 	char msg[1024];
+ 
+ 	pid = getpid();
+ 	sprintf(msg,"getTmpFile: fd=%d [%d]%s->[%d]%s",
+ 		tmpFileFd,tmpFilePid,tmpFileWhat,pid,what);
+ 
+ 	if( 0 < tmpFileFd ){
+ 		if( tmpFilePid != pid || tmpFileWhat != what ){
+ 			syslog_ERROR("#### %s\n",msg);
+ 			tmpFileFd = -1;
+ 			freeTmpFile(what);
+ 		}
+ 	}
+ 	syslog_DEBUG("%s\n",msg);
+ 	if( tmpFileFd < 0 ){
+ 		fp = TMPFILE(what);
+ 		tmpFileFd = dup(fileno(fp));
+ 		tmpFilePid = pid;
+ 		tmpFileWhat = what;
+ 	}else{
+ 		fp = fdopen(dup(tmpFileFd),"r+");
+ 		fseek(fp,0,0);
+ 	}
+ 	return fp;
+ }

  admin search upper oldest olders older1 this newer1 newers latest
[Top/Up] [oldest] - [Older+chunk] - [Newer+chunk] - [newest + Check]
@_@V