Branch: Tag:

2018-12-05

2018-12-05 17:02:31 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Protocols.HTTP.Session: Don't attempt to reuse SessionQuery objects.

give_me_connection() now always returns a new SessionQuery object
(albeit sometimes with a reused connection).

This should alleviate issues with stuff being left around from
previous queries.

Potential fix for [WS-389].

663:   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
687:    one->disconnect(); // removes itself    }    -  q=SessionQuery(); -  q->hostname_cache=hostname_cache; +     connections_host_n[connection_lookup(url)]++; // new    }    connections_inuse_n++;