Hi, I uploaded 9.2.3-pre4 coping with these problems around CFI on Windows. In message <_A3320@delegate-en.ML_> on 06/22/06(00:33:02) you "Xavier Cheney" <p2mgabdyi-mxhgu47df33w.ml@delegate.org> wrote: | I use DeleGate 9.2.3-pre1 under Windows like a proxy to filter web pages. | I made test on localhost, with a small sample (1 CSS and 3 pictures). | When I add the option FTOCL=filter.cfi, the page takes time to appear in |the browser, specialy when there's many links (pictures, ...). In the |filter.cfi I only do text/html replacement. It has been in the TODO list for more than ten years since I prototyped CFIscript in DeleGate/3.0.11 (in 1996) to suppression the invokacaiton of the CFIscript interpreter process when it is not necessary by the condition in the CFIscript. So I prototyped it at last (in "http.c") | My first analyse let me show that when there's filtering option : | - there's many more delegated processes running An extra process named "pre-filter" is inserted on Windows to relay from/to a pipe to/from a socket. FTOCL DeleGate -----> program -----> pre-filter -----> client pipe pipe socket This is necessary because a program on Windows cannot use a socket as its "standard input" nor "standard output". Thus DeleGate chains the program with pipe (which can be used for standard I/O) and relays the pipe on client/server side to the socket. But this is not necessary for CFIscript because the CFIscript interpreter is made by DeleGate which can use socket as its standard I/O. CFI-srcipt | FTOCL DeleGate -----> CFI-sci -----> client pipe | | socket | | program I'm not so sure if this modification does not causes any side effect but at least it should be like this from the viewpoint of the performance, so I'll modify it so (in "filter.c"). | - there's errors "### ERROR: select() applied to non-SOCKET handle" on |child processes It is the warning from the CFIscript interpreter on Windows which does only support select() for socket. In this case, the input is not a socket but a pipe (from DeleGate). The warning should be suppressed if it is confirmed to be not harmful. | - the processes between "REQUEST = [http://domain] GET /img.gif |HTTP/1.1" and "#HT11 ..." takes long time (300-400ms) I observed that each spawn() of DeleGate process tries "loadDefaultConf()" on Windows, consuming a certain amount of time totally in vain, since ver. 8.9.6. So I suppressed it (in "delegated.c"). | Is it possible to have "shorter time display" : | - by a delegate patch ? The "patch" for 9.2.3-pre4 about this issue is enclosed. | - by delegate options ? These modifications except the one for "delegated.c" might be optional in the 9.2.3 but they are default in pre-release versions for a while. Cheers, Yutaka -- D G Yutaka Sato <pfqcabdyi-mxhgu47df33w.ml@delegate.org> http://delegate.org/y.sato/ ( - ) National Institute of Advanced Industrial Science and Technology _< >_ 1-1-4 Umezono, Tsukuba, Ibaraki, 305-8568 Japan Do the more with the less -- B. Fuller diff -cr arc/delegate9.2.3-pre3/src/delegated.c cc/src/delegated.c *** arc/delegate9.2.3-pre3/src/delegated.c Sun Jun 18 16:07:49 2006 --- cc/src/delegated.c Thu Jun 22 14:13:52 2006 *************** *** 4309,4314 **** --- 4309,4317 ---- /* loadDefaultConf(); */ + if( av[0] && DeleGate1 && streq(av[0],DeleGate1) ){ + /* don't apply the default .conf to child-processes (8.9.6) */ + }else loadDefaultConf(ac,av); for( ai = 0; ai < ac; ai++ ){ diff -cr arc/delegate9.2.3-pre3/src/filter.c cc/src/filter.c *** arc/delegate9.2.3-pre3/src/filter.c Wed Jun 21 01:36:23 2006 --- cc/src/filter.c Thu Jun 22 14:17:51 2006 *************** *** 105,110 **** --- 105,112 ---- #define CFIMAGIC "#!cfi" #define isCFI(filter) (strncmp(filter,CFIMAGIC,strlen(CFIMAGIC)) == 0) + int IsCFI(PCStr(filter)){ return filter?isCFI(filter):0; } + int filter_isCFI(int which) { const char *filter; *************** *** 1923,1928 **** --- 1925,1941 ---- if( HTTP_isMethod(buff) ) strcpy(DFLT_PROTO,"http"); } + } + + /* 9.2.3 pre-filter / post-filter to relay between the pipe + * (as the standard I/O of a filter program) with the client's/server's + * socket is not necessary with CFI (to be regarded as IS_BUILTIN()) + */ + if( isCFI(filter) ) + if( fntoi(what) == F_TOCL ) + { + Verbose("## %s don't insert pre-filter for CFI\n",what); + return forkexecFilter1X(Conn,src,dst,what,iomode,isresp,filter,NULL); } if( filters[fntoi(what)].f_push ){ diff -cr arc/delegate9.2.3-pre3/src/http.c cc/src/http.c *** arc/delegate9.2.3-pre3/src/http.c Sun Jun 18 00:08:25 2006 --- cc/src/http.c Thu Jun 22 14:22:30 2006 *************** *** 2786,2791 **** --- 2786,2833 ---- putProxyCookie(Conn,RX_tcp,RX_code,rhead); } + int IsCFI(PCStr(filter)); + int copyHeader(PVStr(dst),PCStr(src),int eos); + const char *searchSpec(PCStr(conni),PCStr(specs),PCStr(stat),PCStr(head)); + static FILE *insertFTOCL_X(Connection *Conn,FILE *tc); + FILE *CFI_insertFTOCL(Connection *Conn,FILE *atc,PCStr(rhead)){ + const char *CFIscript; + CStr(conninfo,2048); + CStr(stat,128); + CStr(headb,1024); + const char *head; + const char *hx; + const char *spec; + + if( Conn->xf_filters & XF_FTOCL ) + return atc; + + if( sav_FTOCL && IsCFI(sav_FTOCL) ){ + CFIscript = sav_FTOCL; + make_conninfo(Conn,AVStr(conninfo)); + head = lineScan(rhead,stat); + if( *head == '\r' ) head++; + if( *head == '\n' ) head++; + if( hx = strSeekEOH(head) ){ + QStrncpy(headb,head,hx-head+1); + head = headb; + } + spec = searchSpec(conninfo,CFIscript,stat,head); + if( spec == 0 ){ + Verbose("No filter in #!cfi to be applied.\n"); + return atc; + }else{ + Verbose("Found a filter in #!cfi to be applied.\n"); + } + } + + if( sav_FTOCL ) + setFTOCL(sav_FTOCL); + atc = insertFTOCL_X(Conn,atc); + setFTOCL(NULL); + return atc; + } + char *HTTP_thruType = "application/zip,application/x-rpm"; int relay_responseX(Connection *Conn,QueryContext *QX,int cpid,PCStr(proto),PCStr(server),int iport,PCStr(req),PCStr(acpath),int fromcache, FILE *afs,FILE *atc,FILE *afc,FILE *acachefp,int cache_rdok, ResponseContext *RX,PVStr(refbuf)) { Referer refererb; *************** *** 2921,2926 **** --- 2963,2969 ---- RESP_DoZIP = 0; } } + atc = CFI_insertFTOCL(Conn,atc,rhead); RX_Conn = Conn; RX_QX = QX; *************** *** 7040,7045 **** --- 7083,7092 ---- if( checkCookie(Conn /*,QX,fc,tc*/) < 0 ) goto EXIT; + if( (Conn->xf_filters & XF_FTOCL) == 0 ) + if( sav_FTOCL && IsCFI(sav_FTOCL) ){ + Verbose("Delay #!cfi insertion\n"); + }else if( (Conn->xf_filters & XF_FTOCL) == 0 ){ if( sav_FTOCL ) setFTOCL(sav_FTOCL);