aboutsummaryrefslogtreecommitdiffstats
path: root/modules/es_ftw
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-06-26 16:18:41 +0000
committerlloyd <[email protected]>2008-06-26 16:18:41 +0000
commit1b4a1cd7b3e74bd3d3c34c6c89721536a6fe3a27 (patch)
tree87fd44ba4b853eb68824055bbd91b29fca646c5d /modules/es_ftw
parent1e2a389d850edc93be424c92211d288e3bed7be7 (diff)
The change in rev f6d0cb6f9569d228ed6a11d021c3f57f55220bde was actually
completely wrong, and it is rather disturbing I made that mistake. The poll() function will gather up to the number of bytes passed as its argument; it will do this by opening up files and reading up to 1024 bytes from each one. So we might open between 256 and 256*1024 files, depending on the sizes of them (ignoring empty files, which count for zero bytes). (Idea: also include the name of the file in the output? Is that useful?) Move the read_buf out of the loop to minimize allocator thrashing.
Diffstat (limited to 'modules/es_ftw')
-rw-r--r--modules/es_ftw/es_ftw.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/modules/es_ftw/es_ftw.cpp b/modules/es_ftw/es_ftw.cpp
index 45271b040..ec11378f8 100644
--- a/modules/es_ftw/es_ftw.cpp
+++ b/modules/es_ftw/es_ftw.cpp
@@ -105,7 +105,7 @@ FTW_EntropySource::FTW_EntropySource(const std::string& p) : path(p)
*************************************************/
void FTW_EntropySource::do_fast_poll()
{
- poll(32);
+ poll(32*1024);
}
/*************************************************
@@ -113,7 +113,7 @@ void FTW_EntropySource::do_fast_poll()
*************************************************/
void FTW_EntropySource::do_slow_poll()
{
- poll(256);
+ poll(256*1024);
}
/*************************************************
@@ -122,8 +122,9 @@ void FTW_EntropySource::do_slow_poll()
void FTW_EntropySource::poll(u32bit max_read)
{
Directory_Walker dir(path);
- u32bit read_so_far = 0;
+ SecureVector<byte> read_buf(1024);
+ u32bit read_so_far = 0;
while(read_so_far < max_read)
{
int fd = dir.next_fd();
@@ -131,7 +132,6 @@ void FTW_EntropySource::poll(u32bit max_read)
if(fd == -1)
break;
- SecureVector<byte> read_buf(1024);
ssize_t got = ::read(fd, read_buf.begin(), read_buf.size());
if(got > 0)