mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-23 22:49:37 -05:00
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:
parent
881f1395c8
commit
6efc71efd5
@ -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
|
||||
|
@ -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 ;
|
||||
|
Loading…
Reference in New Issue
Block a user