[PATCH] Various 4GB+ fixes

Kristian Lyngstol kristian at varnish-software.com
Fri Apr 15 17:15:51 CEST 2011


Mainly changing int/usigned to size_t/ssize_t and a bit of %u to %lu etc.
Not _too_ thoroughly tested, but it went through and the expiry didn't
blast apart any more. A quick look-through before push/commit would be
nice. (Ops, just spotted my white-space mix-up. I'll fix before push)
---
 bin/varnishd/cache.h          |    8 ++++----
 bin/varnishd/cache_center.c   |    8 +++++---
 bin/varnishd/cache_fetch.c    |    4 ++--
 bin/varnishd/cache_response.c |    2 +-
 bin/varnishd/cache_wrw.c      |    6 +++---
 5 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/bin/varnishd/cache.h b/bin/varnishd/cache.h
index a1ea70c..d691fa6 100644
--- a/bin/varnishd/cache.h
+++ b/bin/varnishd/cache.h
@@ -362,8 +362,8 @@ struct storage {
 	void			*priv;
 
 	unsigned char		*ptr;
-	unsigned		len;
-	unsigned		space;
+	ssize_t		len;
+	ssize_t		space;
 
 	int			fd;
 	off_t			where;
@@ -807,10 +807,10 @@ void WRW_EndChunk(struct worker *w);
 void WRW_Reserve(struct worker *w, int *fd);
 unsigned WRW_Flush(struct worker *w);
 unsigned WRW_FlushRelease(struct worker *w);
-unsigned WRW_Write(struct worker *w, const void *ptr, int len);
+ssize_t WRW_Write(struct worker *w, const void *ptr, size_t len);
 unsigned WRW_WriteH(struct worker *w, const txt *hh, const char *suf);
 #ifdef SENDFILE_WORKS
-void WRW_Sendfile(struct worker *w, int fd, off_t off, unsigned len);
+void WRW_Sendfile(struct worker *w, int fd, off_t off, ssize_t len);
 #endif  /* SENDFILE_WORKS */
 
 typedef void *bgthread_t(struct sess *, void *priv);
diff --git a/bin/varnishd/cache_center.c b/bin/varnishd/cache_center.c
index 1c1118c..d753fa7 100644
--- a/bin/varnishd/cache_center.c
+++ b/bin/varnishd/cache_center.c
@@ -325,7 +325,7 @@ cnt_done(struct sess *sp)
 		da = sp->t_end - sp->t_resp;
 		dh = sp->t_req - sp->t_open;
 		/* XXX: Add StatReq == StatSess */
-		WSP(sp, SLT_Length, "%u", sp->acct_req.bodybytes);
+		WSP(sp, SLT_Length, "%lu", sp->acct_req.bodybytes);
 		WSL(sp->wrk, SLT_ReqEnd, sp->id, "%u %.9f %.9f %.9f %.9f %.9f",
 		    sp->xid, sp->t_req, sp->t_end, dh, dp, da);
 	}
@@ -628,9 +628,11 @@ cnt_fetchbody(struct sess *sp)
 	int i;
 	struct http *hp, *hp2;
 	char *b;
-	unsigned l, nhttp;
+	ssize_t l;
+	unsigned nhttp;
 	struct vsb *vary = NULL;
-	int varyl = 0, pass;
+	size_t varyl = 0;
+	int pass;
 
 	assert(sp->handling == VCL_RET_HIT_FOR_PASS ||
 	    sp->handling == VCL_RET_DELIVER);
diff --git a/bin/varnishd/cache_fetch.c b/bin/varnishd/cache_fetch.c
index 87ce092..0f5dcc4 100644
--- a/bin/varnishd/cache_fetch.c
+++ b/bin/varnishd/cache_fetch.c
@@ -570,7 +570,7 @@ FetchBody(struct sess *sp)
 	if (cls == 0 && sp->wrk->do_close)
 		cls = 1;
 
-	WSL(sp->wrk, SLT_Length, sp->vbc->fd, "%u", sp->obj->len);
+	WSL(sp->wrk, SLT_Length, sp->vbc->fd, "%lu", sp->obj->len);
 
 	{
 	/* Sanity check fetch methods accounting */
@@ -585,7 +585,7 @@ FetchBody(struct sess *sp)
 	if (mklen > 0) {
 		http_Unset(sp->obj->http, H_Content_Length);
 		http_PrintfHeader(sp->wrk, sp->fd, sp->obj->http,
-		    "Content-Length: %u", sp->obj->len);
+		    "Content-Length: %lu", sp->obj->len);
 	}
 
 	if (cls)
diff --git a/bin/varnishd/cache_response.c b/bin/varnishd/cache_response.c
index 2fbf120..0a2f3e9 100644
--- a/bin/varnishd/cache_response.c
+++ b/bin/varnishd/cache_response.c
@@ -281,7 +281,7 @@ res_WriteGunzipObj(struct sess *sp)
 static void
 res_WriteDirObj(struct sess *sp, size_t low, size_t high)
 {
-	unsigned u = 0;
+	ssize_t u = 0;
 	size_t ptr, off, len;
 	struct storage *st;
 
diff --git a/bin/varnishd/cache_wrw.c b/bin/varnishd/cache_wrw.c
index 2340aa3..8aaa5c1 100644
--- a/bin/varnishd/cache_wrw.c
+++ b/bin/varnishd/cache_wrw.c
@@ -175,8 +175,8 @@ WRW_WriteH(struct worker *w, const txt *hh, const char *suf)
 	return (u);
 }
 
-unsigned
-WRW_Write(struct worker *w, const void *ptr, int len)
+ssize_t
+WRW_Write(struct worker *w, const void *ptr, size_t len)
 {
 	struct wrw *wrw;
 
@@ -237,7 +237,7 @@ WRW_EndChunk(struct worker *w)
 
 #ifdef SENDFILE_WORKS
 void
-WRW_Sendfile(struct worker *w, int fd, off_t off, unsigned len)
+WRW_Sendfile(struct worker *w, int fd, off_t off, ssize_t len)
 {
 	struct wrw *wrw;
 
-- 
1.7.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: Digital signature
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-dev/attachments/20110415/12b911af/attachment-0003.pgp>


More information about the varnish-dev mailing list