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:
Phil Rosenthal
2025-06-16 16:10:55 -04:00
committed by rakshasa
parent f2b83d50e8
commit 8bd7c79755
+2 -1
View File
@@ -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: