diff --git a/www/mod_backhand/files/patch-platform.c b/www/mod_backhand/files/patch-platform.c new file mode 100644 index 000000000000..0e2596579e67 --- /dev/null +++ b/www/mod_backhand/files/patch-platform.c @@ -0,0 +1,204 @@ +--- platform.c_1.12.c Tue Nov 28 06:33:52 2006 ++++ platform.c Tue Nov 28 06:25:27 2006 +@@ -1,46 +1,46 @@ +- /* ====================================================================== +- * Copyright (c) 1998-1999 The Johns Hopkins University. +- * All rights reserved. +- * The following code was written by Theo Schlossnagle for use in the +- * Backhand project at The Center for Networking and Distributed Systems +- * at The Johns Hopkins University. +- * Please refer to the LICENSE file before using this software. +- * ====================================================================== +- */ +- /* This is exported for use in builtins.c */ +- int find_highest_arriba(serverstat *ss) { +- int i, highest=0; +- for(i=0;i0) aload-=1; /* n - delta */ +- aload /= 1000; /* places hwm @ mag(load)*/ +- aload <<= 1; +- while(aload >>=1) i++; /* log2(1+n-delta) */ +- aload = 1 << i; /* 2^(n+1) */ +- for(i=0;i0) aload-=1; /* n - delta */ ++ aload /= 1000; /* places hwm @ mag(load)*/ ++ aload <<= 1; ++ while(aload >>=1) i++; /* log2(1+n-delta) */ ++ aload = 1 << i; /* 2^(n+1) */ ++ for(i=0;ivalue.ul /= 1024; /* pgsize in kb, we want mb */ + physmem = pgsize*kn->value.ul; +- else ++ } else + physmem = 0; + } else if(!strncmp(k->ks_name, "system_misc", 11)) { + sysmisc = k; +@@ -383,10 +402,10 @@ + ss->tmem = physmem; + if(syspages && + kstat_read(kctl, syspages, 0)!=-1 && +- ((kn = (kstat_named_t *)kstat_data_lookup(syspages, "freemem"))!=NULL)) ++ ((kn = (kstat_named_t *)kstat_data_lookup(syspages, "freemem"))!=NULL)) { + kn->value.ul /= 1024; /* pgsize in kb, we want mb */ + ss->amem = pgsize*kn->value.ul; +- else ++ } else + ss->amem = 0; + if(!ss->contact.sin_port) + if(webport) { +@@ -538,10 +557,12 @@ + void initstat(void) { + int mib[2]; + size_t len; ++ long long int memsize; + mib[0] = CTL_HW; + mib[1] = HW_USERMEM; +- len = sizeof(int); +- sysctl(mib, 2, &usermem, &len, NULL, 0); ++ len = sizeof(long long int); ++ sysctl(mib, 2, &memsize, &len, NULL, 0); ++ usermem = (len==4)?(unsigned int) memsize/(1024*1024):(int) (memsize/(1024*1024)); + mib[1] = HW_NCPU; + sysctl(mib, 2, &ncpu, &len, NULL, 0); + mib[1] = HW_PAGESIZE; +@@ -577,7 +598,7 @@ + sysctl(mib, 2, &ourload, &len, NULL, 0); + ss->load = (int)1000.0*((float)ourload.ldavg[0]/(float)ourload.fscale); + ss->load_hwm=set_high_watermark()*1000; +- ss->tmem=(int)usermem/(1024*1024); /* in mb */ ++ ss->tmem=usermem; + #ifdef VM_TOTAL + mib[1] = VM_TOTAL; + #else +@@ -589,8 +610,7 @@ + #endif + len = sizeof(struct vmtotal); + sysctl(mib, 2, &ourmem, &len, NULL, 0); +- ourmem.t_free /= 1024*1024; /* calculate in mb */ +- ss->amem=(int)usermem-(ourpagesize*ourmem.t_free); ++ ss->amem=(int)(ourpagesize*((unsigned long long int)ourmem.t_free)/(1024*1024)); + ss->cpu =(int)ourcpu; + ss->ncpu=(int)ncpu; + /* Fill out hostname */