[netperf-dev] netperf4 commit notice r3 - in trunk: . src
raj at netperf.org
raj at netperf.org
Mon Oct 24 17:16:00 PDT 2005
Author: raj
Date: 2005-10-24 17:15:58 -0700 (Mon, 24 Oct 2005)
New Revision: 3
Added:
trunk/README.linux
Modified:
trunk/src/netlib.c
trunk/src/netperf.c
trunk/src/netperf.h
trunk/src/nettest_bsd.c
Log:
Additional changes from Stephen Burger. May not be complete. Added a
README.linux file with instructions on how to get the posix_rwlock_t
defined.
Added: trunk/README.linux
===================================================================
--- trunk/README.linux 2005-10-20 00:10:11 UTC (rev 2)
+++ trunk/README.linux 2005-10-25 00:15:58 UTC (rev 3)
@@ -0,0 +1,9 @@
+Until I can find a way to get the configure script ot add it
+automagically, you need to define something along the lines of
+_GNU_SOURCE in CPPFLAGS when doing the configure:
+
+CPPFLAGS="-D_GNU_SOURCE" ./configure
+
+Otherwise, the ever-so-helpful Linux (debian at least) build
+environment will not find things like the posix_rwlock_t that are
+seemingly so easily found on other platforms (eg HP-UX).
Modified: trunk/src/netlib.c
===================================================================
--- trunk/src/netlib.c 2005-10-20 00:10:11 UTC (rev 2)
+++ trunk/src/netlib.c 2005-10-25 00:15:58 UTC (rev 3)
@@ -1088,13 +1088,14 @@
being asked for a massive message size, but for now, we will
simply check the return value on the malloc() call :) raj
2003-03-06 */
- if ((message_base = malloc(bytes_left)) == NULL) {
+ if ((message_base = malloc(bytes_left+1)) == NULL) {
fprintf(where,
"recv_control_messsage: unable to allocate %u bytes for inbound message\n",
bytes_left);
fflush(where);
return(NPE_MALLOC_FAILED1);
}
+ memset(message_base,'\0',bytes_left+1); /* cover fprintf problem */
read_ptr = message_base;
Modified: trunk/src/netperf.c
===================================================================
--- trunk/src/netperf.c 2005-10-20 00:10:11 UTC (rev 2)
+++ trunk/src/netperf.c 2005-10-25 00:15:58 UTC (rev 3)
@@ -603,21 +603,30 @@
new_server->id = netserverid;
if (add_server_to_hash(new_server) == NPE_SUCCESS) {
new_server->node = this_netserver;
- rc = instantiate_tests(this_netserver, new_server);
+ rc = pthread_rwlock_init(&new_server->rwlock, NULL);
+ if (rc) {
+ fprintf(where, "instaniate_netservers: ");
+ fprintf(where, "pthread_rwlock_init error %d\n", rc);
+ fflush(where);
+ rc == NPE_PTHREAD_RWLOCK_INIT_FAILED;
+ }
+ if (rc == NPE_SUCCESS) {
+ rc = instantiate_tests(this_netserver, new_server);
+ }
if (rc == NPE_SUCCESS) { /* instantiate_tests was successful */
- new_server->sock = connect_netserver(config_doc,
- this_netserver,
- new_server);
- if (new_server->sock == -1) {
- /* connect netserver unhappy */
- fprintf(where,"connect_netserver: Failed\n");
- fflush(where);
- new_server->state = NSRV_PREINIT;
- new_server->state_req = NSRV_PREINIT;
- rc = NPE_CONNECT_FAILED;
- }
- new_server->state = NSRV_CONNECTED;
- new_server->state_req = NSRV_CONNECTED;
+ new_server->sock = connect_netserver(config_doc,
+ this_netserver,
+ new_server);
+ if (new_server->sock == -1) {
+ /* connect netserver unhappy */
+ fprintf(where,"connect_netserver: Failed\n");
+ fflush(where);
+ new_server->state = NSRV_PREINIT;
+ new_server->state_req = NSRV_PREINIT;
+ rc = NPE_CONNECT_FAILED;
+ }
+ new_server->state = NSRV_CONNECTED;
+ new_server->state_req = NSRV_CONNECTED;
rc = send_version_message(new_server, my_nid);
if (rc == NPE_SUCCESS) {
new_server->state = NSRV_VERS;
@@ -650,25 +659,25 @@
struct pollfd fds;
xmlDocPtr message;
- pthread_mutex_lock(server->lock);
if (debug) {
fprintf(where,"entering wait_for_version_response\n");
fflush(where);
}
+ pthread_mutex_lock(server->lock);
while (server->state == NSRV_VERS) {
fds.fd = server->sock;
fds.events = POLLIN;
fds.revents = 0;
pthread_mutex_unlock(server->lock);
if (poll(&fds,1,5000) > 0) {
- pthread_mutex_lock(server->lock);
if (debug) {
fprintf(where,"wait_for_version_response ");
fprintf(where,"calling recv_control_messaage\n");
fflush(where);
}
+ pthread_rwlock_rdlock(&server->rwlock);
rc = recv_control_message(server->sock, &message);
- pthread_mutex_unlock(server->lock);
+ pthread_rwlock_unlock(&server->rwlock);
if (rc > 0) {
if (debug) {
fprintf(where,"wait_for_version_response ");
@@ -685,6 +694,7 @@
} else {
server->err_rc = rc;
}
+ pthread_mutex_unlock(server->lock);
}
} else {
if (debug) {
@@ -707,11 +717,11 @@
if (rc != NPE_SUCCESS) {
report_server_error(server);
}
+ pthread_mutex_unlock(server->lock);
if (debug) {
fprintf(where,"exiting wait_for_version_response\n");
fflush(where);
}
- pthread_mutex_unlock(server->lock);
return rc;
}
@@ -721,13 +731,19 @@
static int
resolve_dependency(xmlChar *id, xmlNodePtr *data)
{
- int rc = NPE_DEPENDENCY_NOT_PRESENT;
- int hash_value;
- test_t *test;
- test_hash_t *h;
+ int rc = NPE_DEPENDENCY_NOT_PRESENT;
+ int hash_value;
+ test_t *test;
+ test_hash_t *h;
+ struct timespec delta_time;
+ struct timespec abstime;
+ delta_time.tv_sec = 1;
+ delta_time.tv_nsec = 0;
+
*data = NULL;
+
/* find the dependency in the hash list */
hash_value = TEST_HASH_VALUE(id);
h = &(test_hash[hash_value]);
@@ -736,6 +752,7 @@
while (test != NULL) {
if (!xmlStrcmp(test->id,id)) {
+#ifdef OFF
/* found the test we depend on check its state */
if (test->state_req == TEST_PREINIT) {
/* test is not yet initialized initialize it */
@@ -753,16 +770,20 @@
break;
}
} /* end of test initilization */
-
+#endif
/* wait for test to initialize */
while (test->state == TEST_PREINIT) {
+ pthread_mutex_unlock(&h->hash_lock);
if (debug) {
fprintf(where,
- "resolve_dependency: waiting on thread %d\n",
+ "resolve_dependency: waiting on test %s thread %d\n",
+ (char *)id,
test->tid);
fflush(where);
}
- rc = pthread_cond_wait(&h->condition, &h->hash_lock);
+ pthread_mutex_lock(&h->hash_lock);
+ get_expiration_time(&delta_time,&abstime);
+ rc = pthread_cond_timedwait(&h->condition, &h->hash_lock, & abstime);
if (debug) {
fprintf(where,
"resolve_dependency: pthread_cond_wait exited %d\n",rc);
@@ -774,11 +795,14 @@
if (test->state != TEST_ERROR) {
if (test->dependent_data != NULL) {
*data = test->dependent_data;
+ pthread_mutex_unlock(&h->hash_lock);
rc = NPE_SUCCESS;
if (debug) {
- fprintf(where,"resolve_dependency: successful\n");
+ fprintf(where,"resolve_dependency: successful for %s\n",
+ (char *)id);
fflush(where);
}
+ pthread_mutex_lock(&h->hash_lock);
} else {
rc = NPE_DEPENDENCY_NOT_PRESENT;
}
@@ -843,12 +867,12 @@
}
}
/* is the lock around the send required? */
- pthread_mutex_lock(server->lock);
+ pthread_rwlock_wrlock(&server->rwlock);
rc = send_control_message(server->sock,
msg,
server->id,
my_nid);
- pthread_mutex_unlock(server->lock);
+ pthread_rwlock_unlock(&server->rwlock);
} else {
rc = NPE_INIT_TEST_XMLCOPYNODE_FAILED;
}
@@ -900,8 +924,10 @@
test->err_fn = "initialize_tests";
};
}
- /* restart the chain just incase an entry was inserted or deleted */
- test = h->test;
+ /* should we restart the chain just incase an entry was inserted
+ or deleted? no for now sgb 2005-10-25 */
+ /* test = h->test; */
+ test = test->next;
} else {
/* test initialization has already been requested try next test */
test = test->next;
@@ -936,9 +962,9 @@
fds.revents = 0;
pthread_mutex_unlock(server->lock);
if (poll(&fds,1,5000) > 0) {
- pthread_mutex_lock(server->lock);
+ pthread_rwlock_rdlock(&server->rwlock);
rc = recv_control_message(server->sock, &message);
- pthread_mutex_unlock(server->lock);
+ pthread_rwlock_unlock(&server->rwlock);
if (rc > 0) {
rc = process_message(server, message);
} else {
@@ -992,12 +1018,12 @@
while (server != NULL) {
if (server->state_req == NSRV_INIT) {
/* netserver worker thread needs to be started */
+ pthread_mutex_unlock(&h->hash_lock);
if (debug) {
fprintf(where,"launching thread for netserver %s\n",server->id);
fflush(where);
}
/* netserver worker thread is not yet initialized start it */
- pthread_mutex_unlock(&h->hash_lock);
rc = launch_thread(&server->tid, netperf_worker, server);
if (debug) {
fprintf(where,"launched thread %d for netserver %s\n",
@@ -1025,13 +1051,18 @@
static int
wait_for_tests_to_initialize()
{
- int rc = NPE_SUCCESS;
- int prc;
- int i;
- server_t *server;
- test_t *test;
- test_hash_t *h;
+ int rc = NPE_SUCCESS;
+ int prc;
+ int i;
+ server_t *server;
+ test_t *test;
+ test_hash_t *h;
+ struct timespec delta_time;
+ struct timespec abstime;
+ delta_time.tv_sec = 1;
+ delta_time.tv_nsec = 0;
+
if (debug) {
fprintf(where,"entering wait_for_tests_to_initialize\n");
fflush(where);
@@ -1046,9 +1077,9 @@
rc = NPE_TEST_FOUND_IN_ERROR_STATE;
break;
}
- sleep(1);
/* test is not yet initialized wait for it */
- prc = pthread_cond_wait(&h->condition, &h->hash_lock);
+ get_expiration_time(&delta_time,&abstime);
+ prc = pthread_cond_timedwait(&h->condition, &h->hash_lock, &abstime);
if (prc != 0) {
fprintf(where,
"wait_for_tests_to_initialize: pthread_cond_wait failed %d\n",prc);
@@ -1741,6 +1772,8 @@
end of default command file commands */
/* parse command file */
+ fprintf(where,"parsing command file %s\n",iname);
+ fflush(where);
commands = parse_xml_file(iname, (const xmlChar *)"commands", &doc);
/* execute commands and events in a loop */
Modified: trunk/src/netperf.h
===================================================================
--- trunk/src/netperf.h 2005-10-20 00:10:11 UTC (rev 2)
+++ trunk/src/netperf.h 2005-10-25 00:15:58 UTC (rev 3)
@@ -31,6 +31,9 @@
xmlChar *id; /* the id of the server instance. used
in searches and as sanity checks */
+ pthread_rwlock_t rwlock; /* the mutex used to ensure exclusive
+ access to this servers resources */
+
pthread_mutex_t *lock; /* the mutex used to ensure exclusive
access to this servers resources */
@@ -196,7 +199,7 @@
} test_t;
-#define TEST_HASH_BUCKETS 8
+#define TEST_HASH_BUCKETS 16
#define TEST_HASH_VALUE(id) ((atoi((char *)id + 1)) % TEST_HASH_BUCKETS)
@@ -263,7 +266,7 @@
/* Error codes to be used within Netperf4 */
#define NPE_MIN_ERROR_NUM -1023
enum {
- NPE_MAX_ERROR_NUM = NPE_MIN_ERROR_NUM,
+ NPE_MAX_ERROR_NUM = NPE_MIN_ERROR_NUM, /* -1023 */
NPE_COMMANDED_TO_EXIT_NETPERF,
NPE_TEST_SET_NOT_FOUND,
NPE_BAD_TEST_RANGE,
@@ -273,7 +276,7 @@
NPE_TEST_NOT_FOUND,
NPE_TEST_FOUND_IN_ERROR_STATE,
NPE_TEST_INITIALIZED_FAILED,
- NPE_TEST_INIT_FAILED,
+ NPE_TEST_INIT_FAILED, /* -1013 */
NPE_INIT_TEST_XMLCOPYNODE_FAILED,
NPE_INIT_TEST_XMLNEWDOC_FAILED,
NPE_EMPTY_MSG,
@@ -281,7 +284,9 @@
NPE_ALREADY_CONNECTED,
NPE_BAD_VERSION,
NPE_XMLCOPYNODE_FAILED,
- NPE_PTHREAD_COND_WAIT_FAILED,
+ NPE_PTHREAD_MUTEX_INIT_FAILED,
+ NPE_PTHREAD_RWLOCK_INIT_FAILED,
+ NPE_PTHREAD_COND_WAIT_FAILED, /* -1003 */
NPE_PTHREAD_DETACH_FAILED,
NPE_PTHREAD_CREATE_FAILED,
NPE_DEPENDENCY_NOT_PRESENT,
@@ -290,7 +295,7 @@
NPE_FUNC_NAME_TOO_LONG,
NPE_FUNC_NOT_FOUND,
NPE_LIBRARY_NOT_LOADED,
- NPE_ADD_TO_EVENT_LIST_FAILED,
+ NPE_ADD_TO_EVENT_LIST_FAILED, /* -993 */
NPE_CONNECT_FAILED,
NPE_MALLOC_FAILED6,
NPE_MALLOC_FAILED5,
@@ -299,7 +304,7 @@
NPE_MALLOC_FAILED2,
NPE_MALLOC_FAILED1,
NPE_REMOTE_CLOSE,
- NPE_SEND_VERSION_XMLNEWNODE_FAILED,
+ NPE_SEND_VERSION_XMLNEWNODE_FAILED, /* -983 */
NPE_SEND_VERSION_XMLSETPROP_FAILED,
NPE_SEND_CTL_MSG_XMLDOCDUMPMEMORY_FAILED,
NPE_SEND_CTL_MSG_XMLCOPYNODE_FAILED,
@@ -335,6 +340,8 @@
"NPE_ALREADY_CONNECTED",
"NPE_BAD_VERSION",
"NPE_XMLCOPYNODE_FAILED",
+ "NPE_PTHREAD_MUTEX_INIT_FAILED",
+ "NPE_PTHREAD_RWLOCK_INIT_FAILED",
"NPE_PTHREAD_COND_WAIT_FAILED",
"NPE_PTHREAD_DETACH_FAILED",
"NPE_PTHREAD_CREATE_FAILED",
Modified: trunk/src/nettest_bsd.c
===================================================================
--- trunk/src/nettest_bsd.c 2005-10-20 00:10:11 UTC (rev 2)
+++ trunk/src/nettest_bsd.c 2005-10-25 00:15:58 UTC (rev 3)
@@ -71,11 +71,10 @@
/****************************************************************/
-
+#include <stdio.h>
#include <values.h>
#include <unistd.h>
#include <string.h>
-#include <stdio.h>
#include <errno.h>
#ifdef OFF
@@ -1139,6 +1138,10 @@
BSDE_DATA_RECV_ERROR,
"data_recv_error");
}
+ } else {
+ /* how do we deal with a closed connection in the loaded state */
+ fprintf(where,"\nWE JUST GOT A CLOSE INDICATION !!!!!!!!!!!!!!!!\n\n");
+ fflush(where);
}
/* code to timestamp enabled by HISTOGRAM */
HIST_TIMESTAMP(&time_two);
@@ -2247,8 +2250,8 @@
}
}
elapsed_seconds = test_cntr[TST_E_SEC] + test_cntr[TST_E_USEC]/1000000;
- xmit_rate = test_cntr[TST_X_BYTES]/(elapsed_seconds * 1000000);
- recv_rate = test_cntr[TST_R_BYTES]/(elapsed_seconds * 1000000);
+ xmit_rate = test_cntr[TST_X_BYTES]*8/(elapsed_seconds*1000000);
+ recv_rate = test_cntr[TST_R_BYTES]*8/(elapsed_seconds*1000000);
xmit_trans_rate = test_cntr[TST_X_TRANS]/elapsed_seconds;
recv_trans_rate = test_cntr[TST_R_TRANS]/elapsed_seconds;
if (debug || loc_debug) {
More information about the netperf-dev
mailing list