Commit 7f658475 authored by Pavan Balaji's avatar Pavan Balaji
Browse files

[svn-r10697] Update the HYDU_sock_write function to explicitly take a

block/no-block parameter.

No reviewer.
parent 2236f947
......@@ -533,7 +533,8 @@ HYD_status HYDU_sock_connect(const char *host, uint16_t port, int *fd, int retri
HYD_status HYDU_sock_accept(int listen_fd, int *fd);
HYD_status HYDU_sock_read(int fd, void *buf, int maxlen, int *recvd, int *closed,
enum HYDU_sock_comm_flag flag);
HYD_status HYDU_sock_write(int fd, const void *buf, int maxlen, int *sent, int *closed);
HYD_status HYDU_sock_write(int fd, const void *buf, int maxlen, int *sent, int *closed,
enum HYDU_sock_comm_flag flag);
HYD_status HYDU_sock_forward_stdio(int in, int out, int *closed);
HYD_status HYDU_sock_get_iface_ip(char *iface, char **ip);
HYD_status HYDU_sock_is_local(char *host, int *is_local);
......
......@@ -195,7 +195,7 @@ int main(int argc, char **argv)
status = HYDU_sock_write(HYD_pmcd_pmip.upstream.control,
&HYD_pmcd_pmip.local.id, sizeof(HYD_pmcd_pmip.local.id), &sent,
&closed);
&closed, HYDU_SOCK_COMM_MSGWAIT);
HYDU_ERR_POP(status, "unable to send the proxy ID to the server\n");
if (closed)
goto fn_fail;
......@@ -264,14 +264,15 @@ int main(int argc, char **argv)
HYD_pmcd_init_header(&hdr);
hdr.cmd = EXIT_STATUS;
status =
HYDU_sock_write(HYD_pmcd_pmip.upstream.control, &hdr, sizeof(hdr), &sent, &closed);
HYDU_sock_write(HYD_pmcd_pmip.upstream.control, &hdr, sizeof(hdr), &sent, &closed,
HYDU_SOCK_COMM_MSGWAIT);
HYDU_ERR_POP(status, "unable to send EXIT_STATUS command upstream\n");
HYDU_ASSERT(!closed, status);
status = HYDU_sock_write(HYD_pmcd_pmip.upstream.control,
HYD_pmcd_pmip.downstream.exit_status,
HYD_pmcd_pmip.local.proxy_process_count * sizeof(int), &sent,
&closed);
&closed, HYDU_SOCK_COMM_MSGWAIT);
HYDU_ERR_POP(status, "unable to return exit status upstream\n");
HYDU_ASSERT(!closed, status);
......
......@@ -59,12 +59,12 @@ static HYD_status stdoe_cb(int fd, HYD_event_t events, void *userp)
int upstream_sock_closed;
status = HYDU_sock_write(HYD_pmcd_pmip.upstream.control, &hdr, sizeof(hdr), &sent,
&upstream_sock_closed);
&upstream_sock_closed, HYDU_SOCK_COMM_MSGWAIT);
HYDU_ERR_POP(status, "sock write error\n");
HYDU_ASSERT(!upstream_sock_closed, status);
status = HYDU_sock_write(HYD_pmcd_pmip.upstream.control, buf, recvd, &sent,
&upstream_sock_closed);
&upstream_sock_closed, HYDU_SOCK_COMM_MSGWAIT);
HYDU_ERR_POP(status, "sock write error\n");
HYDU_ASSERT(!upstream_sock_closed, status);
}
......@@ -281,7 +281,7 @@ static HYD_status pmi_cb(int fd, HYD_event_t events, void *userp)
hdr.cmd = PROCESS_TERMINATED;
hdr.pid = HYD_pmcd_pmip.downstream.pmi_rank[pid];
status = HYDU_sock_write(HYD_pmcd_pmip.upstream.control, &hdr, sizeof(hdr),
&sent, &closed);
&sent, &closed, HYDU_SOCK_COMM_MSGWAIT);
HYDU_ERR_POP(status, "unable to send PMI header upstream\n");
HYDU_ASSERT(!closed, status);
}
......@@ -340,12 +340,14 @@ static HYD_status pmi_cb(int fd, HYD_event_t events, void *userp)
hdr.pid = fd;
hdr.buflen = strlen(buf);
status =
HYDU_sock_write(HYD_pmcd_pmip.upstream.control, &hdr, sizeof(hdr), &sent, &closed);
HYDU_sock_write(HYD_pmcd_pmip.upstream.control, &hdr, sizeof(hdr), &sent, &closed,
HYDU_SOCK_COMM_MSGWAIT);
HYDU_ERR_POP(status, "unable to send PMI header upstream\n");
HYDU_ASSERT(!closed, status);
status =
HYDU_sock_write(HYD_pmcd_pmip.upstream.control, buf, hdr.buflen, &sent, &closed);
HYDU_sock_write(HYD_pmcd_pmip.upstream.control, buf, hdr.buflen, &sent, &closed,
HYDU_SOCK_COMM_MSGWAIT);
HYDU_ERR_POP(status, "unable to send PMI command upstream\n");
HYDU_ASSERT(!closed, status);
......@@ -399,7 +401,7 @@ static HYD_status handle_pmi_response(int fd, struct HYD_pmcd_hdr hdr)
pmi_cmd);
}
status = HYDU_sock_write(hdr.pid, buf, hdr.buflen, &sent, &closed);
status = HYDU_sock_write(hdr.pid, buf, hdr.buflen, &sent, &closed, HYDU_SOCK_COMM_MSGWAIT);
HYDU_ERR_POP(status, "unable to forward PMI response to MPI process\n");
if (HYD_pmcd_pmip.user_global.auto_cleanup) {
......@@ -727,14 +729,15 @@ static HYD_status launch_procs(void)
HYD_pmcd_init_header(&hdr);
hdr.cmd = PID_LIST;
status =
HYDU_sock_write(HYD_pmcd_pmip.upstream.control, &hdr, sizeof(hdr), &sent, &closed);
HYDU_sock_write(HYD_pmcd_pmip.upstream.control, &hdr, sizeof(hdr), &sent, &closed,
HYDU_SOCK_COMM_MSGWAIT);
HYDU_ERR_POP(status, "unable to send PID_LIST command upstream\n");
HYDU_ASSERT(!closed, status);
status = HYDU_sock_write(HYD_pmcd_pmip.upstream.control,
HYD_pmcd_pmip.downstream.pid,
HYD_pmcd_pmip.local.proxy_process_count * sizeof(int), &sent,
&closed);
&closed, HYDU_SOCK_COMM_MSGWAIT);
HYDU_ERR_POP(status, "unable to send PID list upstream\n");
HYDU_ASSERT(!closed, status);
......@@ -929,7 +932,7 @@ HYD_status HYD_pmcd_pmip_control_cmd_cb(int fd, HYD_event_t events, void *userp)
HYDU_ASSERT(!closed, status);
status = HYDU_sock_write(HYD_pmcd_pmip.downstream.in, buf, hdr.buflen, &count,
&closed);
&closed, HYDU_SOCK_COMM_MSGWAIT);
HYDU_ERR_POP(status, "unable to write to downstream stdin\n");
if (HYD_pmcd_pmip.user_global.auto_cleanup) {
......
......@@ -39,7 +39,8 @@ static HYD_status send_cmd_upstream(const char *start, int fd, char *args[])
hdr.buflen = strlen(buf);
hdr.pmi_version = 1;
status =
HYDU_sock_write(HYD_pmcd_pmip.upstream.control, &hdr, sizeof(hdr), &sent, &closed);
HYDU_sock_write(HYD_pmcd_pmip.upstream.control, &hdr, sizeof(hdr), &sent, &closed,
HYDU_SOCK_COMM_MSGWAIT);
HYDU_ERR_POP(status, "unable to send PMI header upstream\n");
HYDU_ASSERT(!closed, status);
......@@ -47,7 +48,8 @@ static HYD_status send_cmd_upstream(const char *start, int fd, char *args[])
HYDU_dump(stdout, "forwarding command (%s) upstream\n", buf);
}
status = HYDU_sock_write(HYD_pmcd_pmip.upstream.control, buf, hdr.buflen, &sent, &closed);
status = HYDU_sock_write(HYD_pmcd_pmip.upstream.control, buf, hdr.buflen, &sent, &closed,
HYDU_SOCK_COMM_MSGWAIT);
HYDU_ERR_POP(status, "unable to send PMI command upstream\n");
HYDU_ASSERT(!closed, status);
......@@ -72,7 +74,7 @@ static HYD_status send_cmd_downstream(int fd, const char *cmd)
HYDU_dump(stdout, "PMI response: %s", cmd);
}
status = HYDU_sock_write(fd, cmd, strlen(cmd), &sent, &closed);
status = HYDU_sock_write(fd, cmd, strlen(cmd), &sent, &closed, HYDU_SOCK_COMM_MSGWAIT);
HYDU_ERR_POP(status, "error writing PMI line\n");
/* FIXME: We cannot abort when we are not able to send data
* downstream. The upper layer needs to handle this based on
......
......@@ -43,7 +43,8 @@ static HYD_status send_cmd_upstream(const char *start, int fd, char *args[])
hdr.buflen = strlen(buf);
hdr.pmi_version = 2;
status =
HYDU_sock_write(HYD_pmcd_pmip.upstream.control, &hdr, sizeof(hdr), &sent, &closed);
HYDU_sock_write(HYD_pmcd_pmip.upstream.control, &hdr, sizeof(hdr), &sent, &closed,
HYDU_SOCK_COMM_MSGWAIT);
HYDU_ERR_POP(status, "unable to send PMI header upstream\n");
HYDU_ASSERT(!closed, status);
......@@ -51,7 +52,8 @@ static HYD_status send_cmd_upstream(const char *start, int fd, char *args[])
HYDU_dump(stdout, "forwarding command (%s) upstream\n", buf);
}
status = HYDU_sock_write(HYD_pmcd_pmip.upstream.control, buf, hdr.buflen, &sent, &closed);
status = HYDU_sock_write(HYD_pmcd_pmip.upstream.control, buf, hdr.buflen, &sent, &closed,
HYDU_SOCK_COMM_MSGWAIT);
HYDU_ERR_POP(status, "unable to send PMI command upstream\n");
HYDU_ASSERT(!closed, status);
......@@ -72,7 +74,7 @@ static HYD_status send_cmd_downstream(int fd, const char *cmd)
HYDU_FUNC_ENTER();
HYDU_snprintf(cmdlen, 7, "%6u", (unsigned) strlen(cmd));
status = HYDU_sock_write(fd, cmdlen, 6, &sent, &closed);
status = HYDU_sock_write(fd, cmdlen, 6, &sent, &closed, HYDU_SOCK_COMM_MSGWAIT);
HYDU_ERR_POP(status, "error writing PMI line\n");
/* FIXME: We cannot abort when we are not able to send data
* downstream. The upper layer needs to handle this based on
......@@ -83,7 +85,7 @@ static HYD_status send_cmd_downstream(int fd, const char *cmd)
HYDU_dump(stdout, "PMI response: %s\n", cmd);
}
status = HYDU_sock_write(fd, cmd, strlen(cmd), &sent, &closed);
status = HYDU_sock_write(fd, cmd, strlen(cmd), &sent, &closed, HYDU_SOCK_COMM_MSGWAIT);
HYDU_ERR_POP(status, "error writing PMI line\n");
HYDU_ASSERT(!closed, status);
......
......@@ -165,7 +165,8 @@ HYD_status HYD_pmcd_pmiserv_send_signal(struct HYD_proxy *proxy, int signum)
hdr.cmd = SIGNAL;
hdr.signum = signum;
status = HYDU_sock_write(proxy->control_fd, &hdr, sizeof(hdr), &sent, &closed);
status = HYDU_sock_write(proxy->control_fd, &hdr, sizeof(hdr), &sent, &closed,
HYDU_SOCK_COMM_MSGWAIT);
HYDU_ERR_POP(status, "unable to write data to proxy\n");
HYDU_ASSERT(!closed, status);
......@@ -309,12 +310,14 @@ static HYD_status control_cb(int fd, HYD_event_t events, void *userp)
hdr.buflen = count;
HYDU_sock_write(proxy->control_fd, &hdr, sizeof(hdr), &count, &closed);
HYDU_sock_write(proxy->control_fd, &hdr, sizeof(hdr), &count, &closed,
HYDU_SOCK_COMM_MSGWAIT);
HYDU_ERR_POP(status, "error writing to control socket\n");
HYDU_ASSERT(!closed, status);
if (hdr.buflen) {
HYDU_sock_write(proxy->control_fd, buf, hdr.buflen, &count, &closed);
HYDU_sock_write(proxy->control_fd, buf, hdr.buflen, &count, &closed,
HYDU_SOCK_COMM_MSGWAIT);
HYDU_ERR_POP(status, "error writing to control socket\n");
HYDU_ASSERT(!closed, status);
......@@ -479,7 +482,8 @@ static HYD_status send_exec_info(struct HYD_proxy *proxy)
HYD_pmcd_init_header(&hdr);
hdr.cmd = PROC_INFO;
status = HYDU_sock_write(proxy->control_fd, &hdr, sizeof(hdr), &sent, &closed);
status = HYDU_sock_write(proxy->control_fd, &hdr, sizeof(hdr), &sent, &closed,
HYDU_SOCK_COMM_MSGWAIT);
HYDU_ERR_POP(status, "unable to write data to proxy\n");
HYDU_ASSERT(!closed, status);
......@@ -556,7 +560,8 @@ HYD_status HYD_pmcd_pmiserv_proxy_init_cb(int fd, HYD_event_t events, void *user
else {
hdr.cmd = STDIN;
hdr.buflen = 0;
HYDU_sock_write(proxy->control_fd, &hdr, sizeof(hdr), &count, &closed);
HYDU_sock_write(proxy->control_fd, &hdr, sizeof(hdr), &count, &closed,
HYDU_SOCK_COMM_MSGWAIT);
HYDU_ERR_POP(status, "error writing to control socket\n");
HYDU_ASSERT(!closed, status);
}
......
......@@ -26,7 +26,8 @@ static HYD_status send_cmd_to_proxies(struct HYD_pmcd_hdr hdr)
/* Send the command to all proxies */
for (proxy = pg->proxy_list; proxy; proxy = proxy->next) {
status = HYDU_sock_write(proxy->control_fd, &hdr, sizeof(hdr), &sent, &closed);
status = HYDU_sock_write(proxy->control_fd, &hdr, sizeof(hdr), &sent, &closed,
HYDU_SOCK_COMM_MSGWAIT);
HYDU_ERR_POP(status, "unable to send checkpoint message\n");
HYDU_ASSERT(!closed, status);
}
......
......@@ -24,7 +24,7 @@ static HYD_status cmd_response(int fd, int pid, const char *cmd)
hdr.pid = pid;
hdr.pmi_version = 1;
hdr.buflen = strlen(cmd);
status = HYDU_sock_write(fd, &hdr, sizeof(hdr), &sent, &closed);
status = HYDU_sock_write(fd, &hdr, sizeof(hdr), &sent, &closed, HYDU_SOCK_COMM_MSGWAIT);
HYDU_ERR_POP(status, "unable to send PMI_RESPONSE header to proxy\n");
HYDU_ASSERT(!closed, status);
......@@ -32,7 +32,7 @@ static HYD_status cmd_response(int fd, int pid, const char *cmd)
HYDU_dump(stdout, "PMI response to fd %d pid %d: %s", fd, pid, cmd);
}
status = HYDU_sock_write(fd, cmd, strlen(cmd), &sent, &closed);
status = HYDU_sock_write(fd, cmd, strlen(cmd), &sent, &closed, HYDU_SOCK_COMM_MSGWAIT);
HYDU_ERR_POP(status, "unable to send response to command\n");
HYDU_ASSERT(!closed, status);
......
......@@ -33,12 +33,12 @@ static HYD_status cmd_response(int fd, int pid, char *cmd)
hdr.pid = pid;
hdr.pmi_version = 2;
hdr.buflen = 6 + strlen(cmd);
status = HYDU_sock_write(fd, &hdr, sizeof(hdr), &sent, &closed);
status = HYDU_sock_write(fd, &hdr, sizeof(hdr), &sent, &closed, HYDU_SOCK_COMM_MSGWAIT);
HYDU_ERR_POP(status, "unable to send PMI_RESPONSE header to proxy\n");
HYDU_ASSERT(!closed, status);
HYDU_snprintf(cmdlen, 7, "%6u", (unsigned) strlen(cmd));
status = HYDU_sock_write(fd, cmdlen, 6, &sent, &closed);
status = HYDU_sock_write(fd, cmdlen, 6, &sent, &closed, HYDU_SOCK_COMM_MSGWAIT);
HYDU_ERR_POP(status, "error writing PMI line\n");
HYDU_ASSERT(!closed, status);
......@@ -46,7 +46,7 @@ static HYD_status cmd_response(int fd, int pid, char *cmd)
HYDU_dump(stdout, "PMI response to fd %d pid %d: %s\n", fd, pid, cmd);
}
status = HYDU_sock_write(fd, cmd, strlen(cmd), &sent, &closed);
status = HYDU_sock_write(fd, cmd, strlen(cmd), &sent, &closed, HYDU_SOCK_COMM_MSGWAIT);
HYDU_ERR_POP(status, "error writing PMI line\n");
HYDU_ASSERT(!closed, status);
......
......@@ -31,13 +31,15 @@ static HYD_status persist_cb(int fd, HYD_event_t events, void *userp)
HYDU_ASSERT(!closed, status);
if (hdr.io_type == HYDT_PERSIST_STDOUT) {
HYDU_sock_write(STDOUT_FILENO, buf, hdr.buflen, &sent, &closed);
HYDU_sock_write(STDOUT_FILENO, buf, hdr.buflen, &sent, &closed,
HYDU_SOCK_COMM_MSGWAIT);
HYDU_ERR_POP(status, "stdout forwarding error\n");
HYDU_ASSERT(!closed, status);
HYDU_ASSERT(sent == hdr.buflen, status);
}
else {
HYDU_sock_write(STDERR_FILENO, buf, hdr.buflen, &sent, &closed);
HYDU_sock_write(STDERR_FILENO, buf, hdr.buflen, &sent, &closed,
HYDU_SOCK_COMM_MSGWAIT);
HYDU_ERR_POP(status, "stderr forwarding error\n");
HYDU_ASSERT(!closed, status);
HYDU_ASSERT(sent == hdr.buflen, status);
......
......@@ -86,12 +86,14 @@ static HYD_status stdio_cb(int fd, HYD_event_t events, void *userp)
hdr.io_type = HYDT_PERSIST_STDOUT;
hdr.buflen = count;
status = HYDU_sock_write(private.client_fd, &hdr, sizeof(hdr), &sent, &closed);
status = HYDU_sock_write(private.client_fd, &hdr, sizeof(hdr), &sent, &closed,
HYDU_SOCK_COMM_MSGWAIT);
HYDU_ERR_POP(status, "error sending header to client\n");
HYDU_ASSERT(!closed, status);
if (hdr.buflen) {
status = HYDU_sock_write(private.client_fd, buf, count, &sent, &closed);
status = HYDU_sock_write(private.client_fd, buf, count, &sent, &closed,
HYDU_SOCK_COMM_MSGWAIT);
HYDU_ERR_POP(status, "error sending stdout to client\n");
HYDU_ASSERT(!closed, status);
}
......@@ -115,12 +117,14 @@ static HYD_status stdio_cb(int fd, HYD_event_t events, void *userp)
hdr.io_type = HYDT_PERSIST_STDOUT;
hdr.buflen = count;
status = HYDU_sock_write(private.client_fd, &hdr, sizeof(hdr), &sent, &closed);
status = HYDU_sock_write(private.client_fd, &hdr, sizeof(hdr), &sent, &closed,
HYDU_SOCK_COMM_MSGWAIT);
HYDU_ERR_POP(status, "error sending header to client\n");
HYDU_ASSERT(!closed, status);
if (hdr.buflen) {
status = HYDU_sock_write(private.client_fd, buf, count, &sent, &closed);
status = HYDU_sock_write(private.client_fd, buf, count, &sent, &closed,
HYDU_SOCK_COMM_MSGWAIT);
HYDU_ERR_POP(status, "error sending stdout to client\n");
HYDU_ASSERT(!closed, status);
}
......
......@@ -101,12 +101,12 @@ static HYD_status cmd_response(int fd, const char *str)
HYDU_FUNC_ENTER();
status = HYDU_sock_write(fd, &len, sizeof(int), &sent, &closed);
status = HYDU_sock_write(fd, &len, sizeof(int), &sent, &closed, HYDU_SOCK_COMM_MSGWAIT);
HYDU_ERR_POP(status, "error sending publish info\n");
HYDU_ASSERT(!closed, status);
if (len) {
status = HYDU_sock_write(fd, str, len, &sent, &closed);
status = HYDU_sock_write(fd, str, len, &sent, &closed, HYDU_SOCK_COMM_MSGWAIT);
HYDU_ERR_POP(status, "error sending publish info\n");
HYDU_ASSERT(!closed, status);
}
......
......@@ -42,7 +42,8 @@ static void signal_cb(int signum)
#endif /* HAVE_ALARM */
cmd.type = HYD_CKPOINT;
HYDU_sock_write(HYD_server_info.cmd_pipe[1], &cmd, sizeof(cmd), &sent, &closed);
HYDU_sock_write(HYD_server_info.cmd_pipe[1], &cmd, sizeof(cmd), &sent, &closed,
HYDU_SOCK_COMM_MSGWAIT);
goto fn_exit;
}
......@@ -61,7 +62,8 @@ static void signal_cb(int signum)
HYDU_dump(stdout, "Press Ctrl-C again to force abort\n");
}
HYDU_sock_write(HYD_server_info.cmd_pipe[1], &cmd, sizeof(cmd), &sent, &closed);
HYDU_sock_write(HYD_server_info.cmd_pipe[1], &cmd, sizeof(cmd), &sent, &closed,
HYDU_SOCK_COMM_MSGWAIT);
fn_exit:
HYDU_FUNC_EXIT();
......
......@@ -304,7 +304,7 @@ static HYD_status stdoe_cb(int _fd, int pgid, int proxy_id, int rank, void *_buf
}
if (HYD_ui_info.prepend_pattern == NULL) {
status = HYDU_sock_write(fd, buf, buflen, &sent, &closed);
status = HYDU_sock_write(fd, buf, buflen, &sent, &closed, HYDU_SOCK_COMM_MSGWAIT);
HYDU_ERR_POP(status, "unable to write data to stdout/stderr\n");
HYDU_ASSERT(!closed, status);
}
......@@ -318,10 +318,11 @@ static HYD_status stdoe_cb(int _fd, int pgid, int proxy_id, int rank, void *_buf
if (buf[i] == '\n' || i == buflen - 1) {
if (prepend[0] != '\0') { /* sock_write barfs on maxlen==0 */
status = HYDU_sock_write(fd, (const void *) prepend,
strlen(prepend), &sent, &closed);
strlen(prepend), &sent, &closed,
HYDU_SOCK_COMM_MSGWAIT);
}
status = HYDU_sock_write(fd, (const void *) &buf[mark], i - mark + 1,
&sent, &closed);
&sent, &closed, HYDU_SOCK_COMM_MSGWAIT);
HYDU_ERR_POP(status, "unable to write data to stdout/stderr\n");
HYDU_ASSERT(!closed, status);
mark = i + 1;
......
......@@ -402,7 +402,8 @@ HYD_status HYDU_send_strlist(int fd, char **strlist)
/* Check how many arguments we have */
list_len = HYDU_strlist_lastidx(strlist);
status = HYDU_sock_write(fd, &list_len, sizeof(int), &sent, &closed);
status =
HYDU_sock_write(fd, &list_len, sizeof(int), &sent, &closed, HYDU_SOCK_COMM_MSGWAIT);
HYDU_ERR_POP(status, "unable to write data to proxy\n");
HYDU_ASSERT(!closed, status);
......@@ -410,11 +411,12 @@ HYD_status HYDU_send_strlist(int fd, char **strlist)
for (i = 0; strlist[i]; i++) {
len = strlen(strlist[i]) + 1;
status = HYDU_sock_write(fd, &len, sizeof(int), &sent, &closed);
status =
HYDU_sock_write(fd, &len, sizeof(int), &sent, &closed, HYDU_SOCK_COMM_MSGWAIT);
HYDU_ERR_POP(status, "unable to write data to proxy\n");
HYDU_ASSERT(!closed, status);
status = HYDU_sock_write(fd, strlist[i], len, &sent, &closed);
status = HYDU_sock_write(fd, strlist[i], len, &sent, &closed, HYDU_SOCK_COMM_MSGWAIT);
HYDU_ERR_POP(status, "unable to write data to proxy\n");
HYDU_ASSERT(!closed, status);
}
......
......@@ -250,9 +250,9 @@ HYD_status HYDU_sock_read(int fd, void *buf, int maxlen, int *recvd, int *closed
*recvd += tmp;
}
if (flag != HYDU_SOCK_COMM_MSGWAIT || *recvd == maxlen)
if (flag == HYDU_SOCK_COMM_NONE || *recvd == maxlen)
break;
};
}
fn_exit:
HYDU_FUNC_EXIT();
......@@ -262,7 +262,8 @@ HYD_status HYDU_sock_read(int fd, void *buf, int maxlen, int *recvd, int *closed
goto fn_exit;
}
HYD_status HYDU_sock_write(int fd, const void *buf, int maxlen, int *sent, int *closed)
HYD_status HYDU_sock_write(int fd, const void *buf, int maxlen, int *sent, int *closed,
enum HYDU_sock_comm_flag flag)
{
int tmp;
HYD_status status = HYD_SUCCESS;
......@@ -274,19 +275,28 @@ HYD_status HYDU_sock_write(int fd, const void *buf, int maxlen, int *sent, int *
*sent = 0;
*closed = 0;
while (1) {
do {
tmp = write(fd, (char *) buf + *sent, maxlen - *sent);
} while (tmp < 0 && (errno == EINTR || errno == EAGAIN));
if (tmp < 0 || tmp == 0) {
*closed = 1;
goto fn_exit;
tmp = write(fd, (char *) buf + *sent, maxlen - *sent);
if (tmp <= 0) {
if (errno == EAGAIN) {
if (flag == HYDU_SOCK_COMM_NONE)
goto fn_exit;
else
continue;
}
else if (errno == ECONNRESET) {
*closed = 1;
goto fn_exit;
}
HYDU_ERR_SETANDJUMP(status, HYD_SOCK_ERROR, "write error (%s)\n",
HYDU_strerror(errno));
}
else {
*sent += tmp;
}
*sent += tmp;
if (*sent == maxlen)
if (flag == HYDU_SOCK_COMM_NONE || *sent == maxlen)
break;
};
}
fn_exit:
HYDU_FUNC_EXIT();
......@@ -403,7 +413,7 @@ HYD_status HYDU_sock_forward_stdio(int in, int out, int *closed)
/* there is data in the buffer, send it out first */
status =
HYDU_sock_write(out, fwd_hash->buf + fwd_hash->buf_offset, fwd_hash->buf_count,
&count, closed);
&count, closed, HYDU_SOCK_COMM_MSGWAIT);
HYDU_ERR_POP(status, "write error\n");
if (!*closed) {
......@@ -417,7 +427,7 @@ HYD_status HYDU_sock_forward_stdio(int in, int out, int *closed)
while (*closed && fwd_hash->buf_count) {
status =
HYDU_sock_write(out, fwd_hash->buf + fwd_hash->buf_offset, fwd_hash->buf_count,
&count, closed);
&count, closed, HYDU_SOCK_COMM_MSGWAIT);
HYDU_ERR_POP(status, "write error\n");
if (!*closed) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment