Roxen.git / server / modules / tags / insert_cached_href.pike

version» Context lines:

Roxen.git/server/modules/tags/insert_cached_href.pike:1:   // This is a roxen module. Copyright © 2000 - 2004, Roxen IS.   //      #include <module.h>   inherit "module";      //<locale-token project="mod_insert_cached_href">LOCALE</locale-token>   #define LOCALE(X,Y) _DEF_LOCALE("mod_insert_cached_href",X,Y)    - constant cvs_version = "$Id: insert_cached_href.pike,v 1.15 2006/09/24 09:06:55 liin Exp $"; + constant cvs_version = "$Id: insert_cached_href.pike,v 1.16 2006/11/15 14:05:05 liin Exp $";      constant thread_safe = 1;   constant module_type = MODULE_TAG;   LocaleString module_name = LOCALE(0, "Tags: Insert cached href");   LocaleString module_doc = LOCALE(0, "This module contains the RXML tag \"insert "    "cached-href\". Useful when implementing e.g."    " RSS syndication.");      #if DEBUG_INSERT_CACHED_HREF   #define DWRITE(x) report_debug("INSERT_CACHED_HREF: " + x + "\n")
Roxen.git/server/modules/tags/insert_cached_href.pike:88: Inside #if defined(THREADS)
   roxen.BackgroundProcess(get_time_in_seconds(query("update-interval")),    href_database->update_db, 0);    } else {    report_error("Insert cached href: Failed to initialize SQL tables. "    "Permission error?\n");    }    }   #endif   }    + mapping(string:function) query_action_buttons() + { +  return ([LOCALE(0, "Clear database") : href_database->empty_db]); + } +  +    void stop() {    DWRITE("stop()");      #ifdef THREADS    bg_process && bg_process->stop();    bg_process = 0;    mutex_key = mutex->lock();       /* Removing registered callbacks for unfinished data fetches to avoid having the    back-end thread call them after the module has been destructed: */
Roxen.git/server/modules/tags/insert_cached_href.pike:224:       private string request_table;    private string data_table;       public void create() {    // Failure to create tables will lead to zero return values    request_table = get_my_table("request", ({request_table_def}));    data_table = get_my_table("data", ({data_table_def}));    }    +  public void empty_db() { +  /* Might as well clean up the database in a mutex section, +  just to be sure. No performance issue since this function is only +  supposed to be used when the "Clear database" button in the admin interface +  is pressed. +  */ + #ifdef THREADS +  mutex_key = mutex->lock(); + #endif +  sql_query("DELETE FROM " + request_table); +  sql_query("DELETE FROM " + data_table); +  DWRITE("Database has been emptied."); + #ifdef THREADS +  mutex_key = 0; + #endif +  } +     public int ready_to_run()    {    // Only ok to run if both tables are accessible    return request_table && data_table && 1;    }       public void update_db() {    DWRITE(sprintf("########### update_db(): Called every %d seconds ##########"    , get_time_in_seconds(query("update-interval"))));