trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zw...@apache.org
Subject svn commit: r1148096 - in /trafficserver/traffic/trunk: lib/ts/Makefile.am lib/ts/ink_sys_control.cc lib/ts/ink_sys_control.h mgmt/Main.cc proxy/Initialize.cc proxy/Main.cc proxy/logging/LogStandalone.cc
Date Mon, 18 Jul 2011 23:33:12 GMT
Author: zwoop
Date: Mon Jul 18 23:33:11 2011
New Revision: 1148096

URL: http://svn.apache.org/viewvc?rev=1148096&view=rev
Log:
TS-882 traffic_logstats dies when printing log.

Added:
    trafficserver/traffic/trunk/lib/ts/ink_sys_control.cc
    trafficserver/traffic/trunk/lib/ts/ink_sys_control.h
Modified:
    trafficserver/traffic/trunk/lib/ts/Makefile.am
    trafficserver/traffic/trunk/mgmt/Main.cc
    trafficserver/traffic/trunk/proxy/Initialize.cc
    trafficserver/traffic/trunk/proxy/Main.cc
    trafficserver/traffic/trunk/proxy/logging/LogStandalone.cc

Modified: trafficserver/traffic/trunk/lib/ts/Makefile.am
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/lib/ts/Makefile.am?rev=1148096&r1=1148095&r2=1148096&view=diff
==============================================================================
--- trafficserver/traffic/trunk/lib/ts/Makefile.am (original)
+++ trafficserver/traffic/trunk/lib/ts/Makefile.am Mon Jul 18 23:33:11 2011
@@ -109,6 +109,8 @@ libtsutil_la_SOURCES = \
   ink_string++.cc \
   ink_string.h \
   ink_string++.h \
+  ink_sys_control.cc \
+  ink_sys_control.h \
   ink_syslog.cc \
   ink_syslog.h \
   ink_thread.cc \

Added: trafficserver/traffic/trunk/lib/ts/ink_sys_control.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/lib/ts/ink_sys_control.cc?rev=1148096&view=auto
==============================================================================
--- trafficserver/traffic/trunk/lib/ts/ink_sys_control.cc (added)
+++ trafficserver/traffic/trunk/lib/ts/ink_sys_control.cc Mon Jul 18 23:33:11 2011
@@ -0,0 +1,64 @@
+/** @file
+
+  A brief file description
+
+  @section license License
+
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ */
+
+#include "ink_sys_control.h"
+#include "ink_assert.h"
+
+rlim_t
+ink_max_out_rlimit(int which, bool max_it, bool unlim_it)
+{
+  struct rlimit rl;
+
+#if defined(linux)
+#  define MAGIC_CAST(x) (enum __rlimit_resource)(x)
+#else
+#  define MAGIC_CAST(x) x
+#endif
+
+  if (max_it) {
+    ink_release_assert(getrlimit(MAGIC_CAST(which), &rl) >= 0);
+    if (rl.rlim_cur != rl.rlim_max) {
+#if defined(darwin)
+      if (which == RLIMIT_NOFILE)
+        rl.rlim_cur = fmin(OPEN_MAX, rl.rlim_max);
+      else
+        rl.rlim_cur = rl.rlim_max;
+#else
+      rl.rlim_cur = rl.rlim_max;
+#endif
+      ink_release_assert(setrlimit(MAGIC_CAST(which), &rl) >= 0);
+    }
+  }
+
+#if !defined(darwin)
+  if (unlim_it) {
+    ink_release_assert(getrlimit(MAGIC_CAST(which), &rl) >= 0);
+    if (rl.rlim_cur != (rlim_t)RLIM_INFINITY) {
+      rl.rlim_cur = (rl.rlim_max = RLIM_INFINITY);
+      ink_release_assert(setrlimit(MAGIC_CAST(which), &rl) >= 0);
+    }
+  }
+#endif
+  ink_release_assert(getrlimit(MAGIC_CAST(which), &rl) >= 0);
+  return rl.rlim_cur;
+}

Added: trafficserver/traffic/trunk/lib/ts/ink_sys_control.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/lib/ts/ink_sys_control.h?rev=1148096&view=auto
==============================================================================
--- trafficserver/traffic/trunk/lib/ts/ink_sys_control.h (added)
+++ trafficserver/traffic/trunk/lib/ts/ink_sys_control.h Mon Jul 18 23:33:11 2011
@@ -0,0 +1,40 @@
+/** @file
+
+  A brief file description
+
+  @section license License
+
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ */
+
+#ifndef _INK_SYS_CONTROL_H
+#define _INK_SYS_CONTROL_H
+
+#include <sys/resource.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif                          /* __cplusplus */
+
+rlim_t ink_max_out_rlimit(int which, bool max_it=true, bool unlim_it=true);
+
+#ifdef __cplusplus
+}
+#endif                          /* __cplusplus */
+
+#endif /*_INK_SYS_CONTROL_H*/

Modified: trafficserver/traffic/trunk/mgmt/Main.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/mgmt/Main.cc?rev=1148096&r1=1148095&r2=1148096&view=diff
==============================================================================
--- trafficserver/traffic/trunk/mgmt/Main.cc (original)
+++ trafficserver/traffic/trunk/mgmt/Main.cc Mon Jul 18 23:33:11 2011
@@ -32,6 +32,7 @@
 
 #include "ink_config.h"
 #include "ink_platform.h"
+#include "ink_sys_control.h"
 
 #include "Main.h"
 #include "MgmtUtils.h"
@@ -354,50 +355,6 @@ chdir_root()
   }
 }
 
-#define set_rlimit(name,max_it,ulim_it) max_out_limit(#name, name, max_it, ulim_it)
-static rlim_t
-max_out_limit(const char *name, int which, bool max_it = true, bool unlim_it = true)
-{
-  NOWARN_UNUSED(name);
-  struct rlimit rl;
-
-#if defined(linux)
-#  define MAGIC_CAST(x) (enum __rlimit_resource)(x)
-#else
-#  define MAGIC_CAST(x) x
-#endif
-
-  if (max_it) {
-    ink_release_assert(getrlimit(MAGIC_CAST(which), &rl) >= 0);
-    if (rl.rlim_cur != rl.rlim_max) {
-#if defined(darwin)
-      if (which == RLIMIT_NOFILE)
-        rl.rlim_cur = fmin(OPEN_MAX, rl.rlim_max);
-      else
-        rl.rlim_cur = rl.rlim_max;
-#else
-      rl.rlim_cur = rl.rlim_max;
-#endif
-      ink_release_assert(setrlimit(MAGIC_CAST(which), &rl) >= 0);
-    }
-  }
-
-#if !defined(darwin)
-  if (unlim_it) {
-    ink_release_assert(getrlimit(MAGIC_CAST(which), &rl) >= 0);
-    if (rl.rlim_cur != (rlim_t)RLIM_INFINITY) {
-      rl.rlim_cur = (rl.rlim_max = RLIM_INFINITY);
-      ink_release_assert(setrlimit(MAGIC_CAST(which), &rl) >= 0);
-    }
-  }
-#endif
-  ink_release_assert(getrlimit(MAGIC_CAST(which), &rl) >= 0);
-#ifdef MGMT_USE_SYSLOG
-  //syslog(LOG_NOTICE, "NOTE: %s(%d):cur(%d),max(%d)", name, which, (int)rl.rlim_cur, (int)rl.rlim_max);
-#endif
-  return rl.rlim_cur;
-}
-
 
 static void
 set_process_limits(int fds_throttle)
@@ -405,12 +362,12 @@ set_process_limits(int fds_throttle)
   struct rlimit lim;
 
   // Set needed rlimits (root)
-  set_rlimit(RLIMIT_NOFILE, true, false);
-  set_rlimit(RLIMIT_STACK, true, true);
-  set_rlimit(RLIMIT_DATA, true, true);
-  set_rlimit(RLIMIT_FSIZE, true, false);
+  ink_max_out_rlimit(RLIMIT_NOFILE, true, false);
+  ink_max_out_rlimit(RLIMIT_STACK, true, true);
+  ink_max_out_rlimit(RLIMIT_DATA, true, true);
+  ink_max_out_rlimit(RLIMIT_FSIZE, true, false);
 #ifdef RLIMIT_RSS
-  set_rlimit(RLIMIT_RSS, true, true);
+  ink_max_out_rlimit(RLIMIT_RSS, true, true);
 #endif
 
   if (!getrlimit(RLIMIT_NOFILE, &lim)) {

Modified: trafficserver/traffic/trunk/proxy/Initialize.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/Initialize.cc?rev=1148096&r1=1148095&r2=1148096&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/Initialize.cc (original)
+++ trafficserver/traffic/trunk/proxy/Initialize.cc Mon Jul 18 23:33:11 2011
@@ -39,45 +39,6 @@
 #include "Initialize.h" // TODO: move to I_Initialize.h ???
 
 
-#define set_rlimit(name,max_it,ulim_it) max_out_limit(#name, name, max_it, ulim_it)
-static rlim_t
-max_out_limit(const char *name, int which, bool max_it = true, bool unlim_it = true)
-{
-  struct rlimit rl;
-
-#if defined(linux)
-#  define MAGIC_CAST(x) (enum __rlimit_resource)(x)
-#else
-#  define MAGIC_CAST(x) x
-#endif
-
-  if (max_it) {
-    ink_release_assert(getrlimit(MAGIC_CAST(which), &rl) >= 0);
-    if (rl.rlim_cur != rl.rlim_max) {
-#if defined(darwin)
-      if (which == RLIMIT_NOFILE)
-        rl.rlim_cur = fmin(OPEN_MAX, rl.rlim_max);
-      else
-        rl.rlim_cur = rl.rlim_max;
-#else
-      rl.rlim_cur = rl.rlim_max;
-#endif
-      ink_release_assert(setrlimit(MAGIC_CAST(which), &rl) >= 0);
-    }
-  }
-
-  if (unlim_it) {
-    ink_release_assert(getrlimit(MAGIC_CAST(which), &rl) >= 0);
-    if (rl.rlim_cur != RLIM_INFINITY) {
-      rl.rlim_cur = (rl.rlim_max = RLIM_INFINITY);
-      ink_release_assert(setrlimit(MAGIC_CAST(which), &rl) >= 0);
-    }
-  }
-  ink_release_assert(getrlimit(MAGIC_CAST(which), &rl) >= 0);
-  //syslog(LOG_NOTICE, "NOTE: %s(%d):cur(%d),max(%d)", name, which, (int)rl.rlim_cur, (int)rl.rlim_max);
-  return rl.rlim_cur;
-}
-
 //
 // Initialize operating system related information/services
 //
@@ -85,13 +46,13 @@ void
 init_system_settings(void)
 {
   // Delimit file Descriptors
-  fds_limit = set_rlimit(RLIMIT_NOFILE, true, false);
+  fds_limit = ink_max_out_rlimit(RLIMIT_NOFILE, true, false);
 
-  set_rlimit(RLIMIT_STACK,true,true);
-  set_rlimit(RLIMIT_DATA,true,true);
-  set_rlimit(RLIMIT_FSIZE, true, false);
+  ink_max_out_rlimit(RLIMIT_STACK,true,true);
+  ink_max_out_rlimit(RLIMIT_DATA,true,true);
+  ink_max_out_rlimit(RLIMIT_FSIZE, true, false);
 #ifdef RLIMIT_RSS
-  set_rlimit(RLIMIT_RSS,true,true);
+  ink_max_out_rlimit(RLIMIT_RSS,true,true);
 #endif
 }
 

Modified: trafficserver/traffic/trunk/proxy/Main.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/Main.cc?rev=1148096&r1=1148095&r2=1148096&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/Main.cc (original)
+++ trafficserver/traffic/trunk/proxy/Main.cc Mon Jul 18 23:33:11 2011
@@ -33,10 +33,11 @@
 #include "ink_config.h"
 
 #include "libts.h"
+#include "ink_sys_control.h"
+
 #if !defined(linux)
 #include <sys/lock.h>
 #endif
-#include <sys/resource.h>
 #if defined(linux)
 extern "C" int plock(int);
 #else
@@ -274,48 +275,6 @@ ArgumentDescription argument_description
 };
 int n_argument_descriptions = SIZE(argument_descriptions);
 
-
-#define set_rlimit(name,max_it,ulim_it) max_out_limit(#name, name, max_it, ulim_it)
-static rlim_t
-max_out_limit(const char *name, int which, bool max_it = true, bool unlim_it = true)
-{
-  NOWARN_UNUSED(name);
-  struct rlimit rl;
-
-#if defined(linux)
-#  define MAGIC_CAST(x) (enum __rlimit_resource)(x)
-#else
-#  define MAGIC_CAST(x) x
-#endif
-
-  if (max_it) {
-    ink_release_assert(getrlimit(MAGIC_CAST(which), &rl) >= 0);
-    if (rl.rlim_cur != rl.rlim_max) {
-#if defined(darwin)
-      if (which == RLIMIT_NOFILE)
-        rl.rlim_cur = fmin(OPEN_MAX, rl.rlim_max);
-      else
-        rl.rlim_cur = rl.rlim_max;
-#else
-      rl.rlim_cur = rl.rlim_max;
-#endif
-      ink_release_assert(setrlimit(MAGIC_CAST(which), &rl) >= 0);
-    }
-  }
-
-  if (unlim_it) {
-    ink_release_assert(getrlimit(MAGIC_CAST(which), &rl) >= 0);
-    if (rl.rlim_cur != (rlim_t)RLIM_INFINITY) {
-      rl.rlim_cur = (rl.rlim_max = RLIM_INFINITY);
-      ink_release_assert(setrlimit(MAGIC_CAST(which), &rl) >= 0);
-    }
-  }
-  ink_release_assert(getrlimit(MAGIC_CAST(which), &rl) >= 0);
-  //syslog(LOG_NOTICE, "NOTE: %s(%d):cur(%d),max(%d)", name, which, (int)rl.rlim_cur, (int)rl.rlim_max);
-  return rl.rlim_cur;
-}
-
-
 //
 // Initialize operating system related information/services
 //
@@ -338,7 +297,7 @@ init_system()
   //
   // Delimit file Descriptors
   //
-  fds_limit = set_rlimit(RLIMIT_NOFILE, true, false);
+  fds_limit = ink_max_out_rlimit(RLIMIT_NOFILE, true, false);
 }
 
 static void
@@ -1078,11 +1037,11 @@ adjust_sys_settings(void)
     }
   }
 
-  set_rlimit(RLIMIT_STACK,true,true);
-  set_rlimit(RLIMIT_DATA,true,true);
-  set_rlimit(RLIMIT_FSIZE, true, false);
+  ink_max_out_rlimit(RLIMIT_STACK,true,true);
+  ink_max_out_rlimit(RLIMIT_DATA,true,true);
+  ink_max_out_rlimit(RLIMIT_FSIZE, true, false);
 #ifdef RLIMIT_RSS
-  set_rlimit(RLIMIT_RSS,true,true);
+  ink_max_out_rlimit(RLIMIT_RSS,true,true);
 #endif
 
 #endif  // linux check

Modified: trafficserver/traffic/trunk/proxy/logging/LogStandalone.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/logging/LogStandalone.cc?rev=1148096&r1=1148095&r2=1148096&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/logging/LogStandalone.cc (original)
+++ trafficserver/traffic/trunk/proxy/logging/LogStandalone.cc Mon Jul 18 23:33:11 2011
@@ -28,6 +28,7 @@
  ***************************************************************************/
 
 #include "libts.h"
+#include "ink_sys_control.h"
 #include "signals.h"
 #include "DiagsConfig.h"
 #include "Main.h"
@@ -74,34 +75,6 @@ DiagsConfig *diagsConfig = NULL;
 HttpBodyFactory *body_factory = NULL;
 AppVersionInfo appVersionInfo;
 
-
-/*-------------------------------------------------------------------------
-  max_out_limit
-  -------------------------------------------------------------------------*/
-#if defined(linux)
-   /* Stupid PICKY stupid (did I mention that?) C++ compielrs */
-#define RLIMCAST enum __rlimit_resource
-#else
-#define RLIMCAST int
-#endif
-
-static rlim_t
-max_out_limit(int which, bool max_it)
-{
-  struct rlimit rl;
-
-  ink_release_assert(getrlimit((RLIMCAST) which, &rl) >= 0);
-  if (max_it) {
-    rl.rlim_cur = rl.rlim_max;
-    ink_release_assert(setrlimit((RLIMCAST) which, &rl) >= 0);
-  }
-
-  ink_release_assert(getrlimit((RLIMCAST) which, &rl) >= 0);
-  rlim_t ret = rl.rlim_cur;
-
-  return ret;
-}
-
 /*-------------------------------------------------------------------------
   init_system
   -------------------------------------------------------------------------*/
@@ -109,9 +82,7 @@ max_out_limit(int which, bool max_it)
 void
 init_system()
 {
-
-  fds_limit = max_out_limit(RLIMIT_NOFILE, true);
-
+  fds_limit = ink_max_out_rlimit(RLIMIT_NOFILE, true, false);
 
   init_signals();
   syslog(LOG_NOTICE, "NOTE: --- SAC Starting ---");



Mime
View raw message