You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2013/12/14 22:51:35 UTC

[26/50] git commit: TS-548: remove Initialize.cc Initialize.h

TS-548: remove Initialize.cc Initialize.h


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

Branch: refs/heads/5.0.x
Commit: 707a5e7cfcbcbc7cd972eca75f6453fc21a8c03a
Parents: 0b3367a
Author: Zhao Yongming <mi...@gmail.com>
Authored: Sat Dec 7 15:34:51 2013 +0800
Committer: Zhao Yongming <mi...@gmail.com>
Committed: Sat Dec 7 15:35:25 2013 +0800

----------------------------------------------------------------------
 CHANGES             |   2 +
 proxy/Initialize.cc | 304 -----------------------------------------------
 proxy/Initialize.h  |  57 ---------
 3 files changed, 2 insertions(+), 361 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/707a5e7c/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index be9c8c7..2e1e7b6 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 4.2.0
 
+  *) [TS-548] remove Initialize.cc Initialize.h
+
   *) [TS-2082] remove STANDALONE_IOCORE FIXME_NONMODULAR and NON_MODULAR defines
 
   *) [TS-312] Add option to always share keep-alive connections to the origin server

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/707a5e7c/proxy/Initialize.cc
----------------------------------------------------------------------
diff --git a/proxy/Initialize.cc b/proxy/Initialize.cc
deleted file mode 100644
index 54026ba..0000000
--- a/proxy/Initialize.cc
+++ /dev/null
@@ -1,304 +0,0 @@
-/** @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.
- */
-
-/****************************************************************************
-
-   Initialize.cc --
-   Created On      : Fri Feb  5 18:22:05 1999
-
-   Description:
- ****************************************************************************/
-#include "libts.h"
-
-#include "Diags.h"
-#include "I_EventSystem.h"
-#include "I_Net.h"
-#include "I_Layout.h"
-#include "I_Version.h"
-
-#include "Initialize.h" // TODO: move to I_Initialize.h ???
-#include "ink_sys_control.h"
-
-extern char* admin_user;
-
-//
-// Initialize operating system related information/services
-//
-void
-init_system_settings(void)
-{
-  // Delimit file Descriptors
-  fds_limit = 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
-  ink_max_out_rlimit(RLIMIT_RSS,true,true);
-#endif
-}
-
-#if defined(linux)
-#include <sys/prctl.h>
-#endif
-
-static int
-set_core_size(const char */* name ATS_UNUSED */, RecDataT /* data_type ATS_UNUSED */, RecData data, void */* opaque_token ATS_UNUSED */)
-{
-
-  RecInt size = data.rec_int;
-  struct rlimit lim;
-  bool failed = false;
-
-  if (getrlimit(RLIMIT_CORE, &lim) < 0) {
-    failed = true;
-  } else {
-    if (size < 0) {
-      lim.rlim_cur = lim.rlim_max;
-    } else {
-      lim.rlim_cur = (rlim_t) size;
-    }
-    if (setrlimit(RLIMIT_CORE, &lim) < 0) {
-      failed = true;
-    }
-#if defined(linux)
-#ifndef PR_SET_DUMPABLE
-#define PR_SET_DUMPABLE 4
-#endif
-    if (size != 0)
-      prctl(PR_SET_DUMPABLE, 1, 0, 0, 0);
-#endif
-  }
-
-  if (failed == true) {
-    Warning("Failed to set Core Limit : %s", strerror(errno));
-  }
-  return 0;
-}
-
-void
-init_system_core_size(void)
-{
-  bool found;
-  RecInt coreSize;
-  found = (RecGetRecordInt("proxy.config.core_limit", &coreSize) == REC_ERR_OKAY);
-  if (found == false) {
-    Warning("Unable to determine core limit");
-  } else {
-    RecData rec_temp;
-    rec_temp.rec_int = coreSize;
-    set_core_size(NULL, RECD_INT, rec_temp, NULL);
-    found = (REC_RegisterConfigUpdateFunc("proxy.config.core_limit", set_core_size, NULL) == REC_ERR_OKAY);
-    ink_assert(found);
-  }
-}
-
-
-int system_syslog_facility = LOG_DAEMON;
-
-//   Reads the syslog configuration variable
-//     and sets the global integer for the
-//     facility and calls open log with the
-//     new facility
-void
-init_system_syslog_log_configure(void)
-{
-  char *facility_str = NULL;
-  int facility;
-
-  REC_ReadConfigStringAlloc(facility_str, "proxy.config.syslog_facility");
-
-  if (facility_str == NULL || (facility = facility_string_to_int(facility_str)) < 0) {
-    syslog(LOG_WARNING, "Bad or missing syslog facility.  " "Defaulting to LOG_DAEMON");
-  } else {
-    system_syslog_facility = facility;
-    closelog();
-    openlog("traffic_server", LOG_PID | LOG_NDELAY | LOG_NOWAIT, facility);
-  }
-}
-
-
-void
-init_system_adjust_num_of_net_threads(void)
-{
-  float autoconfig_scale = 1.0;
-  int nth_auto_config = 1;
-  int num_of_threads_tmp = 1;
-
-  REC_ReadConfigInteger(nth_auto_config, "proxy.config.exec_thread.autoconfig");
-  if (!nth_auto_config) {
-    REC_ReadConfigInteger(num_of_threads_tmp, "proxy.config.exec_thread.limit");
-    if (num_of_threads_tmp <= 0)
-      num_of_threads_tmp = 1;
-    else if (num_of_threads_tmp > MAX_NUMBER_OF_THREADS)
-      num_of_threads_tmp = MAX_NUMBER_OF_THREADS;
-    system_num_of_net_threads = num_of_threads_tmp;
-    if (is_debug_tag_set("threads")) {
-      fprintf(stderr, "# net threads Auto config - disabled - use config file settings\n");
-    }
-  } else {                      /* autoconfig is enabled */
-    num_of_threads_tmp = system_num_of_net_threads;
-    REC_ReadConfigFloat(autoconfig_scale, "proxy.config.exec_thread.autoconfig.scale");
-    num_of_threads_tmp = (int) ((float) num_of_threads_tmp * autoconfig_scale);
-    if (num_of_threads_tmp) {
-      system_num_of_net_threads = num_of_threads_tmp;
-    }
-    if (unlikely(num_of_threads_tmp > MAX_NUMBER_OF_THREADS)) {
-      num_of_threads_tmp = MAX_NUMBER_OF_THREADS;
-    }
-    if (is_debug_tag_set("threads")) {
-      fprintf(stderr, "# net threads Auto config - enabled\n");
-      fprintf(stderr, "# autoconfig scale: %f\n", autoconfig_scale);
-      fprintf(stderr, "# scaled number of net threads: %d\n", num_of_threads_tmp);
-    }
-  }
-
-  if (is_debug_tag_set("threads")) {
-    fprintf(stderr, "# number of net threads: %d\n", system_num_of_net_threads);
-  }
-  if (unlikely(system_num_of_net_threads <= 0)) {      /* impossible case -just for protection */
-    Warning("Number of Net Threads should be greater than 0");
-    system_num_of_net_threads = 1;
-  }
-}
-
-
-//////////////////////////////////////////////////////////////////////////////
-//
-//      void reconfigure_diags()
-//
-//      This function extracts the current diags configuration settings from
-//      records.config, and rebuilds the Diags data structures.
-//
-//////////////////////////////////////////////////////////////////////////////
-void
-init_system_reconfigure_diags(void)
-{
-  int i;
-  DiagsConfigState c;
-
-  // initial value set to 0 or 1 based on command line tags
-  c.enabled[DiagsTagType_Debug] = (diags->base_debug_tags != NULL);
-  c.enabled[DiagsTagType_Action] = (diags->base_action_tags != NULL);
-
-  c.enabled[DiagsTagType_Debug] = 1;
-  c.enabled[DiagsTagType_Action] = 1;
-  diags->show_location = 1;
-
-  // read output routing values
-  for (i = 0; i < DiagsLevel_Count; i++) {
-
-    c.outputs[i].to_stdout = 0;
-    c.outputs[i].to_stderr = 1;
-    c.outputs[i].to_syslog = 1;
-    c.outputs[i].to_diagslog = 1;
-  }
-
-  //////////////////////////////
-  // clear out old tag tables //
-  //////////////////////////////
-  diags->deactivate_all(DiagsTagType_Debug);
-  diags->deactivate_all(DiagsTagType_Action);
-
-  //////////////////////////////////////////////////////////////////////
-  //                     add new tag tables
-  //////////////////////////////////////////////////////////////////////
-  if (diags->base_debug_tags)
-    diags->activate_taglist(diags->base_debug_tags, DiagsTagType_Debug);
-  if (diags->base_action_tags)
-    diags->activate_taglist(diags->base_action_tags, DiagsTagType_Action);
-
-  ////////////////////////////////////
-  // change the diags config values //
-  ////////////////////////////////////
-#if !defined(__GNUC__) && !defined(hpux)
-  diags->config = c;
-#else
-  memcpy(((void *) &diags->config), ((void *) &c), sizeof(DiagsConfigState));
-#endif
-
-}
-
-void
-chown_file_to_user(const char *file, const char *user)
-{
-  struct passwd *pwd = NULL;
-
-  if (user && *user) {
-    if (*user == '#') {
-      int uid = atoi(user + 1);
-      if (uid == -1) {
-        // XXX: Can this call hapen after setuid?
-        uid = (int)geteuid();
-      }
-      pwd = getpwuid((uid_t)uid);
-    } else {
-      pwd = getpwnam(user);
-    }
-    if (pwd) {
-      if (chown(file, pwd->pw_uid, pwd->pw_gid) < 0) {
-          diags->print(NULL, DL_Warning, __FILE__, __FUNCTION__, __LINE__, "cop couldn't chown the  file: '%s' [%d] %s\n",
-         file, errno, strerror(errno)
-       );
-      }
-    } else {
-        diags->print(NULL, DL_Warning, __FILE__, __FUNCTION__, __LINE__, "can't get passwd entry for the admin user '%s' - [%d] %s\n", user, errno, strerror(errno));
-    }
-  } else {
-      diags->print(NULL, DL_Warning, __FILE__, __FUNCTION__, __LINE__, "Admin user was the empty string.\n");
-  }
-}
-
-void
-init_system_diags(char *bdt, char *bat)
-{
-  FILE *diags_log_fp = NULL;
-  char diags_logpath[PATH_NAME_MAX + 1];
-
-  ink_filepath_make(diags_logpath, sizeof(diags_logpath),
-                    Layout::get()->logdir, DIAGS_LOG_FILE);
-
-  diags_log_fp = fopen(diags_logpath, "w");
-  if (diags_log_fp) {
-    int status;
-    chown_file_to_user(diags_logpath, admin_user);
-    status = setvbuf(diags_log_fp, NULL, _IOLBF, 512);
-    if (status != 0) {
-      fclose(diags_log_fp);
-      diags_log_fp = NULL;
-    }
-  }
-
-  diags = NEW(new Diags(bdt, bat, diags_log_fp));
-  if (diags_log_fp == NULL) {
-    SrcLoc loc(__FILE__, __FUNCTION__, __LINE__);
-
-    diags->print(NULL, DL_Warning, __FILE__, __FUNCTION__, __LINE__,
-                 "couldn't open diags log file '%s', " "will not log to this file", diags_logpath);
-  } else {
-    diags->print(NULL, DL_Status, "STATUS", NULL, 0, "opened %s", diags_logpath);
-  }
-
-  init_system_reconfigure_diags();
-}
-

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/707a5e7c/proxy/Initialize.h
----------------------------------------------------------------------
diff --git a/proxy/Initialize.h b/proxy/Initialize.h
deleted file mode 100644
index 556f251..0000000
--- a/proxy/Initialize.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/** @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.
- */
-
-/****************************************************************************
-
-   Initialize.h --
-   Created On      : Mon Feb  8 15:14:57 1999
-
-   Description:
-
-
-
- ****************************************************************************/
-#if !defined (_Initialize_h_)
-#define _Initialize_h_
-
-#define MAX_NUMBER_OF_THREADS  1024
-#define DIAGS_LOG_FILE         "diags.log"
-
-extern Diags *diags;
-extern int fds_limit; // TODO: rename
-extern int system_num_of_net_threads;
-extern int system_syslog_facility;
-
-void init_system_settings(void);
-void init_system_dirs(void);
-void init_system_core_size(void);
-void init_system_syslog_log_configure(void);
-//void init_system_logging();
-void init_system_reconfigure_diags(void);
-void init_system_diags(char *bdt, char *bat);
-void chown_file_to_user(const char *file, const char *user);
-void init_system_adjust_num_of_net_threads(void);
-
-//void initialize_standalone();
-
-#endif