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 - 2009, 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.1069 2010/09/23 15:27:30 grubba Exp $"; + constant cvs_version="$Id: roxen.pike,v 1.1070 2010/11/02 17:09:59 marty 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:1231: Inside #if defined(THREADS)
      int maxbeats =    min (time() - bg_last_busy, bg_time_buffer_max) * (int) (1 / 0.04);      #ifndef NO_SLOW_REQ_BT    Pike.Backend monitor;    mixed call_out;   #endif       if (mixed err = catch { -  while (bg_queue->size() && !shutdown_started) { +  // Make sure we don't run forever if background jobs are queued +  // over and over again, to avoid starving other threads. (If they +  // are starved enough, busy_threads will never be incremented.) +  // If jobs are enqueued while running another background job, +  // bg_process_queue is put on the handler queue again at the very +  // end of this function. +  int jobs_to_process = bg_queue->size(); +  while (jobs_to_process-- && !shutdown_started) {    // Not a race here since only one thread is reading the queue.    array task = bg_queue->read();       // Wait a while if another thread is busy already.    if (busy_threads > 1) {    for (maxbeats = max (maxbeats, (int) (bg_time_buffer_min / 0.04));    busy_threads > 1 && maxbeats > 0;    maxbeats--)    // Pike implementation note: If 0.02 or smaller, we'll busy wait here.    sleep (0.04);
Roxen.git/server/base_server/roxen.pike:1335: Inside #if defined(THREADS)
   }    }) {   #ifndef NO_SLOW_REQ_BT    if (call_out) monitor->remove_call_out (call_out);   #endif    bg_process_running = 0;    handle (bg_process_queue);    throw (err);    }    bg_process_running = 0; +  if (bg_queue->size()) handle (bg_process_queue);   }   #endif      mixed background_run (int|float delay, function func, mixed... args)   //! Enqueue a task to run in the background in a way that makes as   //! little impact as possible on the incoming requests. No matter how   //! many tasks are queued to run in the background, only one is run at   //! a time. The tasks won't be starved regardless of server load,   //! though.   //!