Triton Repository branch, master, updated. fd2b27e8dc761e70a4475ae551f8235361f8dd8e
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Triton Repository". The branch, master has been updated via fd2b27e8dc761e70a4475ae551f8235361f8dd8e (commit) from 70e11d29c1cb03163ddd363e560050243d868c45 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit fd2b27e8dc761e70a4475ae551f8235361f8dd8e Author: Dries Kimpe <[email protected]> Date: Fri Jun 3 10:42:12 2011 -0500 socket: properly handle errors - triton_read/write/accept now return proper triton_ret_t errors - modified echo-server to keep reading (and echoing) until client hangs up. ----------------------------------------------------------------------- Summary of changes: code/src/socket/test/echo-server.ae | 21 ++++++++++++++++----- code/src/socket/triton-socket.ae | 6 +++--- 2 files changed, 19 insertions(+), 8 deletions(-) Diff of changes: diff --git a/code/src/socket/test/echo-server.ae b/code/src/socket/test/echo-server.ae index 15c12c4..24af76d 100644 --- a/code/src/socket/test/echo-server.ae +++ b/code/src/socket/test/echo-server.ae @@ -42,16 +42,27 @@ static __blocking void handleConnection (int fd) // maybe have the client first write the number of bytes it will // send? ret = triton_read (fd, &buf[0], sizeof(buf), &len); - assert (ret == TRITON_SUCCESS); - printf ("Got data on fd %i: %i\n", fd, len); + if (ret != TRITON_SUCCESS) + { + triton_error_print (ret, "error on read:"); + break; + } + + if (!len) + break; - //triton_timer (9000); + printf ("Got data on fd %i: %i\n", fd, len); ret = triton_write (fd, &buf[0], len, &written); - assert (ret == TRITON_SUCCESS); + if (ret != TRITON_SUCCESS) + { + triton_error_print (ret, "error on write:"); + break; + } printf ("Wrote data to fd %i: %i\n", fd, written); - } while (0); + } while (1); + printf ("Client %i disconnect...\n", fd); close (fd); } } diff --git a/code/src/socket/triton-socket.ae b/code/src/socket/triton-socket.ae index 2a6ccc7..21789ac 100644 --- a/code/src/socket/triton-socket.ae +++ b/code/src/socket/triton-socket.ae @@ -26,7 +26,7 @@ __blocking triton_ret_t triton_accept (int sockfd, struct sockaddr * addr, if (errno == EAGAIN || errno == EWOULDBLOCK) continue; - perror ("error in accept"); + return triton_error_from_errno (errno); } while (1); @@ -56,7 +56,7 @@ __blocking triton_ret_t triton_read (int fd, void * buf, size_t count, int * len if (errno == EAGAIN || errno == EWOULDBLOCK) continue; - assert (0); + return triton_error_from_errno (errno); } while (1); @@ -83,7 +83,7 @@ __blocking triton_ret_t triton_write (int fd, const void * buf, size_t count, in if (errno == EAGAIN || errno == EWOULDBLOCK) continue; - assert (0); + return triton_error_from_errno (errno); } while (1); hooks/post-receive -- Triton Repository
participants (1)
-
noreply@mcs.anl.gov