Branch: Tag:

1998-03-26

1998-03-26 07:51:52 by Per Hedbor <ph@opera.com>

Added FD_DEBUG #ifdefs around all mark_fd(), and a --fd-debug option to the startscript

Rev: server/base_server/configuration.pike:1.113
Rev: server/base_server/disk_cache.pike:1.35
Rev: server/base_server/roxen.pike:1.178
Rev: server/base_server/roxenloader.pike:1.65
Rev: server/base_server/socket.pike:1.12
Rev: server/config_actions/openfiles.pike:1.3
Rev: server/modules/filters/htaccess.pike:1.32
Rev: server/modules/proxies/ftpgateway.pike:1.21
Rev: server/modules/proxies/proxy.pike:1.30
Rev: server/protocols/ftp.pike:1.88
Rev: server/protocols/http.pike:1.71

1:   // This is a roxen module. Copyright © 1996 - 1998, Idonex AB.    - constant cvs_version = "$Id: http.pike,v 1.70 1998/03/26 07:31:02 neotron Exp $"; + constant cvs_version = "$Id: http.pike,v 1.71 1998/03/26 07:51:52 per Exp $";   // HTTP protocol module.   #include <config.h>   private inherit "roxenlib";
19:   int req_time = HRTIME();   #endif    + #ifdef FD_DEBUG + #define MARK_FD(X) catch(mark_fd(my_fd->query_fd(), (X)+" "+remoteaddr)) + #else + #define MARK_FD(X) + #endif +    constant decode=roxen->decode;   constant find_supports=roxen->find_supports;   constant version=roxen->version;
567:    if(do_not_disconnect) {    return;    } - #ifdef FD_DEBUG -  mark_fd(my_fd->query_fd(), "HTTP disconnected"); - #endif +  MARK_FD("my_fd in HTTP disconnected?");    destruct();   }   
601: Inside #if defined(KEEP_ALIVE)
   o->supports = supports;    o->host = host;    o->client = client; - #ifdef FD_DEBUG -  mark_fd(my_fd->query_fd(), "HTTP kept alive"); - #endif +  MARK_FD("HTTP kept alive");    object fd = my_fd;    my_fd=0;    if(s) leftovers += s;
615:       if(objectp(my_fd))    { - #ifdef FD_DEBUG -  mark_fd(my_fd->query_fd(), "HTTP closed"); - #endif +  MARK_FD("HTTP closed");    catch {    my_fd->set_close_callback(0);    my_fd->set_read_callback(0); - // my_fd->set_blocking(); +  my_fd->set_blocking();    if(s) my_fd->write(s);    my_fd->close();    destruct(my_fd);
636:    int elapsed = _time()-time;    if(elapsed >= 30)    { - #ifdef FD_DEBUG -  mark_fd(my_fd->query_fd(), "HTTP timeout"); - #endif +  MARK_FD("HTTP timeout");    end("HTTP/1.0 408 Timeout\r\n"    "Content-type: text/plain\r\n"    "Server: Roxen Challenger\r\n"
648:    } else {    // premature call_out... *¤#!"    call_out(do_timeout, 10); - #ifdef FD_DEBUG -  mark_fd(my_fd->query_fd(), "HTTP premature timeout"); - #endif +  MARK_FD("HTTP premature timeout");    }   }   
702:    foreach(from[1], array q)    catch {    int id; -  if(sscanf(Stdio.read_bytes(q[0]), "%*s$Id: http.pike,v 1.70 1998/03/26 07:31:02 neotron Exp $", id) == 4) +  if(sscanf(Stdio.read_bytes(q[0]), "%*s$"+"Id: %*s,v %[^ ] ", id) == 2)    q[0] += " ("+id+")";    };    return from;
779:      void do_log()   { - #ifdef FD_DEBUG -  mark_fd(my_fd->query_fd(), "HTTP logging"); - #endif +  MARK_FD("HTTP logging"); // fd can be closed here    if(conf)    {    int len;
806:    object thiso=this_object();       remove_call_out(do_timeout); - #ifdef FD_DEBUG -  mark_fd(my_fd->query_fd(), "HTTP handling request"); - #endif +  MARK_FD("HTTP handling request");       if(conf)    {
943:    file->file = 0;    file->data="";    } - #ifdef FD_DEBUG -  mark_fd(my_fd->query_fd(), "HTTP handled"); - #endif + MARK_FD("HTTP handled");         #ifdef KEEP_ALIVE
971:    } else    file->len = 1; // Keep those alive, please...    if (pipe) { +  MARK_FD("HTTP really handled, piping");    pipe->set_done_callback( do_log );    pipe->output(my_fd);    } else { -  my_fd->close(); +  MARK_FD("HTTP really handled, pipe done");    do_log();    } - #ifdef FD_DEBUG -  mark_fd(my_fd->query_fd(), "HTTP really handled"); - #endif +    }      /* We got some data on a socket.
989:   void got_data(mixed fooid, string s)   {    int tmp; - #ifdef FD_DEBUG -  mark_fd(my_fd->query_fd(), "HTTP got data"); - #endif +  MARK_FD("HTTP got data");    remove_call_out(do_timeout);    call_out(do_timeout, 30); // Close down if we don't get more data    // within 30 seconds. Should be more than enough.
1100:   void clean()   {    if(!(my_fd && objectp(my_fd))) -  { +     end(); - #ifdef FD_DEBUG -  mark_fd(my_fd->query_fd(), "HTTP clean up"); - #endif +  else if((_time(1) - time) > 4800) +  end();   } -  else if((_time(1) - time) > 4800) end(); - } +       void create(object f, object c)   {
1115:    {    my_fd = f;    conf = c; -  mark_fd(my_fd->query_fd(), "HTTP connection"); +  MARK_FD("HTTP connection");    my_fd->set_close_callback(end);    my_fd->set_read_callback(got_data);    // No need to wait more than 30 seconds to get more data.
1142:    if(!processed) {    f->set_close_callback(end);    f->set_read_callback(got_data); +  f->write("");    }    }   }