Roxen.git / server / base_server / roxen.pike

version» Context lines:

Roxen.git/server/base_server/roxen.pike:126:    [string fname, int line] = filename_2 (o);    return fname || "(unknown program)";   }      protected int once_mode;      // Note that 2.5 is a nonexisting version. It's only used for the   // cache static optimization for tags such as <if> and <emit> inside   // <cache> since that optimization can give tricky incompatibilities   // with 2.4. + // Note also that 5.3 only existed in the Print repository, and + // thus is skipped here.   array(string) compat_levels = ({"2.1", "2.2", "2.4", "2.5",    "3.3", "3.4",    "4.0", "4.5", -  "5.0", "5.1", "5.2" }); +  "5.0", "5.1", "5.2", "5.4", + });      #ifdef THREADS   mapping(string:string) thread_names = ([]);   string thread_name( object thread, int|void skip_auto_name )   {    string tn;    if( thread_names[ tn=sprintf("%O",thread) ] || skip_auto_name )    return thread_names[tn];    return tn;   }
Roxen.git/server/base_server/roxen.pike:4003:    {    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+ +  if (sizeof(data) <= 8*1024*1024) { +  // Should fit in the 16 MB query limit without problem. +  // Albeit it might trigger a slow query entry for large +  // entries. +  QUERY("REPLACE INTO " + name +    " (id,size,atime,meta,data) VALUES"    " (%s,%d,UNIX_TIMESTAMP()," MYSQL__BINARY "%s," MYSQL__BINARY "%s)",    id, strlen(data)+strlen(meta_data), meta_data, data ); -  +  } else { +  // We need to perform multiple queries.   #ifdef ARG_CACHE_DEBUG -  +  werror("Writing %d bytes of padding for %s.\n", sizeof(data), id); + #endif +  array(string) a = data/(8.0*1024*1024); +  // NB: We clear the meta field to ensure that the entry +  // is invalid while we perform the insert. +  QUERY("REPLACE INTO " + name + +  " (id,size,atime,meta,data) VALUES" +  " (%s,%d,UNIX_TIMESTAMP(),'',SPACE(%d))", +  id, strlen(data)+strlen(meta_data), sizeof(data)); +  int pos; +  foreach(a, string frag) { + #ifdef ARG_CACHE_DEBUG +  werror("Writing fragment at position %d for %s.\n", pos, id); + #endif +  QUERY("UPDATE " + name + +  " SET data = INSERT(data, %d, %d, "MYSQL__BINARY "%s)" +  " WHERE id = %s", +  pos+1, sizeof(frag), frag, id); +  pos += sizeof(frag); +  } +  /* Set the meta data field to a valid value to enable the entry. */ + #ifdef ARG_CACHE_DEBUG +  werror("Writing metadata for %s.\n", id); + #endif +  QUERY("UPDATE " + name + +  " SET meta = " MYSQL__BINARY "%s" +  " WHERE id = %s", +  meta_data, id); +  } + #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); +  string d = q[0]->data; +  int i; +  int cnt; +  for (i = 0; i < sizeof(data); i++) { +  if (data[i] == d[i]) continue; +  werror("Data differs at offset %d: %d != %d\n", +  i, data[i], d[i]); +  if (cnt++ > 10) break;    }    } -  +  }   #endif    }       protected mapping restore_meta( string id, RequestID rid )    {    if( array item = meta_cache[ id ] )    {    item[ 1 ] = time(1); // Update cached atime.    return item[ 0 ];    }
Roxen.git/server/base_server/roxen.pike:4455:       master()->resolv("DBManager.is_module_table")    ( 0,"local",name,"Image cache for "+name);       QUERY("CREATE TABLE "+name+" ("    "id CHAR(64) NOT NULL PRIMARY KEY, "    "size INT UNSIGNED NOT NULL DEFAULT 0, "    "uid CHAR(32) NOT NULL DEFAULT '', "    "atime INT UNSIGNED NOT NULL DEFAULT 0,"    "meta MEDIUMBLOB NOT NULL DEFAULT ''," -  "data MEDIUMBLOB NOT NULL DEFAULT ''," +  "data LONGBLOB NOT NULL DEFAULT '',"    "INDEX atime_id (atime, id)"    ")" );    }       // Create index in old databases. Index is used when flushing old    // entries. Column 'id' is included in index in order to avoid    // reading data file.    array(mapping(string:mixed)) res = QUERY("SHOW INDEX FROM " + name);    if(search(res->Key_name, "atime_id") < 0) {    report_debug("Updating " + name + " image cache: "    "Adding index atime_id on %s... ", name);    int start_time = gethrtime();    QUERY("CREATE INDEX atime_id ON " + name + " (atime, id)");    report_debug("complete. [%f s]\n", (gethrtime() - start_time)/1000000.0);    report_debug("Updating " + name + " image cache: "    "Dropping index atime on %s... ", name);    start_time = gethrtime();    QUERY("DROP INDEX atime ON " + name);    report_debug("complete. [%f s]\n", (gethrtime() - start_time)/1000000.0);    } -  +  res = QUERY("SHOW COLUMNS FROM " + name + " WHERE Field = 'data'"); +  if (lower_case(res[0]->Type) != "longblob") { +  report_debug("Updating " + name + " image cache: " +  "Increasing maximum blob size..."); +  int start_time = gethrtime(); +  QUERY("ALTER TABLE " + name + +  " MODIFY COLUMN data LONGBLOB NOT NULL DEFAULT ''"); +  report_debug("complete. [%f s]\n", (gethrtime() - start_time)/1000000.0);    } -  +  }       Sql.Sql get_db()    {    return dbm_cached_get("local");    }       protected void init_db( )    {    catch(sync_meta());    setup_tables();