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.1071 2010/11/05 16:01:15 mast Exp $"; + constant cvs_version="$Id: roxen.pike,v 1.1072 2010/11/10 18:39:28 mast 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:1248: Inside #if defined(THREADS)
   // 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)); +  for (maxbeats = max (maxbeats, (int) (bg_time_buffer_min / 0.01));    busy_threads > 1 && maxbeats > 0;    maxbeats--) -  // Pike implementation note: If 0.02 or smaller, we'll busy wait here. -  sleep (0.04); +  sleep (0.01);    bg_last_busy = time();    }      #ifdef DEBUG_BACKGROUND_RUN    report_debug ("background_run run %s (%s) [%d jobs left in queue]\n",    functionp (task[0]) ?    sprintf ("%s: %s", Function.defined (task[0]),    master()->describe_function (task[0])) :    programp (task[0]) ?    sprintf ("%s: %s", Program.defined (task[0]),
Roxen.git/server/base_server/roxen.pike:1346: 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); +  if (bg_queue->size()) { +  handle (bg_process_queue); +  // Sleep a short while to encourage a thread switch. This is a +  // kludge to avoid starving non-handler threads, since pike +  // currently (7.8.503) doesn't switch threads reliably on yields. +  sleep (0.001);    } -  + }   #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.   //!   //! The function @[func] will be enqueued after approximately @[delay]