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 - 2001, 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.845 2003/11/05 13:16:37 grubba Exp $"; + constant cvs_version="$Id: roxen.pike,v 1.846 2003/11/05 15:23:33 grubba 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:1512:    map(indices(variables),query)));    }       void restore()    //! Restore all port options from saved values    {    foreach( (array)get_port_options( get_key() ), array kv )    set( kv[0], kv[1] );    }    +  static int retries; +  static void bind() +  { +  if (bound) return; +  if (!port_obj) port_obj = Stdio.Port(); +  if (port_obj->bind(port, got_connection, ip)) +  { +  bound = 1; +  return; +  } +  report_error(LOC_M(6, "Failed to bind %s://%s:%d/ (%s)")+"\n", +  (string)name, (ip||"*"), (int)port, +  strerror(port_obj->errno())); + #if constant(System.EADDRINUSE) || constant(system.EADDRINUSE) +  if ( + #if constant(System.EADDRINUSE) +  (port_obj->errno == system.EADDRINUSE) && + #else /* !constant(System.EADDRINUSE) */ +  (port_obj->errno == system.EADDRINUSE) && + #endif /* constant(System.EADDRINUSE) */ +  (retries++ < 10)) { +  // We may get spurious failures on rebinding ports on some OS'es +  // (eg Linux, WIN32). See [bug 3031]. +  report_notice(LOC_M(0, "Attempt %d. Retrying in 1 minute.")+"\n", +  retries); +  call_out(bind, 60); +  } + #endif /* constant(System.EADDRINUSE) || constant(system.EADDRINUSE) */ +  } +     static void create( int pn, string i )    //! Constructor. Bind to the port 'pn' ip 'i'    {    port = pn;    ip = i;       restore();    if( file_stat( "../local/"+requesthandlerfile ) )    rrhf = "../local/"+requesthandlerfile;    else    rrhf = requesthandlerfile;    DDUMP( rrhf );   #ifdef DEBUG    if( !requesthandler )    requesthandler = (program)(rrhf);   #endif -  port_obj = Stdio.Port(); -  if(!port_obj->bind( port, got_connection, ip )) -  { -  report_error(LOC_M(6, "Failed to bind %s://%s:%d/ (%s)")+"\n", -  (string)name, (ip||"*"), (int)port, strerror( errno() )); +     bound = 0; -  } else -  bound = 1; +  port_obj = 0; +  retries = 0; +  bind();    }       static string _sprintf( )    {    return "Protocol("+name+"://"+ip+":"+port+")";    }   }      #if constant(SSL.sslfile)   class SSLProtocol