aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/drivers/common
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2011-11-17 15:44:37 +0100
committerSverker Eriksson <[email protected]>2011-11-17 15:44:37 +0100
commit40790b549f870b61828e7590977faf827abd3a01 (patch)
tree9071f22850af53cb053793cd2f3c1b8d73a8d586 /erts/emulator/drivers/common
parentab75301714c3183172e3d315437ed2d62d735c4e (diff)
parentf63b0006ea9ef64ea7da7eb023ccaf55cc03597a (diff)
downloadotp-40790b549f870b61828e7590977faf827abd3a01.tar.gz
otp-40790b549f870b61828e7590977faf827abd3a01.tar.bz2
otp-40790b549f870b61828e7590977faf827abd3a01.zip
Merge branch 'sverker/valgrind-fixing'
* sverker/valgrind-fixing: erts: valgrind suppressions for prebuilt terms in os_info_init Fix dlopen-leak of drivers with incorrect version erts: Add valgrind suppression files erts: Remove valgrind limit for erts_alloc_permanent_cache_aligned erts: Fix write-after-free bug in inet driver ETS: Fix faulty size calculation SIZEOF_EXTSEG ETS: Fix valgrind PossiblyLost in ETS hash tables
Diffstat (limited to 'erts/emulator/drivers/common')
-rw-r--r--erts/emulator/drivers/common/inet_drv.c27
1 files changed, 11 insertions, 16 deletions
diff --git a/erts/emulator/drivers/common/inet_drv.c b/erts/emulator/drivers/common/inet_drv.c
index 426917bd2c..c803e6b51e 100644
--- a/erts/emulator/drivers/common/inet_drv.c
+++ b/erts/emulator/drivers/common/inet_drv.c
@@ -8497,32 +8497,29 @@ static int tcp_deliver(tcp_descriptor* desc, int len)
}
while (len > 0) {
- int code = 0;
+ int code;
inet_input_count(INETP(desc), len);
/* deliver binary? */
if (len*4 >= desc->i_buf->orig_size*3) { /* >=75% */
+ code = tcp_reply_binary_data(desc, desc->i_buf,
+ (desc->i_ptr_start -
+ desc->i_buf->orig_bytes),
+ len);
+ if (code < 0)
+ return code;
+
/* something after? */
if (desc->i_ptr_start + len == desc->i_ptr) { /* no */
- code = tcp_reply_binary_data(desc, desc->i_buf,
- (desc->i_ptr_start -
- desc->i_buf->orig_bytes),
- len);
tcp_clear_input(desc);
}
else { /* move trail to beginning of a new buffer */
- ErlDrvBinary* bin;
+ ErlDrvBinary* bin = alloc_buffer(desc->i_bufsz);
char* ptr_end = desc->i_ptr_start + len;
int sz = desc->i_ptr - ptr_end;
- bin = alloc_buffer(desc->i_bufsz);
memcpy(bin->orig_bytes, ptr_end, sz);
-
- code = tcp_reply_binary_data(desc, desc->i_buf,
- (desc->i_ptr_start-
- desc->i_buf->orig_bytes),
- len);
free_buffer(desc->i_buf);
desc->i_buf = bin;
desc->i_ptr_start = desc->i_buf->orig_bytes;
@@ -8534,17 +8531,15 @@ static int tcp_deliver(tcp_descriptor* desc, int len)
code = tcp_reply_data(desc, desc->i_ptr_start, len);
/* XXX The buffer gets thrown away on error (code < 0) */
/* Windows needs workaround for this in tcp_inet_event... */
+ if (code < 0)
+ return code;
desc->i_ptr_start += len;
if (desc->i_ptr_start == desc->i_ptr)
tcp_clear_input(desc);
else
desc->i_remain = 0;
-
}
- if (code < 0)
- return code;
-
count++;
len = 0;