[prev in list] [next in list] [prev in thread] [next in thread] 

List:       squid-cvs
Subject:    store_copy squid/src net_db.c,1.26,1.26.2.1
From:       Adrian Chadd <adri () users ! sourceforge ! net>
Date:       2007-11-30 4:29:05
Message-ID: 20071130042915.53852.qmail () squid-cache ! org
[Download RAW message or body]

Update of cvs.devel.squid-cache.org:/cvsroot/squid/squid/src

Modified Files:
      Tag: store_copy
	net_db.c 
Log Message:
Convert the net_db code over to use storeClientRef()



Index: net_db.c
===================================================================
RCS file: /cvsroot/squid/squid/src/net_db.c,v
retrieving revision 1.26
retrieving revision 1.26.2.1
diff -C2 -d -r1.26 -r1.26.2.1
*** net_db.c	23 Sep 2007 14:51:44 -0000	1.26
--- net_db.c	30 Nov 2007 04:29:03 -0000	1.26.2.1
***************
*** 45,50 ****
      squid_off_t seen;
      squid_off_t used;
-     size_t buf_sz;
-     char *buf;
  } netdbExchangeState;
  
--- 45,48 ----
***************
*** 69,73 ****
  static FREE netdbFreeNameEntry;
  static FREE netdbFreeNetdbEntry;
! static STCB netdbExchangeHandleReply;
  static void netdbExchangeDone(void *);
  #if USE_ICMP
--- 67,71 ----
  static FREE netdbFreeNameEntry;
  static FREE netdbFreeNetdbEntry;
! static STNCB netdbExchangeHandleReply;
  static void netdbExchangeDone(void *);
  #if USE_ICMP
***************
*** 531,536 ****
  
  static void
! netdbExchangeHandleReply(void *data, char *buf, ssize_t size)
  {
      netdbExchangeState *ex = data;
      int rec_sz = 0;
--- 529,535 ----
  
  static void
! netdbExchangeHandleReply(void *data, mem_node_ref nr, ssize_t size)
  {
+     const char *buf = nr.node->data + nr.offset;
      netdbExchangeState *ex = data;
      int rec_sz = 0;
***************
*** 539,547 ****
      double rtt;
      double hops;
!     char *p;
      int j;
      HttpReply *rep;
      size_t hdr_sz;
      int nused = 0;
      rec_sz = 0;
      rec_sz += 1 + sizeof(addr.s_addr);
--- 538,548 ----
      double rtt;
      double hops;
!     const char *p;
      int j;
      HttpReply *rep;
      size_t hdr_sz;
      int nused = 0;
+     assert(size <= nr.node->len - nr.offset);
+ 
      rec_sz = 0;
      rec_sz += 1 + sizeof(addr.s_addr);
***************
*** 553,557 ****
  	debug(38, 3) ("netdbExchangeHandleReply: Peer became invalid\n");
  	netdbExchangeDone(ex);
! 	return;
      }
      debug(38, 3) ("netdbExchangeHandleReply: for '%s:%d'\n", ex->p->host, ex->p->http_port);
--- 554,558 ----
  	debug(38, 3) ("netdbExchangeHandleReply: Peer became invalid\n");
  	netdbExchangeDone(ex);
!         goto finish;
      }
      debug(38, 3) ("netdbExchangeHandleReply: for '%s:%d'\n", ex->p->host, ex->p->http_port);
***************
*** 568,572 ****
  	    if (HTTP_OK != rep->sline.status) {
  		netdbExchangeDone(ex);
! 		return;
  	    }
  	    assert(size >= hdr_sz);
--- 569,573 ----
  	    if (HTTP_OK != rep->sline.status) {
  		netdbExchangeDone(ex);
!                 goto finish;
  	    }
  	    assert(size >= hdr_sz);
***************
*** 575,582 ****
  	    p += hdr_sz;
  	} else {
! 	    if (size >= ex->buf_sz) {
  		debug(38, 3) ("netdbExchangeHandleReply: Too big HTTP header, aborting\n");
  		netdbExchangeDone(ex);
! 		return;
  	    } else {
  		size = 0;
--- 576,583 ----
  	    p += hdr_sz;
  	} else {
! 	    if (size >= SM_PAGE_SIZE) {
  		debug(38, 3) ("netdbExchangeHandleReply: Too big HTTP header, aborting\n");
  		netdbExchangeDone(ex);
!                 goto finish;
  	    } else {
  		size = 0;
***************
*** 613,617 ****
  		debug(38, 1) ("netdbExchangeHandleReply: corrupt data, aborting\n");
  		netdbExchangeDone(ex);
! 		return;
  	    }
  	}
--- 614,618 ----
  		debug(38, 1) ("netdbExchangeHandleReply: corrupt data, aborting\n");
  		netdbExchangeDone(ex);
!                 goto finish;
  	    }
  	}
***************
*** 637,650 ****
      } else if (ex->e->store_status == STORE_PENDING) {
  	debug(38, 3) ("netdbExchangeHandleReply: STORE_PENDING\n");
! 	storeClientCopy(ex->sc, ex->e, ex->seen, ex->used, ex->buf_sz,
! 	    ex->buf, netdbExchangeHandleReply, ex);
      } else if (ex->seen < ex->e->mem_obj->inmem_hi) {
  	debug(38, 3) ("netdbExchangeHandleReply: ex->e->mem_obj->inmem_hi\n");
! 	storeClientCopy(ex->sc, ex->e, ex->seen, ex->used, ex->buf_sz,
! 	    ex->buf, netdbExchangeHandleReply, ex);
      } else {
  	debug(38, 3) ("netdbExchangeHandleReply: Done\n");
  	netdbExchangeDone(ex);
      }
  }
  
--- 638,654 ----
      } else if (ex->e->store_status == STORE_PENDING) {
  	debug(38, 3) ("netdbExchangeHandleReply: STORE_PENDING\n");
! 	storeClientRef(ex->sc, ex->e, ex->seen, ex->used, SM_PAGE_SIZE,
! 	    netdbExchangeHandleReply, ex);
      } else if (ex->seen < ex->e->mem_obj->inmem_hi) {
  	debug(38, 3) ("netdbExchangeHandleReply: ex->e->mem_obj->inmem_hi\n");
! 	storeClientRef(ex->sc, ex->e, ex->seen, ex->used, SM_PAGE_SIZE,
! 	    netdbExchangeHandleReply, ex);
      } else {
  	debug(38, 3) ("netdbExchangeHandleReply: Done\n");
  	netdbExchangeDone(ex);
      }
+ finish:
+     buf = NULL;
+     stmemNodeUnref(&nr);  
  }
  
***************
*** 654,658 ****
      netdbExchangeState *ex = data;
      debug(38, 3) ("netdbExchangeDone: %s\n", storeUrl(ex->e));
-     memFree(ex->buf, MEM_4K_BUF);
      requestUnlink(ex->r);
      storeClientUnregister(ex->sc, ex->e, ex);
--- 658,661 ----
***************
*** 998,1007 ****
      httpBuildVersion(&ex->r->http_ver, 1, 0);
      ex->e = storeCreateEntry(uri, null_request_flags, METHOD_GET);
-     ex->buf_sz = 4096;
-     ex->buf = memAllocate(MEM_4K_BUF);
      assert(NULL != ex->e);
      ex->sc = storeClientRegister(ex->e, ex);
!     storeClientCopy(ex->sc, ex->e, ex->seen, ex->used, ex->buf_sz,
! 	ex->buf, netdbExchangeHandleReply, ex);
      ex->r->flags.loopdetect = 1;	/* cheat! -- force direct */
      if (p->login)
--- 1001,1008 ----
      httpBuildVersion(&ex->r->http_ver, 1, 0);
      ex->e = storeCreateEntry(uri, null_request_flags, METHOD_GET);
      assert(NULL != ex->e);
      ex->sc = storeClientRegister(ex->e, ex);
!     storeClientRef(ex->sc, ex->e, ex->seen, ex->used, SM_PAGE_SIZE,
! 	netdbExchangeHandleReply, ex);
      ex->r->flags.loopdetect = 1;	/* cheat! -- force direct */
      if (p->login)

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic