Triton Repository branch, master, updated. 2188f9685cba66c0207f11bf44e3eef527c2c6e2
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 2188f9685cba66c0207f11bf44e3eef527c2c6e2 (commit) from be9d2c8ff52c10f3555777dfbe088b8d0499ecde (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 2188f9685cba66c0207f11bf44e3eef527c2c6e2 Author: Phil Carns <[email protected]> Date: Sun Aug 28 08:00:34 2011 -0400 option to control immed complete in triton_socket - zeroconf option can be toggled with "export triton_socket_immed_completion=0" - trades off some latency for fairness in thread/callback work ----------------------------------------------------------------------- Summary of changes: code/src/common/triton-init.c | 2 +- code/src/socket/triton-socket.ae | 125 ++++++++++++++++++++++++++++++++----- 2 files changed, 109 insertions(+), 18 deletions(-) Diff of changes: diff --git a/code/src/common/triton-init.c b/code/src/common/triton-init.c index 7aa0d12..78dbe19 100644 --- a/code/src/common/triton-init.c +++ b/code/src/common/triton-init.c @@ -418,7 +418,7 @@ __attribute__((constructor)) void triton_logical_register(void) NULL, "triton.vosd.file", "triton.resource.timer", - "triton.resource.aesocket"); + "triton.socket"); triton_init_register("triton.server", NULL, diff --git a/code/src/socket/triton-socket.ae b/code/src/socket/triton-socket.ae index 9de2903..961b40f 100644 --- a/code/src/socket/triton-socket.ae +++ b/code/src/socket/triton-socket.ae @@ -1,9 +1,19 @@ #include "triton-socket.hae" #include "src/common/resources/aesocket/aesocket.hae" +#include "src/zeroconf/zeroconf.h" #include <unistd.h> #include <assert.h> +static triton_ret_t immed_completion_updater( + const char* key, const char* value); +static triton_ret_t triton_socket_init( + void); +static void triton_socket_finalize( + void); + +static int immediate_completion = 1; + /* Number of zero byte reads in a row that we will observe before assuming * that the peer has closed the socket; this is a hack to weed out * spurious zero byte reads that can show up on some systems. @@ -23,27 +33,36 @@ __blocking triton_ret_t triton_accept( while(1) { + if(!immediate_completion) + { + ret = triton_aesocket_ready(sockfd, AESOCKET_READ); + if (ret != TRITON_SUCCESS) + return ret; + } + r = accept(sockfd, addr, addrlen); if (r >= 0) { *newfd = r; return(TRITON_SUCCESS); } - else if (errno == EAGAIN || errno == EWOULDBLOCK) + else if (errno != EAGAIN && errno != EWOULDBLOCK && errno != EINTR) + { + return triton_error_from_errno(errno); + } + + if(immediate_completion) { ret = triton_aesocket_ready(sockfd, AESOCKET_READ); if (ret != TRITON_SUCCESS) return ret; } - else - { - return triton_error_from_errno(errno); - } } return TRITON_SUCCESS; } + __blocking triton_ret_t triton_read( int fd, void *buf, @@ -52,7 +71,7 @@ __blocking triton_ret_t triton_read( { triton_ret_t ret; int r; - char* tmp_buf = buf; + char* tmp_buf = (char*)buf; int tmp_count = count; int zero_reads = 0; @@ -61,6 +80,13 @@ __blocking triton_ret_t triton_read( do { + if(!immediate_completion) + { + ret = triton_aesocket_ready(fd, AESOCKET_READ); + if (ret != TRITON_SUCCESS) + return ret; + } + r = read(fd, tmp_buf, tmp_count); if(r > 0) { @@ -77,16 +103,17 @@ __blocking triton_ret_t triton_read( return(TRITON_ERR_IO); } } - else if(errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) + else if(errno != EAGAIN && errno != EWOULDBLOCK && errno != EINTR) + { + return triton_error_from_errno(errno); + } + + if(immediate_completion && tmp_count > 0) { ret = triton_aesocket_ready(fd, AESOCKET_READ); if (ret != TRITON_SUCCESS) return ret; } - else - { - return triton_error_from_errno(errno); - } } while (tmp_count > 0); *len = count; @@ -102,7 +129,7 @@ __blocking triton_ret_t triton_write( { triton_ret_t ret; int r; - char* tmp_buf = buf; + const char* tmp_buf = (const char*)buf; int tmp_count = count; assert(buf && count); @@ -110,28 +137,92 @@ __blocking triton_ret_t triton_write( do { + if(!immediate_completion) + { + ret = triton_aesocket_ready(fd, AESOCKET_WRITE); + if (ret != TRITON_SUCCESS) + return ret; + } + r = write(fd, buf, count); if(r >= 0) { tmp_buf += r; tmp_count -= r; } - else if(errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) + else if(errno != EAGAIN && errno != EWOULDBLOCK && errno != EINTR) + { + return triton_error_from_errno(errno); + } + + if(immediate_completion && tmp_count > 0) { ret = triton_aesocket_ready(fd, AESOCKET_WRITE); if (ret != TRITON_SUCCESS) return ret; } - else - { - return triton_error_from_errno(errno); - } + } while (tmp_count > 0); *len = count; return TRITON_SUCCESS; } +__attribute__ ((constructor)) + void triton_socket_init_register( + void); + +__attribute__ ((constructor)) + void triton_socket_init_register( + void) +{ + triton_init_register("triton.socket", triton_socket_init, + triton_socket_finalize, NULL, "triton.resource.aesocket"); +} + + +static triton_ret_t triton_socket_init( + void) +{ + triton_ret_t tret; + + tret = triton_zeroconf_register("triton.socket.immed_completion", "1", + immed_completion_updater, "Enable immediate completion (1|0)"); + if(tret != TRITON_SUCCESS) + { + return(tret); + } + + return(TRITON_SUCCESS); +} + +static void triton_socket_finalize( + void) +{ + return; +} + + +static triton_ret_t immed_completion_updater(const char* key, const char* value) +{ + int ret; + int tmp; + + ret = sscanf(value, "%d", &tmp); + if(ret != 1) + { + return(TRITON_ERR_INVAL); + } + if(tmp != 0 && tmp != 1) + { + return(TRITON_ERR_INVAL); + } + + immediate_completion = tmp; + + return(TRITON_SUCCESS); +} + /* * Local variables: * c-indent-level: 4 hooks/post-receive -- Triton Repository
participants (1)
-
noreply@mcs.anl.gov