Did a nice 12-hour devsession, and made nice progress in several areas. Unfortunately I didn't get to global searching yet - guess that'll be next dev-session's topic. Anyway, here's the list of changes tonight:
- No longer creates ed2k userhash twice on first startup
- Compilation with Mingw compiler should be fixed (there's some mess with if/how stat64 is defined)
- SSocket class is now Trackable, clearing up few speed-signal-related crashes (a member function of SSocket is often connected to other speed-displaying signals)
- Fixed three (!) debug messages in PartData class that had invalid number of arguments and caused unhandled exception - but only when deleting temp files failed.
- No longer scans same shared folder twice (e.g. if folder is already shared, it won't be re-scanned at a later time). This has nothing to do with 'rescan' concept, which will be a separate function altogether.
- Supports more than 64 open connections on Windows (up to 512 now)
- Only outgoing connections will count towards connections-per-sec value; this should reduce the false low-id issues with ed2k module.
- Chunk class is also now Trackable, to avoid crashes when PartData is canceled while chunk hash job is in progress.
- Simpler and more robust SharedFile::read() syncronization mechanism that hopefully clears up the torrent-completition-crashes once and for all.
- CGComm protocol is now capable of re-creating PartData and SharedFile object hierarchies at the other side of the protocol (e.g. torrents with >1 files).
- GUI displays torrents in a treeview - click on a + sign to see the sub-files of the torrent. As before, each sub-file of the torrent can be paused, stopped, resumed and canceled separately, providing maximum flexibility.
- Dynamic module-based upload-speed scaling, based on how "useful" the module has been to us; a module which accounts for 80% of all downloaded data will receive 80% of upload slots.. This is Mode One of the three planned upload-scheduling modes - automatic and user-defined (percentages) and user-defined (priorities). The latter ones will be implemented some time in the future. Note that these limits are "soft", merely hints to the module / upload-slot opening code. Hard limits do not make sense in this scenario.
- Contrary to popular belief, 16 bits is not enough for everyone. CGComm protocol packets are now sent using 32bit size field. If you were tinkering with the protocol, you need to update your code - there's no backwards compatibility kept at this phase of the protocol development. Anyway, the reason for this change was that DownloadList packet of 600 downloads (cpl big torrents) exceeded the 65kb limit of 16bit size parameter, and breaking the list into multiple packets just causes more problems.
- Torrent name is now included in tracker error messages as well.
Some 4-5 hours of the 12-hour session went to tracking the open connection issue on Windows. If you had used Hydranode on windows, you might have noticed hnshell freezing sometimes and other strange networking issues. After lengthy testing and research, I discovered that the moment connection count exceeded ~50 connections, UDP packets started failing in ed2k module. Further testing showed that networking everywhere in the app started behaving strangely when more than 50 connections were open. After more testing and surfing around, I finally discovered that by default, select() on Windows is limited to 64 sockets! This is one of the times where I really wish someone with Windows networking programming would hang around and tell me these things, heh. Anyway, the workaround is simple - define FD_SETSIZE to a value of your choosing (512 is max as far as I understand) before including sys/select.h and there you go.
So basically, what was happening until now with Hydranode on windows was that we only checked first 50 sockets always; since the ordering of the sockets is somewhat random, this caused HALF of the sockets to fail HALF of the time - enough to wonder why things are strange, but not enough to warrant deeper research. As the connection-count increased, the failure percentage increased as well, but those are rare cases when more than 100 sockets are open (well, until you start few torrents, anyway), so... UDP sockets displayed this issue more obviously, since UDP sockets are added to the select() socket descriptors listing after all other sockets have already been added, so the moment 64 TCP connections were reached, everything about UDP died.
Madcat, ZzZz
PS: New binaries are available for Windows and Linux; source code now available in three formats by default (zip, gz and bz2).