Mercurial > hg > release > heapstats-1.0
changeset 38:2d49f99d0a36
Bug 1735: REGRESSION: Cannot collect files from procfs
reviewed-by: ykubota
author | Yasumasa Suenaga <yasuenag@gmail.com> |
---|---|
date | Mon, 14 Apr 2014 22:23:05 +0900 |
parents | b79822e37689 |
children | c1b7b75d1930 |
files | agent/ChangeLog agent/src/fsUtil.cpp |
diffstat | 2 files changed, 26 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/agent/ChangeLog Mon Mar 31 11:35:50 2014 +0900 +++ b/agent/ChangeLog Mon Apr 14 22:23:05 2014 +0900 @@ -1,3 +1,7 @@ +2014-04-19 Yasumasa Suenaga <yasuenag@gmail.com> + + * Bug 1735: REGRESSION: Cannot collect files from procfs + 2014-03-31 KUBOTA Yuji <kubota.yuji@lab.ntt.co.jp> * Bump to 1.0.2
--- a/agent/src/fsUtil.cpp Mon Mar 31 11:35:50 2014 +0900 +++ b/agent/src/fsUtil.cpp Mon Apr 14 22:23:05 2014 +0900 @@ -99,8 +99,28 @@ } /* Copy data */ - if(unlikely(sendfile64(destFd, sourceFd, NULL, st.st_size) == -1)){ - PRINT_WARN_MSG("Couldn't write copy file data."); + if(st.st_size > 0){ + if(unlikely(sendfile64(destFd, sourceFd, NULL, st.st_size) == -1)){ + PRINT_WARN_MSG("Couldn't copy file."); + } + } + else{ /* This route is for files in procfs */ + char buf[1024]; + ssize_t read_size; + + while((read_size = read(sourceFd, buf, 1024)) > 0){ + + if(write(destFd, buf, (size_t)read_size) == -1){ + read_size = -1; + break; + } + + } + + if(read_size == -1){ + PRINT_WARN_MSG("Couldn't copy file."); + } + } /* Cleanup. */