aboutsummaryrefslogtreecommitdiffstats
path: root/erts
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2013-11-12 18:27:53 +0100
committerLukas Larsson <[email protected]>2014-02-24 15:16:01 +0100
commit7d924d6c1279178db9c81fd04dd87c8d902a6549 (patch)
tree6bf41b61af0f9361b2030685dbdb341695e9ca4d /erts
parenta0766a4efeefe0ac035d2be04816274aee5751f3 (diff)
downloadotp-7d924d6c1279178db9c81fd04dd87c8d902a6549.tar.gz
otp-7d924d6c1279178db9c81fd04dd87c8d902a6549.tar.bz2
otp-7d924d6c1279178db9c81fd04dd87c8d902a6549.zip
ose: Fix printout to stdout to not duplicate long buffers
Diffstat (limited to 'erts')
-rw-r--r--erts/emulator/sys/ose/sys.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/erts/emulator/sys/ose/sys.c b/erts/emulator/sys/ose/sys.c
index 6e55301d6e..ba8851e203 100644
--- a/erts/emulator/sys/ose/sys.c
+++ b/erts/emulator/sys/ose/sys.c
@@ -892,7 +892,7 @@ OS_PROCESS(fd_writer_process) {
SysIOVec *iov;
int iovlen;
int iovcnt;
- int n = 0, i;
+ int n = 0, i = 0, offset = 0;
size_t p;
/* fprintf(stderr,"0x%x: fd_writer, receive\n", current_process()); */
sig = receive(sigsel);
@@ -913,12 +913,22 @@ OS_PROCESS(fd_writer_process) {
driver_pdl_unlock(driver_data[fd].pdl);
if (iovlen > 0) {
- for (i = 0; i < iovcnt; i++) {
- res = write(fd, iov[i].iov_base,
- iov[i].iov_len > 256 ? 256 : iov[i].iov_len);
+ while(i < iovcnt) {
+ /* We only write 256 chars at the time in order to
+ not overflow the stdout process */
+ if ((iov[i].iov_len-offset) > 256) {
+ res = write(fd, iov[i].iov_base+offset, 256);
if (res < 0)
break;
- n += res;
+ offset += res;
+ } else {
+ res = write(fd, iov[i].iov_base+offset, iov[i].iov_len-offset);
+ if (res < 0)
+ break;
+ offset = 0;
+ i++;
+ }
+ n += res;
}
if (res > 0)
res = n;