pike.git / lib / modules / Protocols.pmod / HTTP.pmod / Session.pike

version» Context lines:

pike.git/lib/modules/Protocols.pmod/HTTP.pmod/Session.pike:656:   {    return url->scheme+"://"+url->host+":"+url->port;   }      //! Request a @[Query] object suitable to use for the   //! given URL. This may be a reused object from a keep-alive   //! connection.   Query give_me_connection(Standards.URI url)   {    Query q; +  Query old_q;       Thread.MutexKey key = connection_cache_mux->lock();       if (array(KeptConnection) v =    connection_cache[connection_lookup(url)])    { -  q=v[0]->use(); // removes itself -  // clean up -  q->buf=""; -  q->headerbuf=""; -  q->n_used++; +  old_q = v[0]->use(); // removes itself    } -  +  +  q = SessionQuery(); +  q->hostname_cache=hostname_cache; +  if (old_q) { +  // Transfer connection from the old Query object to the new. +  foreach(({ "con", "host", "port", + #if constant(SSL.Cipher) +  "https", "context", "ssl_session", + #endif +  }), string field) { +  q[field] = old_q[field]; +  } +  q->n_used = old_q->n_used+1; +  old_q->con = 0; +  destruct(old_q); +  }    else    {    if (connections_kept_n+connections_inuse_n+1    >= maximum_total_connections &&    sizeof(connection_cache))    {    // close one if we have it kept    array(KeptConnection) all=`+(@values(connection_cache));    KeptConnection one=all[random(sizeof(all))];    one->disconnect(); // removes itself    }    -  q=SessionQuery(); -  q->hostname_cache=hostname_cache; +     connections_host_n[connection_lookup(url)]++; // new    }    connections_inuse_n++;    return q;   }      //   // called when there might be a free connection      // queue of what to call when we get new free connections