TS-1208 check_memory() in traffic_cop never active on linux

Set the default value to 0, then check_memory() is not activated.


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/4482078b
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/4482078b
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/4482078b

Branch: refs/heads/master
Commit: 4482078b0bb8fad4e1b37ce451a534b8413356b6
Parents: d4607a2
Author: Zhao Yongming <[email protected]>
Authored: Wed Apr 18 15:18:47 2012 +0800
Committer: Zhao Yongming <[email protected]>
Committed: Sat Apr 28 02:35:48 2012 +0800

----------------------------------------------------------------------
 cop/TrafficCop.cc     |   25 ++++++++-----------------
 mgmt/RecordsConfig.cc |    4 ++--
 2 files changed, 10 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4482078b/cop/TrafficCop.cc
----------------------------------------------------------------------
diff --git a/cop/TrafficCop.cc b/cop/TrafficCop.cc
index 57cd78d..9ff96d8 100644
--- a/cop/TrafficCop.cc
+++ b/cop/TrafficCop.cc
@@ -66,11 +66,8 @@ static char cop_lockfile[PATH_NAME_MAX];
 static char manager_lockfile[PATH_NAME_MAX];
 static char server_lockfile[PATH_NAME_MAX];
 
-#if defined(linux)
-static bool check_memory_required = false;
-#endif
-static int check_memory_min_swapfree_kb = 10240;
-static int check_memory_min_memfree_kb = 10240;
+static int check_memory_min_swapfree_kb = 0;
+static int check_memory_min_memfree_kb = 0;
 
 static int syslog_facility = LOG_DAEMON;
 static char syslog_fac_str[PATH_NAME_MAX] = "LOG_DAEMON";
@@ -1567,11 +1564,15 @@ check_programs()
 static void
 check_memory()
 {
+  // TODO: We need to take care of other systems, ie bsd, solaris.
+  //    And we should try to summarize whether the swapping is really
+  //    putting the server under memory pressure. Or should we check
+  //    the process memory usage of the server & manager?
 #ifdef TRACE_LOG_COP
   cop_log(COP_DEBUG, "Entering check_memory()\n");
 #endif
 #if defined(linux)
-  if (check_memory_required) {
+  if (check_memory_min_swapfree_kb > 0 || check_memory_min_memfree_kb > 0) {
     FILE *fp;
     char buf[LINE_MAX];
     long long memfree, swapfree, swapsize;
@@ -1586,7 +1587,7 @@ check_memory()
           swapsize = strtoll(buf + sizeof "SwapTotal:" - 1, 0, 10);
       }
       fclose(fp);
-      // simple heuristic for linux 2.2.x
+      // simple heuristic for linux
       //    swapsize swapfree memfree
       // 1:    >0      low     high    (bad)
       // 2:    >0      high    low     (okay)
@@ -1897,16 +1898,6 @@ init()
   init_lockfiles();
   check_lockfile();
 
-#if defined(linux)
-  struct utsname buf;
-  if (uname(&buf) >= 0) {
-    if (strncmp(buf.release, "2.2.", 4) == 0) {
-      cop_log(COP_WARNING, "Linux 2.2.x kernel detected; enabling low memory 
fault protection");
-      check_memory_required = true;
-    }
-  }
-#endif
-
 #ifdef TRACE_LOG_COP
   cop_log(COP_DEBUG, "Leaving init()\n");
 #endif

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4482078b/mgmt/RecordsConfig.cc
----------------------------------------------------------------------
diff --git a/mgmt/RecordsConfig.cc b/mgmt/RecordsConfig.cc
index e5a5a2a..b74f51a 100644
--- a/mgmt/RecordsConfig.cc
+++ b/mgmt/RecordsConfig.cc
@@ -87,9 +87,9 @@ RecordElement RecordsConfig[] = {
   ,
   {RECT_CONFIG, "proxy.config.cop.core_signal", RECD_INT, "0", RECU_NULL, 
RR_REQUIRED, RECC_NULL, NULL, RECA_NULL}
   ,                             // needed by traffic_cop
-  {RECT_CONFIG, "proxy.config.cop.linux_min_swapfree_kb", RECD_INT, "10240", 
RECU_NULL, RR_REQUIRED, RECC_NULL, NULL, RECA_NULL}
+  {RECT_CONFIG, "proxy.config.cop.linux_min_swapfree_kb", RECD_INT, "0", 
RECU_NULL, RR_REQUIRED, RECC_NULL, NULL, RECA_NULL}
   ,                             // needed by traffic_cop
-  {RECT_CONFIG, "proxy.config.cop.linux_min_memfree_kb", RECD_INT, "10240", 
RECU_NULL, RR_REQUIRED, RECC_NULL, NULL, RECA_NULL}
+  {RECT_CONFIG, "proxy.config.cop.linux_min_memfree_kb", RECD_INT, "0", 
RECU_NULL, RR_REQUIRED, RECC_NULL, NULL, RECA_NULL}
   ,                             // needed by traffic_cop
   //# 0 = disable (seconds)
   {RECT_CONFIG, "proxy.config.dump_mem_info_frequency", RECD_INT, "0", 
RECU_NULL, RR_NULL, RECC_NULL, NULL, RECA_NULL}

Reply via email to