ndt-dev - [ndt-dev] [ndt] r999 committed - Get rid of the count_vars variable that gets passed around
Subject: NDT-DEV email list created
List archive
[ndt-dev] [ndt] r999 committed - Get rid of the count_vars variable that gets passed around
Chronological Thread
- From:
- To:
- Subject: [ndt-dev] [ndt] r999 committed - Get rid of the count_vars variable that gets passed around
- Date: Mon, 10 Mar 2014 13:50:35 +0000
Revision: 999
Author:
Date: Mon Mar 10 13:48:11 2014 UTC
Log: Get rid of the count_vars variable that gets passed around
http://code.google.com/p/ndt/source/detail?r=999
Modified:
/branches/aaron-tcp_stats_cleanup/src/test_c2s_srv.c
/branches/aaron-tcp_stats_cleanup/src/test_s2c_srv.c
/branches/aaron-tcp_stats_cleanup/src/tests_srv.h
/branches/aaron-tcp_stats_cleanup/src/web100-util.c
/branches/aaron-tcp_stats_cleanup/src/web100srv.c
/branches/aaron-tcp_stats_cleanup/src/web100srv.h
=======================================
--- /branches/aaron-tcp_stats_cleanup/src/test_c2s_srv.c Mon Mar 10 13:43:13 2014 UTC
+++ /branches/aaron-tcp_stats_cleanup/src/test_c2s_srv.c Mon Mar 10 13:48:11 2014 UTC
@@ -43,7 +43,6 @@
* @param device string device name inout parameter
* @param options Test Option variables
* @param record_reverse integer indicating whether receiver-side statistics have to be logged
- * @param count_vars count of web100 variables
* @param spds[] [] speed check array
* @param spd_index index used for speed check array
* @param conn_options Connection options
@@ -60,7 +59,7 @@
int test_c2s(int ctlsockfd, tcp_stat_agent* agent, TestOptions* testOptions,
int conn_options, double* c2sspd, int set_buff, int window,
int autotune, char* device, Options* options, int record_reverse,
- int count_vars, char spds[4][256], int* spd_index) {
+ char spds[4][256], int* spd_index) {
tcp_stat_connection conn;
tcp_stat_group* group = NULL;
/* The pipe that will return packet pair results */
@@ -88,9 +87,7 @@
// snap related variables
SnapArgs snapArgs;
snapArgs.snap = NULL;
-#if USE_WEB100
snapArgs.log = NULL;
-#endif
snapArgs.delay = options->snapDelay;
wait_sig = 0;
@@ -378,7 +375,7 @@
// get receiver side Web100 stats and write them to the log file. close
// sockets
if (record_reverse == 1)
- tcp_stat_get_data_recv(recvsfd, agent, conn, count_vars);
+ tcp_stat_get_data_recv(recvsfd, agent, conn);
close(recvsfd);
=======================================
--- /branches/aaron-tcp_stats_cleanup/src/test_s2c_srv.c Mon Mar 10 13:43:13 2014 UTC
+++ /branches/aaron-tcp_stats_cleanup/src/test_s2c_srv.c Mon Mar 10 13:48:11 2014 UTC
@@ -52,7 +52,6 @@
* @param options Test Option variables
* @param spds[][] speed check array
* @param spd_index index used for speed check array
- * @param count_vars count of web100 variables
* @param peaks Cwnd peaks structure pointer
*
* @return 0 - success,
@@ -71,7 +70,7 @@
int test_s2c(int ctlsockfd, tcp_stat_agent* agent, TestOptions* testOptions,
int conn_options, double* s2cspd, int set_buff, int window,
int autotune, char* device, Options* options, char spds[4][256],
- int* spd_index, int count_vars, CwndPeaks* peaks) {
+ int* spd_index, CwndPeaks* peaks) {
#if USE_WEB100
/* experimental code to capture and log multiple copies of the
* web100 variables using the web100_snap() & log() functions.
@@ -578,13 +577,13 @@
#if USE_WEB100
// send web100 data to client
- ret = tcp_stat_get_data(tsnap, xmitsfd, ctlsockfd, agent, count_vars);
+ ret = tcp_stat_get_data(tsnap, xmitsfd, ctlsockfd, agent);
web100_snapshot_free(tsnap);
// send tuning-related web100 data collected to client
- ret = tcp_stat_get_data(rsnap, xmitsfd, ctlsockfd, agent, count_vars);
+ ret = tcp_stat_get_data(rsnap, xmitsfd, ctlsockfd, agent);
web100_snapshot_free(rsnap);
#elif USE_WEB10G
- ret = tcp_stat_get_data(snap, xmitsfd, ctlsockfd, agent, count_vars);
+ ret = tcp_stat_get_data(snap, xmitsfd, ctlsockfd, agent);
estats_val_data_free(&snap);
#endif
=======================================
--- /branches/aaron-tcp_stats_cleanup/src/tests_srv.h Mon Oct 14 13:20:21 2013 UTC
+++ /branches/aaron-tcp_stats_cleanup/src/tests_srv.h Mon Mar 10 13:48:11 2014 UTC
@@ -14,13 +14,13 @@
int test_c2s(int ctlsockfd, tcp_stat_agent* agent, TestOptions* testOptions,
int conn_options, double* c2sspd, int set_buff, int window,
int autotune, char* device, Options* options, int record_reverse,
- int count_vars, char spds[4][256], int* spd_index);
+ char spds[4][256], int* spd_index);
// S2C test
int test_s2c(int ctlsockfd, tcp_stat_agent* agent, TestOptions* testOptions,
int conn_options, double* s2cspd, int set_buff, int window,
int autotune, char* device, Options* options, char spds[4][256],
- int* spd_index, int count_vars, CwndPeaks* peaks);
+ int* spd_index, CwndPeaks* peaks);
// the middlebox test
int test_mid(int ctlsockfd, tcp_stat_agent* agent, TestOptions* testOptions,
=======================================
--- /branches/aaron-tcp_stats_cleanup/src/web100-util.c Mon Mar 10 13:47:36 2014 UTC
+++ /branches/aaron-tcp_stats_cleanup/src/web100-util.c Mon Mar 10 13:48:11 2014 UTC
@@ -133,12 +133,14 @@
trim(line, strlen(line), trimmedline, sizeof(trimmedline));
strlcpy(web_vars[count_vars].name, trimmedline,
sizeof(web_vars[count_vars].name));
+ web_vars[count_vars].defined = 1;
count_vars++;
}
+ web_vars[count_vars].defined = 0;
fclose(fp);
log_println(1, "web100_init() read %d variables from file", count_vars);
- return (count_vars);
+ return count_vars;
#elif USE_WEB10G
return TOTAL_INDEX_MAX;
#endif
@@ -339,11 +341,10 @@
* @param sock integer socket file descriptor
* @param agent pointer to a tcp_stat_agent
* @param cn A tcp_stat_connection
- * @param count_vars integer number of tcp_stat_vars to get value of
*
*/
void tcp_stat_get_data_recv(int sock, tcp_stat_agent* agent,
- tcp_stat_connection cn, int count_vars) {
+ tcp_stat_connection cn) {
#if USE_WEB100
web100_var* var = NULL;
web100_group* group = NULL;
@@ -381,7 +382,7 @@
#if USE_WEB100
int ok = 1;
- for (i = 0; i < count_vars; i++) {
+ for (i = 0; web_vars[i].defined; i++) {
if ((web100_agent_find_var_and_group(agent, web_vars[i].name, &group,
&var)) != WEB100_ERR_SUCCESS) {
log_println(1, "Variable %d (%s) not found in KIS", i,
@@ -509,11 +510,10 @@
* @param snap pointer to a tcp_stat_snapshot taken earlier
* @param ctlsock integer socket file descriptor indicating data recipient
* @param agent pointer to a tcp_stat_agent
- * @param count_vars integer number of tcp_stat_variables to get value of
*
*/
int tcp_stat_get_data(tcp_stat_snap* snap, int testsock, int ctlsock,
- tcp_stat_agent* agent, int count_vars) {
+ tcp_stat_agent* agent) {
char line[256];
#if USE_WEB100
int i;
@@ -524,7 +524,7 @@
assert(snap);
assert(agent);
- for (i = 0; i < count_vars; i++) {
+ for (i = 0; web_vars[i].defined; i++) {
if ((web100_agent_find_var_and_group(agent, web_vars[i].name, &group,
&var)) != WEB100_ERR_SUCCESS) {
log_println(9, "Variable %d (%s) not found in KIS: ", i,
@@ -802,7 +802,7 @@
* @param tcp_vars to local copies of tcp_stat variables
* @return integer 0
*/
-int tcp_stat_logvars(struct tcp_vars* vars, int count_vars) {
+int tcp_stat_logvars(struct tcp_vars* vars) {
#if USE_WEB100
int a, b;
for (a = 0; a < sizeof(struct tcp_vars) / sizeof(tcp_stat_var); ++a) {
@@ -810,7 +810,7 @@
if (web100_name == NULL)
continue;
- for (b = 0; b < count_vars; b++) {
+ for (b = 0; web_vars[b].defined; b++) {
if (strcmp(web_vars[b].name, web100_name) == 0) {
tcp_stat_var* var = &((tcp_stat_var *)vars)[a];
*var = atoi(web_vars[b].value);
@@ -818,7 +818,7 @@
break;
}
}
- if (b == count_vars) {
+ if (web_vars[b].defined == 0) {
log_println(1, "WARNING: Failed to find Web100 var %s", web100_name);
}
}
=======================================
--- /branches/aaron-tcp_stats_cleanup/src/web100srv.c Mon Mar 10 13:43:13 2014 UTC
+++ /branches/aaron-tcp_stats_cleanup/src/web100srv.c Mon Mar 10 13:48:11 2014 UTC
@@ -100,7 +100,6 @@
// list of global variables used throughout this program.
static int window = 64000; // TCP buffer size
-static int count_vars = 0;
static int dumptrace = 0;
static int usesyslog = 0;
static int multiple = 0;
@@ -535,7 +534,7 @@
case SIGHUP:
/* Initialize Web100 structures */
- count_vars = tcp_stats_init(VarFileName);
+ tcp_stats_init(VarFileName);
/* The administrator view automatically generates a usage page for the
* NDT server. This page is then accessable to the general public.
@@ -1018,7 +1017,7 @@
log_println(6, "Starting c2s throughput test");
if ((ret = test_c2s(ctlsockfd, agent, &*testopt, conn_options, &c2sspd,
set_buff, window, autotune, device, &options,
- record_reverse, count_vars, spds, &spd_index)) != 0) {
+ record_reverse, spds, &spd_index)) != 0) {
if (ret < 0)
log_println(6, "C2S test failed with rc=%d", ret);
log_println(0, "C2S throughput test FAILED!, rc=%d", ret);
@@ -1030,7 +1029,7 @@
log_println(6, "Starting s2c throughput test");
if ((ret = test_s2c(ctlsockfd, agent, &*testopt, conn_options, &s2cspd,
set_buff, window, autotune, device, &options, spds,
- &spd_index, count_vars, &peaks)) != 0) {
+ &spd_index, &peaks)) != 0) {
if (ret < 0)
log_println(6, "S2C test failed with rc=%d", ret);
log_println(0, "S2C throughput test FAILED!, rc=%d", ret);
@@ -1065,7 +1064,7 @@
// ...other variables
memset(&vars, 0xFF, sizeof(vars));
- tcp_stat_logvars(&vars, count_vars);
+ tcp_stat_logvars(&vars);
// end getting web100 variable values
/* if (rc == 0) { */
@@ -1832,8 +1831,7 @@
log_println(1, "server ready on port %s (family %d)", port, meta.family);
// Initialize tcp_stat structures
- count_vars = tcp_stats_init(VarFileName);
- if (count_vars == -1) {
+ if (tcp_stats_init(VarFileName) == 0) {
log_println(0, "No Web100 variables file found, terminating program");
exit(-5);
}
=======================================
--- /branches/aaron-tcp_stats_cleanup/src/web100srv.h Mon Mar 10 13:47:12 2014 UTC
+++ /branches/aaron-tcp_stats_cleanup/src/web100srv.h Mon Mar 10 13:48:11 2014 UTC
@@ -171,6 +171,7 @@
};
struct web100_variables {
+ int defined;
char name[256]; // key
char value[256]; // value
} web_vars[WEB100_VARS];
@@ -331,13 +332,13 @@
void tcp_stat_middlebox(int sock, tcp_stat_agent* agent, tcp_stat_connection cn,
char *results, size_t results_strlen);
void tcp_stat_get_data_recv(int sock, tcp_stat_agent* agent,
- tcp_stat_connection cn, int count_vars);
+ tcp_stat_connection cn);
int tcp_stat_get_data(tcp_stat_snap* snap, int testsock, int ctlsock,
- tcp_stat_agent* agent, int count_vars);
+ tcp_stat_agent* agent);
int CwndDecrease(char* logname,
u_int32_t *dec_cnt, u_int32_t *same_cnt, u_int32_t *inc_cnt);
-int tcp_stat_logvars(struct tcp_vars* vars, int count_vars);
+int tcp_stat_logvars(struct tcp_vars* vars);
int KillHung(void);
void writeMeta(int compress, int cputime, int snaplog, int tcpdump);
- [ndt-dev] [ndt] r999 committed - Get rid of the count_vars variable that gets passed around, ndt, 03/10/2014
Archive powered by MHonArc 2.6.16.