compliance with win32

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1020 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2009-02-08 13:04:32 +00:00
parent 881f1395c8
commit 6efc71efd5
2 changed files with 12 additions and 8 deletions

View File

@ -1,4 +1,3 @@
#include <sys/times.h>
#include "ftfileprovider.h"
#include "util/rsdir.h"
@ -7,13 +6,17 @@
ftFileProvider::ftFileProvider(std::string path, uint64_t size, std::string
hash) : mSize(size), hash(hash), file_name(path), fd(NULL),transfer_rate(0),total_size(0)
{
#ifdef DEBUG_FT_FILE_PROVIDER
std::cout << "Creating file provider for " << hash << std::endl ;
#endif
lastTS = time(NULL) ;
lastTS_t = times(NULL) ;
lastTS_t = lastTS ;
}
ftFileProvider::~ftFileProvider(){
#ifdef DEBUG_FT_FILE_PROVIDER
std::cout << "Destroying file provider for " << hash << std::endl ;
#endif
if (fd!=NULL) {
fclose(fd);
}
@ -125,16 +128,17 @@ bool ftFileProvider::getFileData(uint64_t offset, uint32_t &chunk_size, void *da
* (d) timestamp
*/
long int clk = sysconf(_SC_CLK_TCK) ;
clock_t now_t = times(NULL) ;
time_t now_t = time(NULL) ;
long int diff = (long int)now_t - (long int)lastTS_t ; // in bytes/s. Average over multiple samples
#ifdef DEBUG_FT_FILE_PROVIDER
std::cout << "diff = " << diff << std::endl ;
#endif
if(diff > 200)
if(diff > 3)
{
transfer_rate = total_size / (float)diff * clk ;
transfer_rate = total_size / (float)diff ;
#ifdef DEBUG_FT_FILE_PROVIDER
std::cout << "updated TR = " << transfer_rate << ", total_size=" << total_size << std::endl ;
#endif

View File

@ -65,8 +65,8 @@ virtual int initializeFileAttrs(); /* does for both */
std::string lastRequestor;
uint64_t req_loc;
uint32_t req_size;
time_t lastTS;
clock_t lastTS_t;
time_t lastTS; // used for checking if it's alive
time_t lastTS_t; // used for estimating transfer rate.
// these two are used for speed estimation
float transfer_rate ;