Roxen.git / server / base_server / roxen.pike

version» Context lines:

Roxen.git/server/base_server/roxen.pike:1:   // This file is part of Roxen WebServer.   // Copyright © 1996 - 2004, Roxen IS.   //   // The Roxen WebServer main program.   //   // Per Hedbor, Henrik Grubbström, Pontus Hagland, David Hedbor and others.   // ABS and suicide systems contributed freely by Francesco Chemolli    - constant cvs_version="$Id: roxen.pike,v 1.894 2006/03/15 15:58:58 wellhard Exp $"; + constant cvs_version="$Id: roxen.pike,v 1.895 2006/08/21 11:52:45 grubba Exp $";      //! @appears roxen   //!   //! The Roxen WebServer main program.      // The argument cache. Used by the image cache.   ArgCache argcache;      // Some headerfiles   #define IN_ROXEN
Roxen.git/server/base_server/roxen.pike:3075: Inside #if defined(ARG_CACHE_DEBUG)
   if(!stringp(data)) return;   #ifdef ARG_CACHE_DEBUG    werror("store %O (%d bytes)\n", id, strlen(data) );   #endif    meta_cache_insert( id, meta );    string meta_data = encode_value( meta );   #ifdef ARG_CACHE_DEBUG    werror("Replacing entry for %O\n", id );   #endif    QUERY("REPLACE INTO "+name+ -  " (id,size,atime,meta,data) VALUES (%s,%d,UNIX_TIMESTAMP(),%s,%s)", +  " (id,size,atime,meta,data)" +  " VALUES (%s,%d,UNIX_TIMESTAMP(),_binary%s,_binary%s)",    id, strlen(data)+strlen(meta_data), meta_data, data ); -  + #ifdef ARG_CACHE_DEBUG +  array(mapping(string:string)) q = +  QUERY("SELECT meta, data FROM " + name + +  " WHERE id = %s", id); +  if (!q || sizeof(q) != 1) { +  werror("Unexpected result size: %d\n", +  q && sizeof(q)); +  } else { +  if (q[0]->meta != meta_data) { +  werror("Meta data differs: %O != %O\n", +  meta_data, q[0]->meta);    } -  +  if (q[0]->data != data) { +  werror("Data differs: %O != %O\n", +  data, q[0]->data); +  } +  } + #endif +  }       static mapping restore_meta( string id, RequestID rid )    {    if( meta_cache[ id ] )    {    meta_cache[ id ][ 1 ] = time(1); // Update cached atime.    return meta_cache[ id ][ 0 ];    }      #ifdef ARG_CACHE_DEBUG
Roxen.git/server/base_server/roxen.pike:3233:    werror("restore %O\n", id );   #endif    q = QUERY( "SELECT meta,atime,data FROM "+name+" WHERE id=%s",id);    if( sizeof(q) )    {    if( sizeof(q[0]->data) )    {    // Case 1: We have cache entry and image.    string f = q[0]->data;    mapping m; -  catch( m = decode_value( q[0]->meta ) ); +  mixed err = catch( m = decode_value( q[0]->meta ) ); +  if (err) { +  werror("Decode_value failed.\n" +  "%s\n", describe_backtrace(err)); +  }    if( !m ) return 0;       m = Roxen.http_string_answer( f, m->type||("image/gif") );       if( strlen( f ) > 6000 )    return m;    rst_cache[ id ] = m;    if( sizeof( rst_cache ) > 100 )    rst_cache = ([ id : m ]);    return rst_cache[ id ] + ([]);
Roxen.git/server/base_server/roxen.pike:3431:    }       void set_draw_function( function to )    //! Set a new draw function.    {    draw_function = to;    }       static void setup_tables()    { -  if(catch(QUERY("SELECT DATA FROM "+name+" WHERE id=''"))) +  if(catch(QUERY("SELECT data FROM "+name+" WHERE id=''")))    {    werror("Creating image-cache tables for '"+name+"'\n");    catch(QUERY("DROP TABLE "+name));       // The old tables. This is only useful for people who have run    // Roxen 2.2 from cvs before    catch(QUERY("DROP TABLE "+name+"_data"));          master()->resolv("DBManager.is_module_table")
Roxen.git/server/base_server/roxen.pike:3607:    "id: %O, old data: %O, new data: %O\n",    id, row->contents, encoded_args);    error("ArgCache.create_key() Duplicate key found!\n");    }       if(sizeof(rows))    return;       QUERY( "INSERT INTO "+name+"2 "    "(id, contents, ctime, atime) VALUES " -  "(%s, %s, NOW(), NOW())", id, encoded_args ); +  "(%s, _binary%s, NOW(), NOW())", id, encoded_args );       dwerror("ArgCache: Create new key %O\n", id);       (plugins->create_key-({0}))( id, encoded_args );    }       static array plugins;    static void get_plugins()    {    plugins = ({});
Roxen.git/server/base_server/roxen.pike:3880:       foreach( data, mapping m )    if( m->contents == long_key )    return (int)m->id;       if(zero_type(index_id))    index_id = -1;       string index_id_value = (index_id == -1? "NULL": index_id);    QUERY( "INSERT INTO "+name+" (contents,md5,atime,index_id) VALUES " -  "(%s,%s,UNIX_TIMESTAMP(),"+index_id_value+")", long_key, md ); +  "(_binary%s,%s,UNIX_TIMESTAMP(),"+index_id_value+")", +  long_key, md );    int id = (int)db->master_sql->insert_id();    if(!id)    error("ArgCache::create_key() insert_id returned 0.\n");   #ifdef REPLICATE_DEBUG    werror("Create new local key: id: %d, index_id: %d.\n", id, index_id);   #endif       (plugins->create_key-({0}))( id, long_key );       return id;