Mercurial > hg > release > heapstats-1.1
changeset 22:8448fe8f7fae
Bug 1735: REGRESSION: Cannot collect files from procfs
reviewed-by: ykubota
author | Yasumasa Suenaga <yasuenag@gmail.com> |
---|---|
date | Mon, 14 Apr 2014 22:23:10 +0900 |
parents | c721cb53d2e0 |
children | 51762fe6dc8e |
files | agent/ChangeLog agent/src/fsUtil.cpp |
diffstat | 2 files changed, 28 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/agent/ChangeLog Mon Mar 31 11:40:13 2014 +0900 +++ b/agent/ChangeLog Mon Apr 14 22:23:10 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.1.1
--- a/agent/src/fsUtil.cpp Mon Mar 31 11:40:13 2014 +0900 +++ b/agent/src/fsUtil.cpp Mon Apr 14 22:23:10 2014 +0900 @@ -111,9 +111,30 @@ } /* Copy data */ - if(unlikely(sendfile64(destFd, sourceFd, NULL, st.st_size) == -1)){ - result = errno; - PRINT_WARN_MSG("Couldn't write copy file data."); + if(st.st_size > 0){ + if(unlikely(sendfile64(destFd, sourceFd, NULL, st.st_size) == -1)){ + result = errno; + 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){ + result = errno; + PRINT_WARN_MSG("Couldn't copy file."); + } + } /* Clean up */