BitSwarm icon indicating copy to clipboard operation
BitSwarm copied to clipboard

Multiple Process Instances - Threading Bug?

Open Wiilf opened this issue 2 years ago • 7 comments

The client seems to make 3 application instances in memory when starting only 1 single torrent.

This can be confirmed by adding NotifyIcon1 to frmMain and watching for 3 spawn processes after starting a torrent. This is also a issue reflecting peer databases. On my end, a single query to the tracker for peers will add 3 rows into the database (for the same torrent, same instance. Really confuses the announce routines and gives up until next peer table clean interval).

This is a huge no no on nearly any tracker out there, especially older PHP4 trackers due to abuse/peer flooding/DDOS and the early days of the PHP team catching up.

If this is intended behavior, then the requests out to the tracker must be resolved. Only 1 single unique info_hash should be sent out and acknowledged.

There are 3 rows with exact same data (and tells me its seeding, also no good). It seems to be retrying 3 times every time spawning a new instance? That is fine on the hardware-side of a consumer PC but for the database, this is a killer.

Please confirm.

Wiilf avatar Oct 14 '21 23:10 Wiilf

Hey @Wiilf, help me out to understand here. BitSwarm library does not create any application instances so I cannot understand what do you mean. I have not tested much with multiple torrents so there might be few issues there (with statics) but I will need some more info. I might try to do some test by myself later on as well.

SuRGeoNix avatar Oct 15 '21 06:10 SuRGeoNix

Just primary process, and 3 threads as soon as I click on a single or more, its same effect. I have no other threading code except a image downloader class, thought it was odd. I considered maybe threading issue, and I always dispose my connections so I really dont know.

Wiilf avatar Oct 15 '21 08:10 Wiilf

If you want me to email over the EXE (scan, do all that) and maybe my copy of the client is the problem, let me know. Task manager will group child spawns and that is very normal, but seeing the tray system icon 3 times in a row, I investigated further and it matches the duplicate rows it causes when trying to connect to my tracker.

Wiilf avatar Oct 15 '21 08:10 Wiilf

@Wiilf if you see 3 icons is UI problem not library's problem

SuRGeoNix avatar Oct 15 '21 08:10 SuRGeoNix

I didnt think so, or I would have the application running multiple times in my task bar (which I dont, just threads).

I've added connection indicators on any TCP traffic throughout the application. Now I see constant activity, which is exactly what I expected. I'll keep an eye on task manager and you can go ahead and close this - not enough testing.

Green light has plenty of traffic (received), not so much for the red light (sent). Similar control used in BearShare.

Wiilf avatar Oct 15 '21 08:10 Wiilf

When trackers are running will create max 5 threads to run them. So might you see those threads at your task manager but that's not an issue. I mean, they could run in .net's threadpool but that is not wise as they are long runs (could take 30 sec to timeout). Could be improved but not an issue in any case.

Update: OK, on multiple torernts it will be an issue as a lot of threads will be created and the system might not be able to handle them. I will review this.

SuRGeoNix avatar Oct 15 '21 09:10 SuRGeoNix

Thank you, im not sure if that is effecting my ability to download but once I get the visualizer graph and figure out how to implement it I'll know a lot more within the program without tools, wireshark etc

Wiilf avatar Oct 15 '21 10:10 Wiilf