RE: squid 2.6-rproxy

From: JDW - List <jdw_list@dont-contact.us>
Date: Sat, 15 Jun 2002 22:23:08 -0500

Attached are the rest of the "low hanging fruit" patches for the cbdata
updates to the rproxy branch. It still doesn't compile because of the
parsing of the -a flag; I'm going to look at that now.

> -----Original Message-----
> > On another note, if I submitted a patch to HEAD that changed
> > READ_AHEAD_GAP to be a config file parameter, would that patch be
> > accepted?
>
> Probably, if given a good motivation why such a thing is needed and
> what kind of testing you have done to make sure that there was no ill
> effects of changing this..

Well, my squid hangs connections with this at its default value under
certain circumstances. I was advised by someone more squid-knowledgeable
than me to change it, and that solved the problem.

I don't even really know what it does. It looks it's got something to do
with managing how far ahead of the client the server will receive from the
origin server, but it's not clear to me why the default value causes
connections to hang.

It appears to be most prevalent when a lot of clients access the same very
large file.

I'm not looking to change the default, just make it configurable. Mostly
selfish reasons: to teach myself about the config interface. It's very
questionable whether this is of value to anyone else.

Thanks,
Jeff

# These patches update the rproxy branch to use
# the new-style cbdataReference() interface.

Index: client_side.c
===================================================================
RCS file: /cvsroot/squid/squid/src/client_side.c,v
retrieving revision 1.27.2.2.4.46.2.6
diff -c -r1.27.2.2.4.46.2.6 client_side.c
*** client_side.c 11 Jun 2002 08:45:04 -0000 1.27.2.2.4.46.2.6
--- client_side.c 16 Jun 2002 03:06:33 -0000
***************
*** 1713,1720 ****
        body_size, rep->hdr_sz);
      CBDATA_INIT_TYPE(clientCheckHeaderStateData);
      state = cbdataAlloc(clientCheckHeaderStateData);
! state->http = http;
! cbdataLock(http);
      state->rep = rep;
      state->buf = buf;
      state->size = size;
--- 1713,1719 ----
        body_size, rep->hdr_sz);
      CBDATA_INIT_TYPE(clientCheckHeaderStateData);
      state = cbdataAlloc(clientCheckHeaderStateData);
! state->http = cbdataReference(http);
      state->rep = rep;
      state->buf = buf;
      state->size = size;
***************
*** 1728,1734 ****
  {
      HttpReply *rep = state->rep;
      aclCheck_t *ch;
! if (!cbdataValid(state->http)) {
        /* oops.. */
        clientCheckHeaderDone(state);
        return;
--- 1727,1733 ----
  {
      HttpReply *rep = state->rep;
      aclCheck_t *ch;
! if (!cbdataReferenceValid(state->http)) {
        /* oops.. */
        clientCheckHeaderDone(state);
        return;
***************
*** 1750,1756 ****
  clientHttpLocationRewriteCheckDone(int answer, void *data)
  {
      clientCheckHeaderStateData *state = data;
! if (!cbdataValid(state->http)) {
        /* oops.. */
        clientCheckHeaderDone(state);
        return;
--- 1749,1755 ----
  clientHttpLocationRewriteCheckDone(int answer, void *data)
  {
      clientCheckHeaderStateData *state = data;
! if (!cbdataReferenceValid(state->http)) {
        /* oops.. */
        clientCheckHeaderDone(state);
        return;
***************
*** 1766,1772 ****
  clientHttpLocationRewrite(clientCheckHeaderStateData * state)
  {
      HttpReply *rep = state->rep;
! if (!cbdataValid(state->http)) {
        /* oops.. */
        clientCheckHeaderDone(state);
        return;
--- 1765,1771 ----
  clientHttpLocationRewrite(clientCheckHeaderStateData * state)
  {
      HttpReply *rep = state->rep;
! if (!cbdataReferenceValid(state->http)) {
        /* oops.. */
        clientCheckHeaderDone(state);
        return;
***************
*** 1784,1790 ****
      clientHttpRequest *http = state->http;
      HttpReply *rep = state->rep;
      ConnStateData *conn = http->conn;
! if (!cbdataValid(http)) {
        /* oops.. */
        clientCheckHeaderDone(state);
        return;
--- 1783,1789 ----
      clientHttpRequest *http = state->http;
      HttpReply *rep = state->rep;
      ConnStateData *conn = http->conn;
! if (!cbdataReferenceValid(http)) {
        /* oops.. */
        clientCheckHeaderDone(state);
        return;
***************
*** 1810,1816 ****
  clientHttpReplyAccessCheck(clientCheckHeaderStateData * state)
  {
      aclCheck_t *ch;
! if (!cbdataValid(state->http)) {
        /* oops.. */
        clientCheckHeaderDone(state);
        return;
--- 1809,1815 ----
  clientHttpReplyAccessCheck(clientCheckHeaderStateData * state)
  {
      aclCheck_t *ch;
! if (!cbdataReferenceValid(state->http)) {
        /* oops.. */
        clientCheckHeaderDone(state);
        return;
***************
*** 1842,1848 ****
      clientCheckHeaderStateData *state = data;
      clientHttpRequest *http = state->http;
      HttpReply *rep = state->rep;
! if (!cbdataValid(state->http)) {
        /* oops.. */
        clientCheckHeaderDone(state);
        return;
--- 1841,1847 ----
      clientCheckHeaderStateData *state = data;
      clientHttpRequest *http = state->http;
      HttpReply *rep = state->rep;
! if (!cbdataReferenceValid(state->http)) {
        /* oops.. */
        clientCheckHeaderDone(state);
        return;
***************
*** 1875,1881 ****
  clientCheckErrorMapDone(StoreEntry * e, int body_offset, ssize_t
content_length, void *data)
  {
      clientCheckHeaderStateData *state = data;
! if (!cbdataValid(state->http)) {
        /* oops.. */
        clientCheckHeaderDone(state);
        return;
--- 1874,1880 ----
  clientCheckErrorMapDone(StoreEntry * e, int body_offset, ssize_t
content_length, void *data)
  {
      clientCheckHeaderStateData *state = data;
! if (!cbdataReferenceValid(state->http)) {
        /* oops.. */
        clientCheckHeaderDone(state);
        return;
***************
*** 1908,1914 ****
  {
      clientHttpRequest *http = state->http;
      HttpReply *rep = state->rep;
! if (!cbdataValid(http)) {
        /* oops.. */
        clientCheckHeaderDone(state);
        return;
--- 1907,1913 ----
  {
      clientHttpRequest *http = state->http;
      HttpReply *rep = state->rep;
! if (!cbdataReferenceValid(http)) {
        /* oops.. */
        clientCheckHeaderDone(state);
        return;
***************
*** 1933,1939 ****
      clientHttpRequest *http = state->http;
      MemBuf mb;
      cbdataFree(state);
! if (!cbdataValid(http))
        goto aborted;
      /* reset range iterator */
      http->range_iter.pos = HttpHdrRangeInitPos;
--- 1932,1938 ----
      clientHttpRequest *http = state->http;
      MemBuf mb;
      cbdataFree(state);
! if (!cbdataReferenceValid(http))
        goto aborted;
      /* reset range iterator */
      http->range_iter.pos = HttpHdrRangeInitPos;
***************
*** 1958,1964 ****
      comm_write_mbuf(http->conn->fd, mb, clientWriteComplete, http);
      /* clean up */
    aborted:
! cbdataUnlock(http);
      http = NULL;
  }

--- 1957,1963 ----
      comm_write_mbuf(http->conn->fd, mb, clientWriteComplete, http);
      /* clean up */
    aborted:
! cbdataReferenceDone(http);
      http = NULL;
  }

***************
*** 3169,3176 ****
        }
        debug(33, 4) ("httpAccept: FD %d: accepted\n", fd);
        connState = cbdataAlloc(ConnStateData);
! connState->port = s;
! cbdataLock(connState->port);
        connState->peer = peer;
        connState->log_addr = peer.sin_addr;
        connState->log_addr.s_addr &= Config.Addrs.client_netmask.s_addr;
--- 3168,3174 ----
        }
        debug(33, 4) ("httpAccept: FD %d: accepted\n", fd);
        connState = cbdataAlloc(ConnStateData);
! connState->port = cbdataReference(s);
        connState->peer = peer;
        connState->log_addr = peer.sin_addr;
        connState->log_addr.s_addr &= Config.Addrs.client_netmask.s_addr;
Index: locrewrite.c
===================================================================
RCS file: /cvsroot/squid/squid/src/Attic/locrewrite.c,v
retrieving revision 1.1.2.7
diff -c -r1.1.2.7 locrewrite.c
*** locrewrite.c 19 Oct 2001 23:26:49 -0000 1.1.2.7
--- locrewrite.c 16 Jun 2002 03:06:34 -0000
***************
*** 62,69 ****
        if (*reply == '\0')
            reply = NULL;
      }
! valid = cbdataValid(r->data);
! cbdataUnlock(r->data);
      if (valid)
        r->handler(r->data, reply);
      locationRewriteStateFree(r);
--- 62,69 ----
        if (*reply == '\0')
            reply = NULL;
      }
! valid = cbdataReferenceValid(r->data);
! cbdataReferenceDone(r->data);
      if (valid)
        r->handler(r->data, reply);
      locationRewriteStateFree(r);
***************
*** 120,127 ****
      r = cbdataAlloc(rewriteStateData);
      r->orig_url = xstrdup(location);
      r->handler = handler;
! r->data = data;
! cbdataLock(r->data);
      snprintf(buf, 8192, "%s %s %s\n",
        r->orig_url, http->uri, urlgroup);
      helperSubmit(locrewriters, buf, locationRewriteHandleReply, r);
--- 120,126 ----
      r = cbdataAlloc(rewriteStateData);
      r->orig_url = xstrdup(location);
      r->handler = handler;
! r->data = cbdataReference(data);
      snprintf(buf, 8192, "%s %s %s\n",
        r->orig_url, http->uri, urlgroup);
      helperSubmit(locrewriters, buf, locationRewriteHandleReply, r);
Index: peer_monitor.c
===================================================================
RCS file: /cvsroot/squid/squid/src/Attic/peer_monitor.c,v
retrieving revision 1.1.2.10.4.2
diff -c -r1.1.2.10.4.2 peer_monitor.c
*** peer_monitor.c 5 Jun 2002 16:20:53 -0000 1.1.2.10.4.2
--- peer_monitor.c 16 Jun 2002 03:06:34 -0000
***************
*** 63,69 ****
  freePeerMonitor(void *data)
  {
      PeerMonitor *pm = data;
! cbdataUnlock(pm->peer);
      pm->peer = NULL;
  }

--- 63,69 ----
  freePeerMonitor(void *data)
  {
      PeerMonitor *pm = data;
! cbdataReferenceDone(pm->peer);
      pm->peer = NULL;
  }

***************
*** 203,210 ****
      CBDATA_INIT_TYPE_FREECB(PeerMonitor, freePeerMonitor);
      pm = cbdataAlloc(PeerMonitor);
      snprintf(pm->name, sizeof(pm->name), "monitor %s", peer->name);
! pm->peer = peer;
! cbdataLock(pm->peer);
      if (*url == '/') {
        snprintf(pm->url, sizeof(pm->url), "http://%s:%d%s",
            pm->peer->host, pm->peer->http_port, url);
--- 203,209 ----
      CBDATA_INIT_TYPE_FREECB(PeerMonitor, freePeerMonitor);
      pm = cbdataAlloc(PeerMonitor);
      snprintf(pm->name, sizeof(pm->name), "monitor %s", peer->name);
! pm->peer = cbdataReference(peer);
      if (*url == '/') {
        snprintf(pm->url, sizeof(pm->url), "http://%s:%d%s",
            pm->peer->host, pm->peer->http_port, url);
Index: peer_sourcehash.c
===================================================================
RCS file: /cvsroot/squid/squid/src/Attic/peer_sourcehash.c,v
retrieving revision 1.1.2.3
diff -c -r1.1.2.3 peer_sourcehash.c
*** peer_sourcehash.c 31 Jan 2002 13:58:00 -0000 1.1.2.3
--- peer_sourcehash.c 16 Jun 2002 03:06:34 -0000
***************
*** 60,66 ****
      char *t;
      /* Clean up */
      for (k = 0; k < n_sourcehash_peers; k++) {
! cbdataUnlock(sourcehash_peers[k]);
      }
      safe_free(sourcehash_peers);
      n_sourcehash_peers = 0;
--- 60,66 ----
      char *t;
      /* Clean up */
      for (k = 0; k < n_sourcehash_peers; k++) {
! cbdataReferenceDone(sourcehash_peers[k]);
      }
      safe_free(sourcehash_peers);
      n_sourcehash_peers = 0;
***************
*** 94,101 ****
        if (floor(p->sourcehash.load_factor * 1000.0) == 0.0)
            p->sourcehash.load_factor = 0.0;
        /* add it to our list of peers */
! *P++ = p;
! cbdataLock(p);
      }
      /* Sort our list on weight */
      qsort(sourcehash_peers, n_sourcehash_peers, sizeof(*sourcehash_peers),
peerSortWeight);
--- 94,100 ----
        if (floor(p->sourcehash.load_factor * 1000.0) == 0.0)
            p->sourcehash.load_factor = 0.0;
        /* add it to our list of peers */
! *P++ = cbdataReference(p);
      }
      /* Sort our list on weight */
      qsort(sourcehash_peers, n_sourcehash_peers, sizeof(*sourcehash_peers),
peerSortWeight);
Received on Sat Jun 15 2002 - 21:21:55 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:15:40 MST