Branch: Tag:

1996-11-11

1996-11-11 23:31:54 by Per Hedbor <ph@opera.com>

Ny version... HATA CVS ibland

Rev: .cvsignore:1.1.1.1
Rev: BUGS:1.1.1.1
Rev: CHANGES:1.1.1.1
Rev: COPYING:1.1.1.1
Rev: INSTALLING:1.1.1.1
Rev: Makefile.in:1.1.1.1
Rev: README:1.1.1.1
Rev: TODO:1.1.1.1
Rev: configure.in:1.1.1.1
Rev: extern/.cvsignore:1.1.1.1
Rev: extern/Makefile.in:1.1.1.1
Rev: extern/README:1.1.1.1
Rev: extern/cgi.c:1.1.1.1
Rev: extern/configure.in:1.1.1.1
Rev: extern/fast_cgi/LICENSE.TERMS:1.1.1.1
Rev: extern/fast_cgi/Makefile.in:1.1.1.1
Rev: extern/fast_cgi/README:1.1.1.1
Rev: extern/fast_cgi/acconfig.h:1.1.1.1
Rev: extern/fast_cgi/cgi-fcgi/Makefile.in:1.1.1.1
Rev: extern/fast_cgi/cgi-fcgi/cgi-fcgi.c:1.1.1.1
Rev: extern/fast_cgi/configure.in:1.1.1.1
Rev: extern/fast_cgi/include/fastcgi.h:1.1.1.1
Rev: extern/fast_cgi/include/fcgi_stdio.h:1.1.1.1
Rev: extern/fast_cgi/include/fcgiapp.h:1.1.1.1
Rev: extern/fast_cgi/include/fcgiappmisc.h:1.1.1.1
Rev: extern/fast_cgi/include/fcgimisc.h:1.1.1.1
Rev: extern/fast_cgi/libfcgi/Makefile.in:1.1.1.1
Rev: extern/fast_cgi/libfcgi/fcgi_stdio.c:1.1.1.1
Rev: extern/fast_cgi/libfcgi/fcgiapp.c:1.1.1.1
Rev: extern/fast_cgi/libfcgi/strerror.c:1.1.1.1
Rev: extern/roxen_hostname.c:1.1.1.1
Rev: extern/shuffle.c:1.1.1.1
Rev: extern/ssl.c:1.1.1.1
Rev: install-sh:1.1.1.1
Rev: mkdir:1.1.1.1
Rev: pike/.cvsignore:1.1.1.1
Rev: pike/Makefile.in:1.1.1.1
Rev: pike/README:1.1.1.1
Rev: pike/ROXEN_PIKE_BASE:1.1.1.1
Rev: pike/configure.in:1.1.1.1
Rev: server/base_server/cache.pike:1.1.1.1
Rev: server/base_server/config/builders.pike:1.1.1.1
Rev: server/base_server/config/describers.pike:1.1.1.1
Rev: server/base_server/config/low_describers.pike:1.1.1.1
Rev: server/base_server/config/savers.pike:1.1.1.1
Rev: server/base_server/configuration.pike:1.1.1.1
Rev: server/base_server/db.pike:1.1.1.1
Rev: server/base_server/disk_cache.pike:1.1.1.1
Rev: server/base_server/dummy_hosts.pike:1.1.1.1
Rev: server/base_server/hosts.pike:1.1.1.1
Rev: server/base_server/html.pike:1.1.1.1
Rev: server/base_server/http.pike:1.1.1.1
Rev: server/base_server/language.pike:1.1.1.1
Rev: server/base_server/lock.pike:1.1.1.1
Rev: server/base_server/mainconfig.pike:1.1.1.1
Rev: server/base_server/module.pike:1.1.1.1
Rev: server/base_server/module_support.pike:1.1.1.1
Rev: server/base_server/newdecode.pike:1.1.1.1
Rev: server/base_server/persistent.pike:1.1.1.1
Rev: server/base_server/proxyauth.pike:1.1.1.1
Rev: server/base_server/read_config.pike:1.1.1.1
Rev: server/base_server/roxen.pike:1.1.1.1
Rev: server/base_server/roxenlib.pike:1.1.1.1
Rev: server/base_server/roxenloader.pike:1.1.1.1
Rev: server/base_server/socket.pike:1.1.1.1
Rev: server/base_server/spinnerlib.pike:1.1.1.1
Rev: server/base_server/struct/ftp_gateway_request.pike:1.1.1.1
Rev: server/base_server/struct/node.pike:1.1.1.1
Rev: server/bin/.cvsignore:1.1.1.1
Rev: server/bin/garbagecollector.pike:1.1.1.1
Rev: server/bin/install.pike:1.1.1.1
Rev: server/configvar:1.1.1.1
Rev: server/etc/config.html:1.1.1.1
Rev: server/etc/extensions:1.1.1.1
Rev: server/etc/include/array.h:1.1.1.1
Rev: server/etc/include/array.pre.pike:1.1.1.1
Rev: server/etc/include/config.h:1.1.1.1
Rev: server/etc/include/confignode.h:1.1.1.1
Rev: server/etc/include/fifo.h:1.1.1.1
Rev: server/etc/include/fifo.pre.pike:1.1.1.1
Rev: server/etc/include/getopt.h:1.1.1.1
Rev: server/etc/include/getopt.pre.pike:1.1.1.1
Rev: server/etc/include/module.h:1.1.1.1
Rev: server/etc/include/process.h:1.1.1.1
Rev: server/etc/include/process.pre.pike:1.1.1.1
Rev: server/etc/include/roxen.h:1.1.1.1
Rev: server/etc/include/simulate.h:1.1.1.1
Rev: server/etc/include/simulate.pre.pike:1.1.1.1
Rev: server/etc/include/stat.h:1.1.1.1
Rev: server/etc/include/stdio.h:1.1.1.1
Rev: server/etc/include/stdio.pre.pike:1.1.1.1
Rev: server/etc/include/string.h:1.1.1.1
Rev: server/etc/include/string.pre.pike:1.1.1.1
Rev: server/etc/include/syslog.h:1.1.1.1
Rev: server/etc/include/variables.h:1.1.1.1
Rev: server/etc/newconfig.html:1.1.1.1
Rev: server/etc/restart.html:1.1.1.1
Rev: server/etc/roxen_master.pike:1.1.1.1
Rev: server/etc/shutdown.html:1.1.1.1
Rev: server/etc/supports:1.1.1.1
Rev: server/etc/welcome.html:1.1.1.1
Rev: server/install:1.1.1.1
Rev: server/languages/catala.pike:1.1.1.1
Rev: server/languages/dutch.pike:1.1.1.1
Rev: server/languages/english.pike:1.1.1.1
Rev: server/languages/finnish.pike:1.1.1.1
Rev: server/languages/french.pike:1.1.1.1
Rev: server/languages/german.pike:1.1.1.1
Rev: server/languages/japanese.pike:1.1.1.1
Rev: server/languages/norwegian.pike:1.1.1.1
Rev: server/languages/spanish.pike:1.1.1.1
Rev: server/languages/swedish.pike:1.1.1.1
Rev: server/mkdir:1.1.1.1
Rev: server/modules/cgi.pike:1.1.1.1
Rev: server/modules/client_logger.pike:1.1.1.1
Rev: server/modules/connect.pike:1.1.1.1
Rev: server/modules/contenttypes.pike:1.1.1.1
Rev: server/modules/directories.pike:1.1.1.1
Rev: server/modules/fastdir.pike:1.1.1.1
Rev: server/modules/fcgi.pike:1.1.1.1
Rev: server/modules/filesystem.pike:1.1.1.1
Rev: server/modules/ftpgateway.pike:1.1.1.1
Rev: server/modules/gopher.pike:1.1.1.1
Rev: server/modules/header.pike:1.1.1.1
Rev: server/modules/home_logger.pike:1.1.1.1
Rev: server/modules/hostredirect.pike:1.1.1.1
Rev: server/modules/htaccess.pike:1.1.1.1
Rev: server/modules/htmlparse.pike:1.1.1.1
Rev: server/modules/indexfiles.pike:1.1.1.1
Rev: server/modules/indirect_href.pike:1.1.1.1
Rev: server/modules/ismap.pike:1.1.1.1
Rev: server/modules/language.pike:1.1.1.1
Rev: server/modules/lpcscript.pike:1.1.1.1
Rev: server/modules/lpctag.pike:1.1.1.1
Rev: server/modules/nologging.pike:1.1.1.1
Rev: server/modules/proxy.pike:1.1.1.1
Rev: server/modules/redirect.pike:1.1.1.1
Rev: server/modules/relay.pike:1.1.1.1
Rev: server/modules/secure_fs.pike:1.1.1.1
Rev: server/modules/tablist.pike:1.1.1.1
Rev: server/modules/userdb.pike:1.1.1.1
Rev: server/modules/userfs.pike:1.1.1.1
Rev: server/modules/variable.pike:1.1.1.1
Rev: server/modules/wais.pike:1.1.1.1
Rev: server/more_modules/bofh.pike:1.1.1.1
Rev: server/more_modules/clock.pike:1.1.1.1
Rev: server/more_modules/configure.pike:1.1.1.1
Rev: server/more_modules/lysator.pike:1.1.1.1
Rev: server/more_modules/tablify.pike:1.1.1.1
Rev: server/protocols/ftp.pike:1.1.1.1
Rev: server/protocols/gopher.pike:1.1.1.1
Rev: server/protocols/http.pike:1.1.1.1
Rev: server/protocols/ssl.pike:1.1.1.1
Rev: server/roxen-images/back.gif:1.1.1.1
Rev: server/roxen-images/background.jpg:1.1.1.1
Rev: server/roxen-images/changed.gif:1.1.1.1
Rev: server/roxen-images/delconf.gif:1.1.1.1
Rev: server/roxen-images/delmod.gif:1.1.1.1
Rev: server/roxen-images/delmodcop.gif:1.1.1.1
Rev: server/roxen-images/dir/binary.gif:1.1.1.1
Rev: server/roxen-images/dir/image.gif:1.1.1.1
Rev: server/roxen-images/dir/menu.gif:1.1.1.1
Rev: server/roxen-images/dir/sound.gif:1.1.1.1
Rev: server/roxen-images/dir/text.gif:1.1.1.1
Rev: server/roxen-images/dir/unknown.gif:1.1.1.1
Rev: server/roxen-images/fold.gif:1.1.1.1
Rev: server/roxen-images/fold2.gif:1.1.1.1
Rev: server/roxen-images/foldall.gif:1.1.1.1
Rev: server/roxen-images/infovav.gif:1.1.1.1
Rev: server/roxen-images/left.gif:1.1.1.1
Rev: server/roxen-images/newconf.gif:1.1.1.1
Rev: server/roxen-images/newmod.gif:1.1.1.1
Rev: server/roxen-images/off.gif:1.1.1.1
Rev: server/roxen-images/on.gif:1.1.1.1
Rev: server/roxen-images/power.gif:1.1.1.1
Rev: server/roxen-images/power_anim.gif:1.1.1.1
Rev: server/roxen-images/refresh.gif:1.1.1.1
Rev: server/roxen-images/restart.gif:1.1.1.1
Rev: server/roxen-images/right.gif:1.1.1.1
Rev: server/roxen-images/roxen.gif:1.1.1.1
Rev: server/roxen-images/save.gif:1.1.1.1
Rev: server/roxen-images/shutdown.gif:1.1.1.1
Rev: server/roxen-images/tablists/1.gif:1.1.1.1
Rev: server/roxen-images/tablists/10.gif:1.1.1.1
Rev: server/roxen-images/tablists/11.gif:1.1.1.1
Rev: server/roxen-images/tablists/12.gif:1.1.1.1
Rev: server/roxen-images/tablists/13.gif:1.1.1.1
Rev: server/roxen-images/tablists/14.gif:1.1.1.1
Rev: server/roxen-images/tablists/15.gif:1.1.1.1
Rev: server/roxen-images/tablists/16.gif:1.1.1.1
Rev: server/roxen-images/tablists/2.gif:1.1.1.1
Rev: server/roxen-images/tablists/3.gif:1.1.1.1
Rev: server/roxen-images/tablists/4.gif:1.1.1.1
Rev: server/roxen-images/tablists/5.gif:1.1.1.1
Rev: server/roxen-images/tablists/6.gif:1.1.1.1
Rev: server/roxen-images/tablists/7.gif:1.1.1.1
Rev: server/roxen-images/tablists/8.gif:1.1.1.1
Rev: server/roxen-images/tablists/9.gif:1.1.1.1
Rev: server/roxen-images/top.gif:1.1.1.1
Rev: server/roxen-images/unfold.gif:1.1.1.1
Rev: server/roxen-images/unfold2.gif:1.1.1.1
Rev: server/roxen-images/unmod.gif:1.1.1.1
Rev: server/roxen-images/up.gif:1.1.1.1
Rev: server/roxen-images/zap.gif:1.1.1.1
Rev: server/start:1.1.1.1
Rev: server/unfinishedmodules/deepthought.pike:1.1.1.1
Rev: server/unfinishedmodules/extended_logger.pike:1.1.1.1
Rev: server/unfinishedmodules/fastcgi.pike:1.1.1.1
Rev: server/unfinishedmodules/hedbor.pike:1.1.1.1
Rev: server/unfinishedmodules/httpc.lpc.gz:1.1.1.1
Rev: server/unfinishedmodules/javascript.pike:1.1.1.1
Rev: server/unfinishedmodules/mirror.lpc.gz:1.1.1.1
Rev: server/unfinishedmodules/mountserver.pike:1.1.1.1
Rev: server/unfinishedmodules/tree.pike:1.1.1.1
Rev: server/unfinishedmodules/whois++.pike:1.1.1.1
Rev: tools/Makefile:1.1.1.1
Rev: tools/accessed.lpc:1.1.1.1
Rev: tools/backlog-bumper:1.1.1.1
Rev: tools/htpasswd.c:1.1.1.1
Rev: tools/init.d_roxen:1.1.1.1
Rev: tools/xdumpfont/Makefile:1.1.1.1
Rev: tools/xdumpfont/README:1.1.1.1
Rev: tools/xdumpfont/banner.c:1.1.1.1
Rev: tools/xdumpfont/fontdemo.c:1.1.1.1
Rev: tools/xdumpfont/makefonts.lpc:1.1.1.1
Rev: tools/xdumpfont/readfont.c:1.1.1.1
Rev: tools/xdumpfont/readfont.h:1.1.1.1
Rev: tools/xdumpfont/xdumpfont.c:1.1.1.1

1: + #include <config.h>    -  + inherit "roxenlib"; +  + #define TIMESTAMP 0 + #define DATA 1 +  + #define ENTRY_SIZE 2 +  + #define CACHE_TIME_OUT 2000 +  + #if DEBUG_LEVEL > 8 + #ifndef CACHE_DEBUG + #define CACHE_DEBUG + #endif + #endif +  + mapping cache; + mapping hits=([]), all=([]); +  + mixed cache_lookup(string in, string what) + { + #ifdef CACHE_DEBUG +  perror(sprintf("CACHE: cache_lookup(\"%s\",\"%s\") -> ", in, what)); + #endif +  all[in]++; +  if(cache[in] && cache[in][what]) +  { + #ifdef CACHE_DEBUG +  perror("Hit\n"); + #endif +  hits[in]++; +  cache[in][what][TIMESTAMP]=time(0); +  return cache[in][what][DATA]; +  } + #ifdef CACHE_DEBUG +  perror("Miss\n"); + #endif +  return 0; + } +  + string status() + { +  string res, a; +  res = "<table border=1 cellspacing=0 cellpadding=2><tr>" +  "<th>Class</th><th>Entries</th><th>Memory used</th><th>% hits</th></tr>"; +  foreach(indices(cache), a) +  { +  res += "<tr align=right><td align=center>"+a+"</td><td>"+sizeof(cache[a])+"</td><td>" +  + (get_size(cache[a])/1024) + " Kbytes</td>"; +  if(all[a]) +  res += "<td>"+(hits[a]*100)/all[a]+"%</td>"; +  else +  res += "<td>0%</td>"; +  res += "</tr>"; +  } +  return res + "</table>"; + } +  + void cache_remove(string in, string what) + { + #ifdef CACHE_DEBUG +  perror(sprintf("CACHE: cache_remove(\"%s\",\"%O\")\n", in, what)); + #endif +  if(!what) +  m_delete(cache, in); +  else +  if(cache[in]) +  m_delete(cache[in], what); + } +  + void cache_set(string in, string what, mixed to) + { + #ifdef CACHE_DEBUG +  perror(sprintf("CACHE: cache_set(\"%s\", \"%s\", %O)\n", +  in, what, to)); + #endif +  if(!cache[in]) +  cache[in]=([ ]); +  cache[in][what] = allocate(ENTRY_SIZE); +  cache[in][what][DATA] = to; +  cache[in][what][TIMESTAMP] = time(0); + } +  + void cache_clean() + { +  string a, b; +  int cache_time_out=CACHE_TIME_OUT; + #ifdef CACHE_DEBUG +  perror("CACHE: cache_clean()\n"); + #endif + #ifdef CACHE_DEBUG +  perror("CACHE: Before cleaning\n"); +  perror("CACHE: "+status()/"\n"*"\nCACHE: "+"\n"); + #endif +  foreach(indices(cache), a) +  { + #ifdef CACHE_DEBUG + #if DEBUG_LEVEL > 40 +  perror("CACHE: Class " + a + "\n"); + #endif + #endif +  foreach(indices(cache[a]), b) +  { + #ifdef CACHE_DEBUG + #if DEBUG_LEVEL > 40 +  perror("CACHE: " + b + " "); + #endif + #endif +  if(!intp(cache[a][b][TIMESTAMP])) +  error("Illegal timestamp in cache ("+a+":"+b+")\n"); + #endif +  if(cache[a][b][TIMESTAMP] < (time(0) - cache_time_out)) +  { + #ifdef CACHE_DEBUG + #if DEBUG_LEVEL > 40 +  perror("DELETED\n"); + #endif + #endif +  m_delete(cache[a], b); +  } + #ifdef CACHE_DEBUG + #if DEBUG_LEVEL > 40 +  else +  perror("Ok\n"); + #endif + #endif +  if(!sizeof(cache[a])) +  { + #ifdef CACHE_DEBUG + #if DEBUG_LEVEL > 40 +  perror("CACHE: Class DELETED.\n"); + #endif + #endif +  m_delete(cache, a); +  } +  } +  } + #ifdef CACHE_DEBUG +  perror("CACHE: After cleaning\n"); +  perror("CACHE: "+status()/"\n"*"\nCACHE: "+"\n"); + #endif +  call_out(cache_clean, 1000); + } +  + void create() + { + #ifdef CACHE_DEBUG +  perror("CACHE: Now online.\n"); + #endif +  cache=([ ]); +  add_efun("cache_lookup", cache_lookup); +  add_efun("cache_set", cache_set); +  add_efun("cache_remove", cache_remove); +  call_out(cache_clean, 10); + } +  +  +    Newline at end of file added.