99
#define DEFAULT_NUMBER_OF_THREADS ink_number_of_processors()
100
#define DEFAULT_NUMBER_OF_UDP_THREADS 1
101
#define DEFAULT_NUMBER_OF_SSL_THREADS 0
102
#define DEFAULT_NUM_ACCEPT_THREADS 0
103
#define DEFAULT_NUM_TASK_THREADS 0
104
100
#define DEFAULT_HTTP_ACCEPT_PORT_NUMBER 0
105
101
#define DEFAULT_COMMAND_FLAG 0
106
102
#define DEFAULT_LOCK_PROCESS 0
118
114
#define DEFAULT_REMOTE_MANAGEMENT_FLAG 0
120
116
static void * mgmt_restart_shutdown_callback(void *, char *, int data_len);
121
static bool xmlBandwidthSchemaRead(XMLNode * node);
123
118
static int version_flag = DEFAULT_VERSION_FLAG;
125
120
static int const number_of_processors = ink_number_of_processors();
126
static int num_of_net_threads = DEFAULT_NUMBER_OF_THREADS;
121
static int num_of_net_threads = number_of_processors;
122
static int num_of_udp_threads = 0;
123
static int num_accept_threads = 0;
124
static int num_task_threads = 0;
127
126
extern int num_of_cluster_threads;
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;
132
129
static int run_test_hook = 0;
405
402
ink_strlcpy(management_directory, Layout::get()->sysconfdir, sizeof(management_directory));
406
403
if (access(management_directory, R_OK) == -1) {
407
404
fprintf(stderr,"unable to access() management path '%s': %d, %s\n", management_directory, errno, strerror(errno));
408
fprintf(stderr,"please set management path via command line '-d <managment directory>'\n");
405
fprintf(stderr,"please set management path via command line '-d <management directory>'\n");
1520
1518
TS_ReadConfigInteger(history_info_enabled, "proxy.config.history_info_enabled");
1521
1519
TS_ReadConfigInteger(res_track_memory, "proxy.config.res_track_memory");
1525
//char *configPath = TS_ConfigReadString("proxy.config.config_dir");
1526
char *filename = TS_ConfigReadString("proxy.config.bandwidth_mgmt.filename");
1527
char bwFilename[PATH_NAME_MAX];
1529
snprintf(bwFilename, sizeof(bwFilename), "%s/%s", system_config_directory, filename);
1532
Debug("bw-mgmt", "Looking to read: %s for bw-mgmt", bwFilename);
1533
schema.LoadFile(bwFilename);
1534
xmlBandwidthSchemaRead(&schema);
1538
1521
init_http_header();
1540
1523
// Sanity checks
1541
// if (!lock_process) check_for_root_uid();
1542
1524
check_fd_limit();
1544
1525
command_flag = command_flag || *command_string;
1546
1527
// Set up store
1790
xmlBandwidthSchemaRead(XMLNode * node)
1792
XMLNode *child, *c2;
1797
// file doesn't exist
1798
if (node->getNodeName() == NULL) {
1799
// alloc 1-elt array to store stuff for best-effort traffic
1800
G_inkPipeInfo.perPipeInfo = NEW(new InkSinglePipeInfo[1]);
1801
G_inkPipeInfo.perPipeInfo[0].wt = 1.0;
1802
G_inkPipeInfo.numPipes = 0;
1803
G_inkPipeInfo.interfaceMbps = 0.0;
1807
if (strcmp(node->getNodeName(), "interface") != 0) {
1808
Debug("bw-mgmt", "Root node should be an interface tag!\n");
1811
// First entry G_inkPipeInfo.perPipeInfo[0] is the one for "best-effort" traffic.
1812
G_inkPipeInfo.perPipeInfo = NEW(new InkSinglePipeInfo[node->getChildCount() + 1]);
1813
G_inkPipeInfo.perPipeInfo[0].wt = 1.0;
1814
G_inkPipeInfo.numPipes = 0;
1815
G_inkPipeInfo.reliabilityMbps = 1.0;
1816
G_inkPipeInfo.interfaceMbps = 30.0;
1817
for (i = 0; i < node->getChildCount(); i++) {
1818
if ((child = node->getChildNode(i))) {
1819
if (strcmp(child->getNodeName(), "pipe") == 0) {
1820
G_inkPipeInfo.numPipes++;
1821
for (k = 0; k < child->getChildCount(); k++) {
1822
c2 = child->getChildNode(k);
1823
for (int l = 0; l < c2->m_nACount; l++) {
1824
if (strcmp(c2->m_pAList[l].pAName, "weight") == 0) {
1825
G_inkPipeInfo.perPipeInfo[G_inkPipeInfo.numPipes].wt = atof(c2->m_pAList[l].pAValue);
1826
G_inkPipeInfo.perPipeInfo[0].wt -= G_inkPipeInfo.perPipeInfo[G_inkPipeInfo.numPipes].wt;
1827
} else if (strcmp(c2->m_pAList[l].pAName, "dest_ip") == 0) {
1828
p = (unsigned char *) &(G_inkPipeInfo.perPipeInfo[G_inkPipeInfo.numPipes].destIP);
1829
ip = c2->m_pAList[l].pAValue;
1830
for (j = 0; j < 4; j++) {
1832
while (ip && *ip && (*ip != '.'))
1839
} else if (strcmp(child->getNodeName(), "bandwidth") == 0) {
1840
for (j = 0; j < child->m_nACount; j++) {
1841
if (strcmp(child->m_pAList[j].pAName, "limit_mbps") == 0) {
1842
G_inkPipeInfo.interfaceMbps = atof(child->m_pAList[j].pAValue);
1843
} else if (strcmp(child->m_pAList[j].pAName, "reliability_mbps") == 0) {
1844
G_inkPipeInfo.reliabilityMbps = atof(child->m_pAList[j].pAValue);
1850
Debug("bw-mgmt", "Read in: limit_mbps = %lf\n", G_inkPipeInfo.interfaceMbps);
1851
for (i = 0; i < G_inkPipeInfo.numPipes + 1; i++) {
1852
G_inkPipeInfo.perPipeInfo[i].bwLimit =
1853
(int64_t) (G_inkPipeInfo.perPipeInfo[i].wt * G_inkPipeInfo.interfaceMbps * 1024.0 * 1024.0);
1854
p = (unsigned char *) &(G_inkPipeInfo.perPipeInfo[i].destIP);
1855
Debug("bw-mgmt", "Pipe [%d]: wt = %lf, dest ip = %d.%d.%d.%d\n",
1856
i, G_inkPipeInfo.perPipeInfo[i].wt, p[0], p[1], p[2], p[3]);
1862
1773
#if TS_HAS_TESTS
1863
1774
//////////////////////////////
1864
1775
// Unit Regresion Test Hook //