aboutsummaryrefslogtreecommitdiffstats
path: root/erts
diff options
context:
space:
mode:
authorPatrik Nyblom <[email protected]>2012-11-29 19:40:21 +0100
committerPatrik Nyblom <[email protected]>2012-12-20 12:16:37 +0100
commit70ac0aadbdfe78cd25e35852d555467ccfcc650e (patch)
tree375f9f2cfb61711ebbdcefca0570a116218e093c /erts
parentb9096c76013c3c6e665640142227d30c9ff96a78 (diff)
downloadotp-70ac0aadbdfe78cd25e35852d555467ccfcc650e.tar.gz
otp-70ac0aadbdfe78cd25e35852d555467ccfcc650e.tar.bz2
otp-70ac0aadbdfe78cd25e35852d555467ccfcc650e.zip
Add workaround for CentOS/RedHat writev bug to inet_drv
Diffstat (limited to 'erts')
-rw-r--r--erts/emulator/drivers/common/inet_drv.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/erts/emulator/drivers/common/inet_drv.c b/erts/emulator/drivers/common/inet_drv.c
index 236b8710fb..09577ffa8a 100644
--- a/erts/emulator/drivers/common/inet_drv.c
+++ b/erts/emulator/drivers/common/inet_drv.c
@@ -9711,7 +9711,7 @@ static int tcp_inet_output(tcp_descriptor* desc, HANDLE event)
else if (IS_CONNECTED(INETP(desc))) {
for (;;) {
int vsize;
- ssize_t n;
+ ssize_t n,res;
SysIOVec* iov;
if ((iov = driver_peekq(ix, &vsize)) == NULL) {
@@ -9722,7 +9722,8 @@ static int tcp_inet_output(tcp_descriptor* desc, HANDLE event)
vsize = vsize > MAX_VSIZE ? MAX_VSIZE : vsize;
DEBUGF(("tcp_inet_output(%ld): s=%d, About to send %d items\r\n",
(long)desc->inet.port, desc->inet.s, vsize));
- if (IS_SOCKET_ERROR(sock_sendv(desc->inet.s, iov, vsize, &n, 0))) {
+ if (IS_SOCKET_ERROR(res = sock_sendv(desc->inet.s, iov, vsize, &n, 0))) {
+ write_error:
if ((sock_errno() != ERRNO_BLOCK) && (sock_errno() != EINTR)) {
DEBUGF(("tcp_inet_output(%ld): sock_sendv(%d) errno = %d\r\n",
(long)desc->inet.port, vsize, sock_errno()));
@@ -9733,6 +9734,20 @@ static int tcp_inet_output(tcp_descriptor* desc, HANDLE event)
desc->inet.send_would_block = 1;
#endif
goto done;
+ } else if (res == 0) { /* Workaround for redhat/CentOS bug */
+ size_t howmuch = 0x7FFFFFFF; /* max signed 32bit */
+ int x;
+ for(x = 0; x < vsize && iov[x].iov_len == 0; ++x)
+ ;
+ if (x < vsize) {
+ if (howmuch > iov[x].iov_len) {
+ howmuch = iov[x].iov_len;
+ }
+ n = sock_send(desc->inet.s, iov[x].iov_base,howmuch,0);
+ if (IS_SOCKET_ERROR(n)) {
+ goto write_error;
+ }
+ }
}
if (driver_deq(ix, n) <= desc->low) {
if (IS_BUSY(INETP(desc))) {