]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Moved local variables declared at the global scope to the function that use them.
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Mon, 13 Jul 2009 08:27:20 +0000 (08:27 +0000)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Mon, 13 Jul 2009 08:27:20 +0000 (08:27 +0000)
Display a warning if no resource is defined to limit the number of open files.

include/conf.h
log.c

index f9a2c712bbe55188db2eced21ce4b923302eda4c..47ded9657adfadb7ecc33fabd47ffbb4636c19fb 100755 (executable)
@@ -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 eb27ac3b3358cc82e2d3925d715f1bbdcd638394..5e8430f22795536a1732312153ad5be04884ef03 100644 (file)
--- 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));
          }
       }