Branch: Tag:

2001-08-22

2001-08-22 15:41:24 by Per Hedbor <ph@opera.com>

Bug Of The Day: int id = mysql->insert_id(); mysql->query( "INSERT .... " ); Duh!

Rev: server/base_server/roxen.pike:1.707

6:   // 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.706 2001/08/21 14:32:15 mast Exp $"; + constant cvs_version="$Id: roxen.pike,v 1.707 2001/08/22 15:41:24 per Exp $";      // The argument cache. Used by the image cache.   ArgCache argcache;
3090:    if( m->contents == long_key )    return (int)m->id;    -  int id = (int)get_db()->master_sql->insert_id(); -  +     QUERY( "INSERT INTO "+name+" (contents,md5,atime) VALUES "    "(%s,%s,UNIX_TIMESTAMP())", long_key, md );    -  +  int id = (int)get_db()->master_sql->insert_id(); +     (plugins->create_key-({0}))( id, long_key, md );       return id;
3210:    if( cache[id] )    return cache[id]+([]);    array i = decode_id( id ); - // if( !i ) - // { - // mixed res; - // foreach( (plugins->lookup-({0})), function f ) - // if( res = f( id ) ) - // return res; - // return 0; - // } +  if( !i ) +  error("Requesting unknown key\n");    array a = low_lookup( i[0] );    array b = low_lookup( i[1] );    if( a && b )
3232:    string q = read_args( id );    if( !q )    error("Requesting unknown key\n"); - // { - // mixed res; - // foreach( (plugins->low_lookup-({0})), function f ) - // if( res = f( id ) ) - // return res; - // } +     mixed data = decode_value(q);    string hl = Crypto.md5()->update( q )->digest();    cache[ hl ] = id;
4015:    start_time=time(); // Used by the "uptime" info later on.       -  if (query("suicide_engage")) -  call_out (restart,60*60*24*max(1,query("suicide_timeout"))); + // if (query("suicide_engage")) + // call_out (restart,60*60*24*max(1,query("suicide_timeout")));   #ifndef __NT__    restart_if_stuck( 0 );   #endif
4026:    return -1;   }    + void check_suicide( ) + { +  int next = getvar("suicide_schedule") +  ->get_next( query("last_suicide") ); +  if( next < time() ) +  { +  set( "last_suicide", time() ); +  return 0; +  } + } +    // Called from the administration interface.   string check_variable(string name, mixed value)   {
4042:       case "suicide_engage":    if (value) -  call_out(restart,60*60*24*max(1,query("suicide_timeout"))); +  { +  remove_call_out( check_suicide ); +  call_out( check_suicide, 60 ); +  }    else -  remove_call_out(restart); +  remove_call_out( check_suicide );    break;      #ifdef SNMP_AGENT