Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

file upload stats (lib) #107

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

RetroPooh
Copy link
Contributor

No description provided.


uint64_t ftServer::getCumulativeUpload(RsFileHash hash)
{
std::map<RsFileHash,uint64_t>::iterator it = cumulative_uploaded.find(hash) ;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like a mutex is missing here.


uint64_t ftServer::getCumulativeUploadAll()
{
uint64_t all = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@csoler
Copy link
Contributor

csoler commented Jul 8, 2023

Make sure to always use a mutex protection when reading/writing to a std::map. Otherwise it's bound to crash when you access from different threads.

Another problem is that you're not saving the upload stats. So they are lost accross restarts, which somewhat kills the entire idea since upload stats are supposed to be long-term stats. But ftServer does not have a saving system.

All accounted for, it seems that it would make much more sense to store them with p3FileDatabase in ft_database.cfg.
That means:

  • add to p3FileDatabase class the functions to update the upload stats, as called from ftServer (no mutex needed in ftServer for that since the one is p3FileDatabase will be used)
  • create a new RsItem in rsfilelistitems.h to store the upload stats.
  • add the proper lines to load/save these stats in p3FileDatabase::loadList() and saveList() using these created items

@defnax
Copy link
Contributor

defnax commented Feb 7, 2024

when we get this stats in retroshare? we need this

@defnax
Copy link
Contributor

defnax commented Feb 7, 2024

@csoler i have added before the mutex this is right or

image

@csoler
Copy link
Contributor

csoler commented Feb 8, 2024

yes this is fine.

@csoler
Copy link
Contributor

csoler commented Feb 8, 2024

I like the idea of keeping these stats. Last time I looked at it, it still needed saving that data. Of course we need to only save the stats for files that actually have been uploaded (in order to limit the file size) and using a std::map for that is indeed a good idea.

@defnax
Copy link
Contributor

defnax commented Feb 8, 2024

Hi, you will reimplement this? else i can make a new pr with the mutex tonight

@defnax
Copy link
Contributor

defnax commented Feb 11, 2024

new pr for this : #142

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants