~ubuntu-branches/ubuntu/wily/trafficserver/wily

« back to all changes in this revision

Viewing changes to proxy/Main.cc

  • Committer: Package Import Robot
  • Author(s): Adam Conrad
  • Date: 2013-04-29 11:47:57 UTC
  • mfrom: (5.2.1 sid)
  • Revision ID: package-import@ubuntu.com-20130429114757-bbeb5eacidfuj2qg
Tags: 3.2.4-1ubuntu1
* Merge from Debian unstable.  Remaining changes:
  - Revert FreeBSD strerror_r() fixes that give errors with glibc 2.16.
* Drop markos's ARM barrier definition patch, now integrated upstream.
* Brute-force upstream's suboptimal C/C++ with: -Wno-unused-result
  -Wno-sizeof-pointer-memaccess -Wno-unused-local-typedefs flags.

Show diffs side-by-side

added added

removed removed

Lines of Context:
117
117
 
118
118
#define DEFAULT_REMOTE_MANAGEMENT_FLAG    0
119
119
 
120
 
int version_flag = DEFAULT_VERSION_FLAG;
121
 
int stack_trace_flag = DEFAULT_STACK_TRACE_FLAG;
122
 
 
123
 
int number_of_processors = ink_number_of_processors();
124
 
int num_of_net_threads = DEFAULT_NUMBER_OF_THREADS;
 
120
static void * mgmt_restart_shutdown_callback(void *, char *, int data_len);
 
121
static bool xmlBandwidthSchemaRead(XMLNode * node);
 
122
 
 
123
static int version_flag = DEFAULT_VERSION_FLAG;
 
124
 
 
125
static int const number_of_processors = ink_number_of_processors();
 
126
static int num_of_net_threads = DEFAULT_NUMBER_OF_THREADS;
125
127
extern int num_of_cluster_threads;
126
 
int num_of_udp_threads = DEFAULT_NUMBER_OF_UDP_THREADS;
127
 
int num_accept_threads  = DEFAULT_NUM_ACCEPT_THREADS;
128
 
int num_task_threads = DEFAULT_NUM_TASK_THREADS;
129
 
int run_test_hook = 0;
130
 
char http_accept_port_descriptor[TS_ARG_MAX + 1];
131
 
#define TS_ARG_MAX_STR_FMT "S" TS_ARG_MAX_STR
 
128
static int num_of_udp_threads = DEFAULT_NUMBER_OF_UDP_THREADS;
 
129
static int num_accept_threads  = DEFAULT_NUM_ACCEPT_THREADS;
 
130
static int num_task_threads = DEFAULT_NUM_TASK_THREADS;
 
131
static int run_test_hook = 0;
 
132
static char * http_accept_port_descriptor;
132
133
int http_accept_file_descriptor = NO_FD;
133
 
int ssl_accept_file_descriptor = NO_FD;
134
 
char core_file[255] = "";
135
 
bool enable_core_file_p = false; // Enable core file dump?
 
134
static char core_file[255] = "";
 
135
static bool enable_core_file_p = false; // Enable core file dump?
136
136
int command_flag = DEFAULT_COMMAND_FLAG;
137
137
#if TS_HAS_TESTS
138
 
char regression_test[1024] = "";
 
138
static char regression_test[1024] = "";
139
139
#endif
140
140
int auto_clear_hostdb_flag = 0;
141
141
int lock_process = DEFAULT_LOCK_PROCESS;
146
146
 
147
147
//         = DEFAULT_CLUSTER_PORT_NUMBER;
148
148
char proxy_name[MAXDNAME + 1] = "unknown";
149
 
char command_string[512] = "";
 
149
static char command_string[512] = "";
150
150
int remote_management_flag = DEFAULT_REMOTE_MANAGEMENT_FLAG;
151
151
 
152
152
char management_directory[PATH_NAME_MAX+1];      // Layout->sysconfdir
155
155
char system_config_directory[PATH_NAME_MAX + 1]; // Layout->sysconfdir
156
156
char system_log_dir[PATH_NAME_MAX + 1];          // Layout->logdir
157
157
 
158
 
int logging_port_override = 0;
159
 
char logging_server_override[256] = " do not override";
160
 
char error_tags[1024] = "";
161
 
char action_tags[1024] = "";
162
 
int show_statistics = 0;
163
 
int history_info_enabled = 1;
 
158
static char error_tags[1024] = "";
 
159
static char action_tags[1024] = "";
 
160
static int show_statistics = 0;
 
161
static int history_info_enabled = 1;
164
162
//inkcoreapi Diags *diags = NULL;
165
 
inkcoreapi DiagsConfig *diagsConfig = NULL;
 
163
static inkcoreapi DiagsConfig *diagsConfig = NULL;
166
164
HttpBodyFactory *body_factory = NULL;
167
 
int diags_init = 0;             // used by process manager
 
165
static int diags_init = 0;             // used by process manager
168
166
 
169
 
char vingid_flag[255] = "";
 
167
static char vingid_flag[255] = "";
170
168
 
171
169
static int accept_mss = 0;
172
170
static int cmd_line_dprintf_level = 0;  // default debug output level fro ink_dprintf function
176
174
#if TS_HAS_TESTS
177
175
extern int run_TestHook();
178
176
#endif
179
 
void deinitSubAgent();
180
177
 
181
 
Version version = {
 
178
const Version version = {
182
179
  {CACHE_DB_MAJOR_VERSION, CACHE_DB_MINOR_VERSION},     // cacheDB
183
180
  {CACHE_DIR_MAJOR_VERSION, CACHE_DIR_MINOR_VERSION},   // cacheDir
184
181
  {CLUSTER_MAJOR_VERSION, CLUSTER_MINOR_VERSION},       // current clustering
185
182
  {MIN_CLUSTER_MAJOR_VERSION, MIN_CLUSTER_MINOR_VERSION},       // min clustering
186
183
};
187
184
 
188
 
ArgumentDescription argument_descriptions[] = {
 
185
static const ArgumentDescription argument_descriptions[] = {
189
186
  {"lock_memory", 'l', "Lock process in memory (must be root)",
190
187
   "I", &lock_process, "PROXY_LOCK_PROCESS", NULL},
191
188
  {"net_threads", 'n', "Number of Net Threads", "I", &num_of_net_threads,
198
195
   "PROXY_ACCEPT_THREAD", NULL},
199
196
  {"accept_till_done", 'b', "Accept Till Done", "T", &accept_till_done,
200
197
   "PROXY_ACCEPT_TILL_DONE", NULL},
201
 
  {"httpport", 'p', "Port descriptor for HTTP Accept", TS_ARG_MAX_STR_FMT,
202
 
   http_accept_port_descriptor, "PROXY_HTTP_ACCEPT_PORT", NULL},
 
198
  {"httpport", 'p', "Port descriptor for HTTP Accept", "S*",
 
199
   &http_accept_port_descriptor, "PROXY_HTTP_ACCEPT_PORT", NULL},
203
200
  {"cluster_port", 'P', "Cluster Port Number", "I", &cluster_port_number,
204
201
   "PROXY_CLUSTER_PORT", NULL},
205
202
  {"dprintf_level", 'o', "Debug output level", "I", &cmd_line_dprintf_level,
262
259
   NULL, NULL},
263
260
  {"help", 'h', "HELP!", NULL, NULL, NULL, usage},
264
261
};
265
 
int n_argument_descriptions = SIZE(argument_descriptions);
 
262
static const unsigned n_argument_descriptions = SIZE(argument_descriptions);
266
263
 
267
264
//
268
265
// Initialize operating system related information/services
677
674
 
678
675
static int cmd_help(char *cmd);
679
676
 
680
 
static struct CMD
 
677
static const struct CMD
681
678
{
682
679
  const char *n;                      // name
683
680
  const char *d;                      // description (part of a line)
736
733
      "EXAMPLES: help help\n"
737
734
      "          help commit\n" "\n" "Provide a short description of a command (like this).\n", cmd_help},};
738
735
 
739
 
#define N_CMDS ((int)(sizeof(commands)/sizeof(commands[0])))
740
 
 
741
736
static int
742
737
cmd_index(char *p)
743
738
{
744
739
  p += strspn(p, " \t");
745
 
  for (int c = 0; c < N_CMDS; c++) {
 
740
  for (unsigned c = 0; c < SIZE(commands); c++) {
746
741
    const char *l = commands[c].n;
747
742
    while (l) {
748
743
      const char *s = strchr(l, '/');
760
755
static int
761
756
cmd_help(char *cmd)
762
757
{
763
 
  int i;
764
 
 
765
758
  (void) cmd;
766
759
  printf("HELP\n\n");
767
760
  cmd = skip(cmd, true);
768
761
  if (!cmd) {
769
 
    for (i = 0; i < N_CMDS; i++) {
 
762
    for (unsigned i = 0; i < SIZE(commands); i++) {
770
763
      printf("%15s  %s\n", commands[i].n, commands[i].d);
771
764
    }
772
765
  } else {
 
766
    int i;
773
767
    if ((i = cmd_index(cmd)) < 0) {
774
768
      printf("\nno help found for: %s\n", cmd);
775
769
      return CMD_FAILED;
1220
1214
}
1221
1215
 
1222
1216
 
1223
 
int
 
1217
static int
1224
1218
getNumSSLThreads(void)
1225
1219
{
1226
1220
  int num_of_ssl_threads = 0;
1300
1294
 * Change the uid and gid to what is in the passwd entry for supplied user name.
1301
1295
 * @param user User name in the passwd file to change the uid and gid to.
1302
1296
 */
1303
 
void
 
1297
static void
1304
1298
change_uid_gid(const char *user)
1305
1299
{
1306
1300
  struct passwd pwbuf;
1560
1554
 
1561
1555
  {
1562
1556
    XMLDom schema;
1563
 
    bool xmlBandwidthSchemaRead(XMLNode * node);
1564
1557
    //char *configPath = TS_ConfigReadString("proxy.config.config_dir");
1565
1558
    char *filename = TS_ConfigReadString("proxy.config.bandwidth_mgmt.filename");
1566
1559
    char bwFilename[PATH_NAME_MAX];
1798
1791
    ///////////////////////////////////////////
1799
1792
    updateManager.start();
1800
1793
 
1801
 
    void *mgmt_restart_shutdown_callback(void *, char *, int data_len);
1802
 
 
1803
1794
    pmgmt->registerMgmtCallback(MGMT_EVENT_SHUTDOWN, mgmt_restart_shutdown_callback, NULL);
1804
1795
    pmgmt->registerMgmtCallback(MGMT_EVENT_RESTART, mgmt_restart_shutdown_callback, NULL);
1805
1796
 
1832
1823
}
1833
1824
 
1834
1825
 
1835
 
bool
 
1826
static bool
1836
1827
xmlBandwidthSchemaRead(XMLNode * node)
1837
1828
{
1838
1829
  XMLNode *child, *c2;
1919
1910
}
1920
1911
#endif
1921
1912
 
1922
 
void *
 
1913
static void *
1923
1914
mgmt_restart_shutdown_callback(void *, char *, int data_len)
1924
1915
{
1925
1916
  NOWARN_UNUSED(data_len);