[mpich2-commits] r4065 - mpich2/trunk/src/pm/hydra/utils/sock
balaji at mcs.anl.gov
balaji at mcs.anl.gov
Sat Mar 14 07:22:54 CDT 2009
Author: balaji
Date: 2009-03-14 07:22:54 -0500 (Sat, 14 Mar 2009)
New Revision: 4065
Modified:
mpich2/trunk/src/pm/hydra/utils/sock/sock.c
Log:
Fixes to the stdout management code. When there was a lot of stdout data,
some of it was being dropped as we were not checking to see how much
data was actually written out before returning.
Modified: mpich2/trunk/src/pm/hydra/utils/sock/sock.c
===================================================================
--- mpich2/trunk/src/pm/hydra/utils/sock/sock.c 2009-03-13 23:50:12 UTC (rev 4064)
+++ mpich2/trunk/src/pm/hydra/utils/sock/sock.c 2009-03-14 12:22:54 UTC (rev 4065)
@@ -388,7 +388,7 @@
HYD_Status HYDU_Sock_stdout_cb(int fd, HYD_Event_t events, int stdout_fd, int *closed)
{
- int count;
+ int count, written, ret;
char buf[HYD_TMPBUF_SIZE];
HYD_Status status = HYD_SUCCESS;
@@ -414,11 +414,16 @@
goto fn_exit;
}
- count = write(stdout_fd, buf, count);
- if (count < 0) {
- HYDU_Error_printf("socket write error on fd: %d (errno: %d)\n", fd, errno);
- status = HYD_SOCK_ERROR;
- goto fn_fail;
+ written = 0;
+ while (written != count) {
+ ret = write(stdout_fd, buf + written, count - written);
+ if (ret < 0 && errno != EAGAIN) {
+ HYDU_Error_printf("socket write error on fd: %d (errno: %d)\n", stdout_fd, errno);
+ status = HYD_SOCK_ERROR;
+ goto fn_fail;
+ }
+ if (ret > 0)
+ written += ret;
}
fn_exit:
@@ -470,7 +475,7 @@
break;
}
- HYDU_Error_printf("socket read error on fd: %d (errno: %d)\n", fd, errno);
+ HYDU_Error_printf("socket read error on fd: %d (errno: %d)\n", 0, errno);
status = HYD_SOCK_ERROR;
goto fn_fail;
}
More information about the mpich2-commits
mailing list