ndt-dev - [ndt] r318 committed - the write() function can get terminated by an interrupt. When there...
Subject: NDT-DEV email list created
List archive
[ndt] r318 committed - the write() function can get terminated by an interrupt. When there...
Chronological Thread
- From:
- To:
- Subject: [ndt] r318 committed - the write() function can get terminated by an interrupt. When there...
- Date: Sun, 21 Mar 2010 19:12:07 +0000
Revision: 318
Author: rcarlson501
Date: Sun Mar 21 12:11:15 2010
Log: the write() function can get terminated by an interrupt. When there
ar multiple clients running, the possibility of this happening increases.
This update wraps the write() calls in a for() loop. This way the write()
can get repeated up to 4 times. If all 4 write()'s fail then the test
will fail.
RAC 3/21/10
http://code.google.com/p/ndt/source/detail?r=318
Modified:
/trunk/src/web100srv.c
=======================================
--- /trunk/src/web100srv.c Sun Mar 21 11:04:42 2010
+++ /trunk/src/web100srv.c Sun Mar 21 12:11:15 2010
@@ -259,11 +259,11 @@
log_println(3, "wstopsig = %d", WSTOPSIG(status));
}
if (status != 0) {
- log_println(4, "child_sig() routine, wait4() non-zero status (%d) returned", status);
+ log_println(4, "child_sig() routine, wait3() non-zero status (%d) returned", status);
return;
}
}
- log_println(6, "child_sig() called pid=%d, wait3 returned child=%d - status=%d",
+ log_println(6, "child_sig() called pid=%d, wait returned child=%d - status=%d",
chld_pid, pid, status);
if (pid == 0) {
log_println(6, "wait3() failed to return non-zero PID, ignore it");
@@ -1276,7 +1276,8 @@
int
main(int argc, char** argv)
{
- int chld_pid, rc;
+ pid_t chld_pid;
+ int rc;
int tpid, mwaiting = 0;
int ctlsockfd = -1;
int c, chld_pipe[2];
@@ -1877,10 +1878,14 @@
}
/* the specially crafted data that kicks off the old clients */
-/* handle interrupt's to ensure that string is actually written
- * RAC 3/1/10
- */
- write(ctlsockfd, "123456 654321", 13);
+ for (i=0; i<5; i++) {
+ rc = write(ctlsockfd, "123456 654321", 13);
+ if ((rc == -1) && (errno == EINTR))
+ continue;
+ if (rc == 13)
+ break;
+ /* todo: handle other error contitions */
+ }
new_child = (struct ndtchild *) malloc(sizeof(struct ndtchild));
memset(new_child, 0, sizeof(struct ndtchild));
tt = time(0);
@@ -2124,12 +2129,14 @@
mclients++;
sprintf(tmpstr, "go %d %s", t_opts, test_suite);
send_msg(mchild->ctlsockfd, SRV_QUEUE, "0", 1);
-/* the write() call could return before any data is written if a interrupt is processed
- * change code to detect this condition and redo the write() if it exits prematurely.
- * fix here, below, and above where we write the 123456 string.
- * RAC 3/18/10
- */
- write(mchild->pipe, tmpstr, strlen(tmpstr));
+ for (i=0; i<5; i++) {
+ rc = write(mchild->pipe, tmpstr, strlen(tmpstr));
+ if ((rc == -1) && (errno == EINTR))
+ continue;
+ if (rc == strlen(tmpstr))
+ break;
+ /* TODO: handle other error conditions */
+ }
close(mchild->pipe);
close(mchild->ctlsockfd);
}
@@ -2138,7 +2145,14 @@
head_ptr->running = 1;
sprintf(tmpstr, "go %d %s", t_opts, head_ptr->tests);
send_msg(head_ptr->ctlsockfd, SRV_QUEUE, "0", 1);
- write(head_ptr->pipe, tmpstr, strlen(tmpstr));
+ for (i=0; i<5; i++) {
+ rc = write(head_ptr->pipe, tmpstr, strlen(tmpstr));
+ if ((rc == -1) && (errno == EINTR))
+ continue;
+ if (rc == strlen(tmpstr))
+ break;
+ /* TODO: handle other error conditions */
+ }
close(head_ptr->pipe);
close(head_ptr->ctlsockfd);
}
- [ndt] r318 committed - the write() function can get terminated by an interrupt. When there..., ndt, 03/21/2010
Archive powered by MHonArc 2.6.16.