summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2015-07-13 05:51:04 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2015-07-13 05:51:04 +0200
commit41372f346ae5636e59284ff698d8202e8301641f (patch)
tree0680939b9f2f1c49311edd05c6d2a71e4500f1eb
parent39c9f1abbb11b310e77f43fe4f5e580f1791be67 (diff)
httpfile: fix evictblock() so we wont consume all the memory
-rw-r--r--sys/src/cmd/ip/httpfile.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/sys/src/cmd/ip/httpfile.c b/sys/src/cmd/ip/httpfile.c
index b5c1dbdfc..995a1cfaa 100644
--- a/sys/src/cmd/ip/httpfile.c
+++ b/sys/src/cmd/ip/httpfile.c
@@ -114,11 +114,11 @@ evictblock(Blocklist *cache)
for(l=&cache->first; (b=*l) != nil; l=&b->link){
if(b->rq != nil) /* dont touch block when still requests queued */
continue;
- if(b->rq != nil && (oldest == nil || (*oldest)->lastuse > b->lastuse))
+ if(oldest == nil || (*oldest)->lastuse > b->lastuse)
oldest = l;
}
- if(oldest == nil)
+ if(oldest == nil || *oldest == nil || (*oldest)->rq != nil)
return;
b = *oldest;
@@ -439,8 +439,7 @@ finishthread(void*)
b = recvp(finishchan);
assert(b == inprogress.first);
inprogress.first = b->link;
- ncache++;
- if(ncache >= mcache)
+ if(++ncache >= mcache)
evictblock(&cache);
addblock(&cache, b);
while((r = b->rq) != nil){
@@ -448,7 +447,7 @@ finishthread(void*)
r->aux = nil;
readfrom(r, b);
}
- if(inprogress.first)
+ if(inprogress.first != nil)
sendp(httpchan, inprogress.first);
}
}