From: Frédéric Marchal Date: Mon, 13 Jul 2009 08:27:20 +0000 (+0000) Subject: Moved local variables declared at the global scope to the function that use them. X-Git-Tag: v2_2_6~58 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=243a9fab9be5b9377d5f561b06ebfd2a7d9b6938;p=thirdparty%2Fsarg.git Moved local variables declared at the global scope to the function that use them. Display a warning if no resource is defined to limit the number of open files. --- diff --git a/include/conf.h b/include/conf.h index f9a2c71..47ded96 100755 --- a/include/conf.h +++ b/include/conf.h @@ -322,7 +322,6 @@ int dotinuser; int realtime_refresh; int realtime_access_log_lines; int realt; -int x, y; int rc; int ntopsites; int nsitesusers; @@ -330,7 +329,6 @@ int nrepday; int ndownload; int ntopuser; int squid24; -long l1, l2; float perc; long long int twork; diff --git a/log.c b/log.c index eb27ac3..5e8430f 100644 --- a/log.c +++ b/log.c @@ -650,10 +650,15 @@ int main(int argc,char *argv[]) debuga("sarg %s: %s",text[73],VERSION); if (strlen(Ulimit) > 0) { + long l1, l2; + int rc=0; + #if defined(RLIMIT_NOFILE) getrlimit (RLIMIT_NOFILE, &rl); #elif defined(RLIMIT_OFILE) getrlimit (RLIMIT_OFILE, &rl); +#else +#warning "No rlimit resource for the number of open files" #endif l1 = rl.rlim_cur; l2 = rl.rlim_max; @@ -661,12 +666,15 @@ int main(int argc,char *argv[]) if(Ulimit[0] != '\0') { rl.rlim_cur = atol(Ulimit); rl.rlim_max = atol(Ulimit); - #if defined(RLIMIT_NOFILE) - if(setrlimit (RLIMIT_NOFILE, &rl) == -1) { - #elif defined(RLIMIT_OFILE) - if(setrlimit (RLIMIT_OFILE, &rl) == -1) { - #endif - debuga("setrlimit error - %s\n",strerror(errno)); +#if defined(RLIMIT_NOFILE) + rc=setrlimit (RLIMIT_NOFILE, &rl); +#elif defined(RLIMIT_OFILE) + rc=setrlimit (RLIMIT_OFILE, &rl); +#else +#warning "No rlimit resource for the number of open files" +#endif + if(rc == -1) { + debuga("setrlimit error - %s\n",strerror(errno)); } }