mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-05 17:52:29 +00:00
Fix file descriptor leak in session file saving
When system.files.session.fdatasync is set to "no", file descriptors were not being closed after writing session files, causing a severe resource leak. Each save operation would leak one file descriptor. With hundreds of torrents, this leads to tens of thousands of leaked file descriptors within hours, mostly pointing to deleted session files. This can exhaust the system's file descriptor limit and cause rtorrent to fail when opening new files. The fix moves the close() call outside the fdatasync conditional block, ensuring file descriptors are always properly closed regardless of the fdatasync setting.
This commit is contained in:
@@ -100,9 +100,10 @@ DownloadStore::write_bencode(const std::string& filename, const torrent::Object&
|
||||
#else
|
||||
fdatasync(fd);
|
||||
#endif
|
||||
::close(fd);
|
||||
}
|
||||
|
||||
::close(fd);
|
||||
|
||||
return true;
|
||||
|
||||
download_store_save_error:
|
||||
|
||||
Reference in New Issue
Block a user