Skip to Content.
Sympa Menu

ndt-dev - [ndt] r319 committed - Updating files to handle case where a write() or read() can return due...

Subject: NDT-DEV email list created

List archive

[ndt] r319 committed - Updating files to handle case where a write() or read() can return due...


Chronological Thread 
  • From:
  • To:
  • Subject: [ndt] r319 committed - Updating files to handle case where a write() or read() can return due...
  • Date: Tue, 23 Mar 2010 03:56:39 +0000

Revision: 319
Author: rcarlson501
Date: Mon Mar 22 20:56:00 2010
Log: Updating files to handle case where a write() or read() can return due
to an interrupt. In this case no date is written/read and the server may
not move to the next test. This would cause the server to timeout the client
and the client would report a failed test.

Previous changes also include a reduction in the firewall test time. The
original version had a max time of 30 sec. This may cause an alarm() signal
to go off terminating the server process. The max time was reduced to 3 sec.

RAC 3/22/10


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

Modified:
/trunk/src/testoptions.c
/trunk/src/web100-pcap.c
/trunk/src/web100-util.c
/trunk/src/web100srv.c

=======================================
--- /trunk/src/testoptions.c Sun Mar 21 11:04:42 2010
+++ /trunk/src/testoptions.c Mon Mar 22 20:56:00 2010
@@ -412,7 +412,7 @@
close(midfd);
close(options->midsockfd);
send_msg(ctlsockfd, TEST_FINALIZE, "", 0);
- log_println(1, " <-------------------->");
+ log_println(1, " <--------- %d ----------->", options->child0);
setCurrentTest(TEST_NONE);
}
/* I2AddrFree(midsrv_addr); */
@@ -701,6 +701,8 @@
}
if (ret > 0) {
n = read(recvsfd, buff, sizeof(buff));
+ if ((n == -1) && (errno == EINTR))
+ continue;
if (n == 0)
break;
bytes += n;
@@ -786,12 +788,18 @@
send_msg(ctlsockfd, TEST_FINALIZE, "", 0);

if (getuid() == 0) {
- write(mon_pipe1[1], "c", 1);
+ for (i=0; i<5; i++) {
+ ret = write(mon_pipe1[1], "c", 1);
+ if (ret == 1)
+ break;
+ if ((ret == -1) && (errno == EINTR))
+ continue;
+ }
close(mon_pipe1[0]);
close(mon_pipe1[1]);
}

- log_println(1, " <------------------------->");
+ log_println(1, " <----------- %d -------------->", testOptions->child0);
setCurrentTest(TEST_NONE);
}
/* I2AddrFree(c2ssrv_addr); */
@@ -1133,6 +1141,8 @@
}

n = write(xmitsfd, buff, RECLTH);
+ if ((n == -1) && (errno == EINTR))
+ continue;
if (n < 0)
break;
bytes += n;
@@ -1264,12 +1274,18 @@
log_println(6, "S2C test - failed to send finalize message to pid=%d", mon_pid2);

if (getuid() == 0) {
- write(mon_pipe2[1], "c", 1);
+ for (i=0; i<5; i++) {
+ ret = write(mon_pipe2[1], "c", 1);
+ if (ret == 1)
+ break;
+ if ((ret == -1) && (errno == EINTR))
+ continue;
+ }
close(mon_pipe2[0]);
close(mon_pipe2[1]);
}

- log_println(1, " <------------------------->");
+ log_println(1, " <------------ %d ------------->", testOptions->child0);
setCurrentTest(TEST_NONE);
}
/* I2AddrFree(s2csrv_addr); */
=======================================
--- /trunk/src/web100-pcap.c Tue Feb 9 17:30:07 2010
+++ /trunk/src/web100-pcap.c Mon Mar 22 20:56:00 2010
@@ -207,6 +207,7 @@
char buff[256];
int tzoffset = 6;
FILE *fp;
+ int j;

assert(cur);

@@ -343,10 +344,16 @@
cur->links[5], cur->links[6], cur->links[7], cur->links[8], cur->links[9],
cur->links[10], cur->links[11], cur->totalspd2, cur->inc_cnt, cur->dec_cnt,
cur->same_cnt, cur->timeout, cur->dupack, ifspeed);
- i = write(monitor_pipe[1], buff, strlen(buff));
- log_println(6, "wrote %d bytes: link counters are '%s'", i, buff);
- log_println(6, "#$#$#$#$ pcap routine says window increases = %d, decreases = %d, no change = %d",
- cur->inc_cnt, cur->dec_cnt, cur->same_cnt);
+ for (j=0; j<5; j++) {
+ i = write(monitor_pipe[1], buff, strlen(buff));
+ if (i == strlen(buff))
+ break;
+ if ((i == -1) && (errno == EINTR))
+ continue;
+ }
+ log_println(6, "wrote %d bytes: link counters are '%s'", i, buff);
+ log_println(6, "#$#$#$#$ pcap routine says window increases = %d, decreases = %d, no change = %d",
+ cur->inc_cnt, cur->dec_cnt, cur->same_cnt);
}

void calculate_spd(struct spdpair *cur, struct spdpair *cur2, int portA, int portB)
@@ -679,6 +686,7 @@
pcap_if_t *alldevs, *dp;
pcap_addr_t *curAddr;
DIR *dip;
+ int rc;

cnt = -1; /* read forever, or until end of file */
sig1 = 0;
@@ -865,10 +873,23 @@
}

printer = (pcap_handler) print_speed;
- if (dumptrace == 0)
- write(monitor_pipe[1], "Ready", 6);
- else
- write(monitor_pipe[1], dir, strlen(dir));
+ if (dumptrace == 0) {
+ for (i=0; i<5; i++) {
+ rc = write(monitor_pipe[1], "Ready", 6);
+ if (rc == 6)
+ break;
+ if ((rc == -1) && (errno == EINTR))
+ continue;
+ }
+ } else {
+ for (i=0; i<5; i++) {
+ rc = write(monitor_pipe[1], dir, strlen(dir));
+ if (rc == strlen(dir))
+ break;
+ if ((rc == -1) && (errno == EINTR))
+ continue;
+ }
+ }

/* kill process off if parent doesn't send a signal. */
alarm(60);
=======================================
--- /trunk/src/web100-util.c Sun Mar 21 11:04:42 2010
+++ /trunk/src/web100-util.c Mon Mar 22 20:56:00 2010
@@ -163,6 +163,8 @@
}

k = write(sock, sndbuff, octets);
+ if ((k == -1) && (errno == EINTR))
+ continue;
if (k < 0 )
break;
}
=======================================
--- /trunk/src/web100srv.c Sun Mar 21 12:11:15 2010
+++ /trunk/src/web100srv.c Mon Mar 22 20:56:00 2010
@@ -1704,7 +1704,7 @@
}

if ((waiting < 0) || (mclients < 0)) {
- log_println(6, "Fault: Negtive number of clents waiting=$d, mclients=%d, nuke them", waiting, mclients);
+ log_println(6, "Fault: Negative number of clents waiting=%d, mclients=%d, nuke them", waiting, mclients);
while (head_ptr != NULL) {
tpid = head_ptr->pid;
child_sig(-1);
@@ -1745,9 +1745,7 @@
log_println(5, "Empty slot in test queue, find new client to
dispatch");
tmp_ptr = head_ptr;
mchild = head_ptr;
- log_println(2, "starting queue look for non-running client current=%d, running=%d, next=0x%x",
- tmp_ptr->pid, tmp_ptr->running, tmp_ptr->next);
- while (tmp_ptr->next != NULL) {
+ while (tmp_ptr != NULL) {
log_println(2, "walking queue look for non-running client current=%d, running=%d, next=0x%x",
tmp_ptr->pid, tmp_ptr->running, tmp_ptr->next);
if (tmp_ptr->running == 0) {
@@ -1758,8 +1756,32 @@
}
if ((tmp_ptr->next == NULL) && (tmp_ptr->running == 0))
mchild = tmp_ptr;
- if (mchild != head_ptr)
- goto multi_client;
+ if (mchild != head_ptr) {
+ tmp_ptr = mchild;
+ /* update queued clients, send message to client when it moves
+ * up in the queue enough to get closer to running a test. This
happens
+ * when the client falls into the next lower maxquee bin
+ * RAC 3/21/10
+ */
+ if (waiting > (2*max_clients)) {
+ for (i=max_clients; i<=waiting; i++) {
+ if (tmp_ptr == NULL)
+ break;
+ if (i == (2*max_clients)) {
+ log_println(6, "Updating client list position client %d moved now 45 sec away",
+ tmp_ptr->pid);
+ send_msg(tmp_ptr->ctlsockfd, SRV_QUEUE, "1", 1);
+ }
+ if (i == (3*max_clients)) {
+ log_println(6, "Updating client list position client %d moved now 90 sec away",
+ tmp_ptr->pid);
+ send_msg(tmp_ptr->ctlsockfd, SRV_QUEUE, "2", 1);
+ }
+ tmp_ptr = tmp_ptr->next;
+ }
+ goto multi_client;
+ }
+ }
}

if ((multiple == 1) && (mclients > waiting)) {
@@ -2127,7 +2149,7 @@
mchild->stime = time(0);
mchild->running = 1;
mclients++;
- sprintf(tmpstr, "go %d %s", t_opts, test_suite);
+ sprintf(tmpstr, "go %d %s", t_opts, mchild->tests);
send_msg(mchild->ctlsockfd, SRV_QUEUE, "0", 1);
for (i=0; i<5; i++) {
rc = write(mchild->pipe, tmpstr, strlen(tmpstr));
@@ -2182,7 +2204,9 @@
* should be checked for and the read() restarted if necessary
* RAC 3/18/10
*/
- read(chld_pipe[0], buff, 32);
+ rc = read(chld_pipe[0], buff, 32);
+ if ((rc == -1) && (errno == EINTR))
+ continue;
if (strncmp(buff, "go", 2) == 0) {
log_println(6, "Got 'go' signal from parent, ready to start testing");
break;


  • [ndt] r319 committed - Updating files to handle case where a write() or read() can return due..., ndt, 03/22/2010

Archive powered by MHonArc 2.6.16.

Top of Page