Skip to Content.
Sympa Menu

ndt-dev - [ndt-dev] [ndt] r916 committed - Resolve Issue 122...

Subject: NDT-DEV email list created

List archive

[ndt-dev] [ndt] r916 committed - Resolve Issue 122...


Chronological Thread 
  • From:
  • To:
  • Subject: [ndt-dev] [ndt] r916 committed - Resolve Issue 122...
  • Date: Fri, 14 Feb 2014 15:28:55 +0000

Revision: 916
Author:

Date: Fri Feb 14 15:28:42 2014 UTC
Log: Resolve Issue 122

1. Use string constants when sending error codes
to the client.
2. In initialize_tests, use local buffers to send
error messages to the client.


http://code.google.com/p/ndt/source/detail?r=916

Modified:
/branches/Issue122/src/protocol.h
/branches/Issue122/src/testoptions.c
/branches/Issue122/src/web100srv.c

=======================================
--- /branches/Issue122/src/protocol.h Thu Nov 15 21:34:19 2012 UTC
+++ /branches/Issue122/src/protocol.h Fri Feb 14 15:28:42 2014 UTC
@@ -25,10 +25,24 @@
#define MSG_WAITING 10

#define SRV_QUEUE_TEST_STARTS_NOW 0
+#define SRV_QUEUE_TEST_STARTS_NOW_STR "0"
+#define SRV_QUEUE_TEST_STARTS_NOW_STR_LN 4
+
#define SRV_QUEUE_SERVER_FAULT 9977
+#define SRV_QUEUE_SERVER_FAULT_STR "9977"
+#define SRV_QUEUE_SERVER_FAULT_STR_LN 4
+
#define SRV_QUEUE_SERVER_BUSY 9988
+#define SRV_QUEUE_SERVER_BUSY_STR "9988"
+#define SRV_QUEUE_SERVER_BUSY_STR_LN 4
+
#define SRV_QUEUE_HEARTBEAT 9990
+#define SRV_QUEUE_HEARTBEAT_STR "9990"
+#define SRV_QUEUE_HEARTBEAT_STR_LN 4
+
#define SRV_QUEUE_SERVER_BUSY_60s 9999
+#define SRV_QUEUE_SERVER_BUSY_60s_STR "9999"
+#define SRV_QUEUE_SERVER_BUSY_60s_STR_LN 4

/*
#define TEST_NONE 0
=======================================
--- /branches/Issue122/src/testoptions.c Mon Oct 14 13:20:21 2013 UTC
+++ /branches/Issue122/src/testoptions.c Fri Feb 14 15:28:42 2014 UTC
@@ -210,6 +210,10 @@
int msgType;
int msgLen = 1;
int first = 1;
+ char *invalid_test_suite = "Invalid test suite request.";
+ char *client_timeout = "Client timeout.";
+ char *invalid_test = "Invalid test request.";
+
// char remhostarr[256], protologlocalarr[256];
// char *remhost_ptr = get_remotehost();

@@ -218,8 +222,8 @@

// read the test suite request
if (recv_msg(ctlsockfd, &msgType, &useropt, &msgLen)) {
- snprintf(buff, buff_strlen, "Invalid test suite request");
- send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
+ send_msg(ctlsockfd, MSG_ERROR, invalid_test_suite,
+ strlen(invalid_test_suite));
return (-1);
}
if (msgLen == -1) {
@@ -228,8 +232,7 @@
}
// Expecting a MSG_LOGIN with payload byte indicating tests to be run
if ((msgType != MSG_LOGIN) || (msgLen != 1)) {
- snprintf(buff, buff_strlen, "Invalid test request");
- send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
+ send_msg(ctlsockfd, MSG_ERROR, invalid_test, strlen(invalid_test));
return (-2);
}
// client connect received correctly. Logging activity
@@ -244,8 +247,8 @@
& (TEST_MID | TEST_C2S | TEST_S2C | TEST_SFW | TEST_STATUS
| TEST_META))) {
// message received does not indicate a valid test!
- snprintf(buff, buff_strlen, "Invalid test suite request");
- send_msg(ctlsockfd, MSG_ERROR, buff, strlen(buff));
+ send_msg(ctlsockfd, MSG_ERROR, invalid_test_suite,
+ strlen(invalid_test_suite));
return (-3);
}
// construct test suite request based on user options received
=======================================
--- /branches/Issue122/src/web100srv.c Mon Oct 14 13:20:21 2013 UTC
+++ /branches/Issue122/src/web100srv.c Fri Feb 14 15:28:42 2014 UTC
@@ -757,7 +757,7 @@
int i = 0, retcode;
struct timeval sel_tv;
fd_set rfd;
- char tmpstr[8], buff[32];
+ char buff[32];
int msgType, msgLen = 1;

tmp_ptr = (struct ndtchild *) head_ptr;
@@ -772,7 +772,6 @@
pre_ptr = tmp_ptr;
tmp_ptr = tmp_ptr->next;
}
- snprintf(tmpstr, sizeof(tmpstr), "9990");
i = 0;
while (tmp_ptr != NULL) {
if (tmp_ptr->oldclient == 0) {
@@ -788,8 +787,9 @@
tmp_ptr->pid);

// send "keep-alive" SRV_QUEUE message to client and expect a response
- retcode = send_msg(tmp_ptr->ctlsockfd, SRV_QUEUE, tmpstr,
- strlen(tmpstr));
+ retcode = send_msg(tmp_ptr->ctlsockfd, SRV_QUEUE,
+ SRV_QUEUE_HEARTBEAT_STR,
+ SRV_QUEUE_HEARTBEAT_STR_LN);
log_println(6,
"send_msg() returned %d during zombie check on client %d",
retcode, tmp_ptr->pid);
@@ -2027,7 +2027,9 @@
while (head_ptr != NULL) {
/* send_msg(head_ptr->ctlsockfd, SRV_QUEUE, "9933", 4); */
// indicate server waiting in queue
- send_msg(head_ptr->ctlsockfd, SRV_QUEUE, "9988", 4);
+ send_msg(head_ptr->ctlsockfd, SRV_QUEUE,
+ SRV_QUEUE_SERVER_BUSY_STR,
+ SRV_QUEUE_SERVER_BUSY_STR_LN);
shutdown(head_ptr->ctlsockfd, SHUT_WR);
close(head_ptr->ctlsockfd);
tpid = head_ptr->pid;
@@ -2046,7 +2048,9 @@
"clients", head_ptr->pid);
while (head_ptr != NULL) {
/* send_msg(head_ptr->ctlsockfd, SRV_QUEUE, "9977", 4); */
- send_msg(head_ptr->ctlsockfd, SRV_QUEUE, "9988", 4);
+ send_msg(head_ptr->ctlsockfd, SRV_QUEUE,
+ SRV_QUEUE_SERVER_BUSY_STR,
+ SRV_QUEUE_SERVER_BUSY_STR_LN);
shutdown(head_ptr->ctlsockfd, SHUT_WR);
close(head_ptr->ctlsockfd);
tpid = head_ptr->pid;
@@ -2080,7 +2084,9 @@
head_ptr->pipe, head_ptr->running, head_ptr->ctlsockfd,
head_ptr->oldclient, head_ptr->tests);
// boot the client
- send_msg(head_ptr->ctlsockfd, SRV_QUEUE, "9988", 4);
+ send_msg(head_ptr->ctlsockfd, SRV_QUEUE,
+ SRV_QUEUE_SERVER_BUSY_STR,
+ SRV_QUEUE_SERVER_BUSY_STR_LN);
shutdown(head_ptr->ctlsockfd, SHUT_WR);
close(head_ptr->ctlsockfd);
tpid = head_ptr->pid;
@@ -2287,9 +2293,9 @@
0,
"Too many clients/mclients (%d) waiting to be served, "
"Please try again later.", chld_pid);
- // 9988 = server_BUSY_OR_ERROR
- snprintf(tmpstr, sizeof(tmpstr), "9988");
- send_msg(ctlsockfd, SRV_QUEUE, tmpstr, strlen(tmpstr));
+ send_msg(ctlsockfd, SRV_QUEUE,
+ SRV_QUEUE_SERVER_BUSY_STR,
+ SRV_QUEUE_SERVER_BUSY_STR_LN);
close(chld_pipe[0]);
close(chld_pipe[1]);
shutdown(ctlsockfd, SHUT_WR);
@@ -2306,18 +2312,16 @@
t_opts = initialize_tests(ctlsockfd, &testopt, test_suite,
sizeof(test_suite));
if (t_opts < 1) { // some error in initialization routines
- log_println(
- 3,
- "Invalid test suite string '%s' received, terminate child",
- test_suite);
+ log_println(3, "Invalid test suite received, terminate child");
close(chld_pipe[0]);
close(chld_pipe[1]);
shutdown(ctlsockfd, SHUT_WR);
close(ctlsockfd);
kill(chld_pid, SIGTERM);
if (new_child != NULL) {
- log_println(6, "invalid test suite, freeing new_child=0x%x",
- new_child);
+ log_println(6, "Freeing new_child=0x%x because of "
+ "invalid test suite",
+ new_child);
free(new_child);
}
continue;
@@ -2351,7 +2355,7 @@
else
new_child->oldclient = 0;
memset(new_child->tests, 0, sizeof(test_suite));
- memcpy(new_child->tests, test_suite, strlen(test_suite));
+ memcpy(new_child->tests, test_suite, sizeof(test_suite));
new_child->next = NULL;
/* sigprocmask(SIG_SETMASK, &oldmask, NULL); */
sem_post(&ndtq);
@@ -2372,7 +2376,9 @@
3,
"queuing disabled and testing in progress, tell client no");
/* send_msg(new_child->ctlsockfd, SRV_QUEUE, "9944", 4); */
- send_msg(new_child->ctlsockfd, SRV_QUEUE, "9988", 4);
+ send_msg(new_child->ctlsockfd, SRV_QUEUE,
+ SRV_QUEUE_SERVER_BUSY_STR,
+ SRV_QUEUE_SERVER_BUSY_STR_LN);
close(chld_pipe[1]);
shutdown(new_child->ctlsockfd, SHUT_WR);
close(new_child->ctlsockfd);


  • [ndt-dev] [ndt] r916 committed - Resolve Issue 122..., ndt, 02/14/2014

Archive powered by MHonArc 2.6.16.

Top of Page