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

« back to all changes in this revision

Viewing changes to mgmt/LocalManager.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:
999
999
    RecSetRecordInt("proxy.node.restarts.proxy.start_time", proxy_started_at);
1000
1000
    RecSetRecordInt("proxy.node.restarts.proxy.restart_count", proxy_launch_count);
1001
1001
  } else {
1002
 
    int res, i = 0, n;
1003
 
    char real_proxy_options[TS_ARG_MAX], *options[32], *last, *tok;
 
1002
    int res, i = 0;
 
1003
    char *options[32], *last, *tok;
1004
1004
    bool open_ports_p = false;
1005
1005
 
1006
 
    snprintf(real_proxy_options, sizeof(real_proxy_options), "%s", proxy_options);
1007
 
    n = strlen(real_proxy_options);
 
1006
    Vec<char> real_proxy_options;
 
1007
 
 
1008
    real_proxy_options.append(proxy_options, strlen(proxy_options));
1008
1009
 
1009
1010
    // Check if we need to pass down port/fd information to
1010
1011
    // traffic_server by seeing if there are any open ports.
1011
 
    for ( int i = 0, limit = m_proxy_ports.length()
1012
 
            ; !open_ports_p && i < limit
1013
 
            ; ++i
1014
 
    )
1015
 
      if (ts::NO_FD != m_proxy_ports[i].m_fd) open_ports_p = true;
 
1012
    for ( int i = 0, limit = m_proxy_ports.length() ; !open_ports_p && i < limit ; ++i) {
 
1013
      if (ts::NO_FD != m_proxy_ports[i].m_fd) {
 
1014
        open_ports_p = true;
 
1015
      }
 
1016
    }
1016
1017
 
1017
1018
    if (open_ports_p) {
 
1019
      char portbuf[128];
1018
1020
      bool need_comma_p = false;
1019
 
      snprintf(&real_proxy_options[n], sizeof(real_proxy_options) - n, " --httpport ");
1020
 
      n = strlen(real_proxy_options);
 
1021
      real_proxy_options.append(" --httpport ", strlen(" --httpport "));
1021
1022
      for ( int i = 0, limit = m_proxy_ports.length() ; i < limit ; ++i ) {
1022
1023
        HttpProxyPort& p = m_proxy_ports[i];
1023
1024
        if (ts::NO_FD != p.m_fd) {
1024
 
          if (need_comma_p) real_proxy_options[n++] = ',';
 
1025
          if (need_comma_p) {
 
1026
            real_proxy_options.append(',');
 
1027
          }
1025
1028
          need_comma_p = true;
1026
 
          p.print(real_proxy_options+n, sizeof(real_proxy_options)-n);
1027
 
          n = strlen(real_proxy_options);
 
1029
          p.print(portbuf, sizeof(portbuf));
 
1030
          real_proxy_options.append((const char *)portbuf, strlen(portbuf));
1028
1031
        }
1029
1032
      }
1030
1033
    }
1031
1034
 
 
1035
    // NUL-terminate for the benefit of strtok and printf.
 
1036
    real_proxy_options.append('\0');
 
1037
 
1032
1038
    Debug("lm", "[LocalManager::startProxy] Launching %s with options '%s'\n",
1033
 
          absolute_proxy_binary, real_proxy_options);
 
1039
          absolute_proxy_binary, &real_proxy_options[0]);
1034
1040
 
1035
1041
    ink_zero(options);
1036
1042
    options[0] = absolute_proxy_binary;
1037
1043
    i = 1;
1038
 
    tok = ink_strtok_r(real_proxy_options, " ", &last);
 
1044
    tok = ink_strtok_r(&real_proxy_options[0], " ", &last);
1039
1045
    options[i++] = tok;
1040
1046
    while (i < 32 && (tok = ink_strtok_r(NULL, " ", &last))) {
1041
1047
      Debug("lm", "opt %d = '%s'\n", i, tok);