Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#3967 closed Bug (fixed)

regression: watch.c's readdir() implementation broke between 2.13 and 2.20b1

Reported by: bulljit Owned by:
Priority: Normal Milestone:
Component: Daemon Version: 2.13+
Severity: Normal Keywords:
Cc: bulljit@…


v2.20 fails to recognize/add NEW torrents from watch-dir. This function works correctly under v2.13.

"transmission-daemon -f" reports that it is set up correctly... :(

[11:38:55.315] Watching "/Users/me/Downloads/Watch2" for new .torrent files (/Users/me/Downloads/_td/untitled/TransmissionSVN/daemon/daemon.c:530)
[11:38:55.315] Using readdir to watch directory "/Users/me/Downloads/Watch2" (/Users/me/Downloads/_td/untitled/TransmissionSVN/daemon/watch.c:161)

Change History (12)

comment:1 Changed 11 years ago by bulljit

  • Priority changed from Normal to Lowest
  • Resolution set to invalid
  • Severity changed from Normal to Trivial
  • Status changed from new to closed

comment:2 Changed 11 years ago by bulljit

  • Cc bulljit@… added
  • Resolution invalid deleted
  • Status changed from closed to reopened

comment:3 Changed 11 years ago by bulljit

Again complete complete noob here, but I can confirm that:

  1. The watch-dir setting is correct and readdir is functioning.
  2. It appears that in the "non-inotify chunks of code" is_file_in_list is returning the wrong boolean.
  3. The simple hack is to just flip the expression on line 226:

from: if( !is_file_in_list( w->lastFiles, name, len ) )

to: if( is_file_in_list( w->lastFiles, name, len ) )

  1. Now its working as advertised :)
  2. Of course this is sloppy, but I'm just having a hard time figuring out the function is_file_in_list. Any smarter individuals out there than can help?

comment:4 Changed 11 years ago by zebulon501

Will this regression be fixed for the upcoming 2.20?

comment:5 Changed 11 years ago by jordan

  • Milestone changed from None Set to 2.20
  • Priority changed from Lowest to Normal
  • Severity changed from Trivial to Normal
  • Version changed from 2.13+ to 2.13

comment:6 Changed 11 years ago by jordan

That is_file_in_list() function is kind of a hack to begin with. I don't think that one-liner so much fixes it as avoids it... I'll rewrite the list.

What it's /trying/ to do is make sure we don't keep trying to add the same torrent again and again. If a torrent gets successfully added then an ".added" suffix is appended the filename, but we might keep trying to add a corrupt/invalid .torrent file again and again.

Last edited 11 years ago by jordan (previous) (diff)

comment:7 Changed 11 years ago by jordan

  • Version changed from 2.13 to 2.13+

comment:8 Changed 11 years ago by jordan

  • Milestone 2.20 deleted

After looking it over, maybe the code isn't that bad after all. A different one-liner seems to fix things without throwing out the don't-keep-readding-the-same-torrent feature :)

comment:9 Changed 11 years ago by jordan

  • Resolution set to fixed
  • Status changed from reopened to closed

jordan * r11823 daemon/watch.c:

(trunk libT) #3967 "regression: transmission-daemon's non-inotify watchdir is broken in 2.20 betas" -- fixed.

When inotify isn't available, watch.c uses readdir() to look for new .torrent files. It keeps a list of old .torrent files internally so that it doesn't try to keep re-adding the same file. This list is stored in an evbuffer. As part of the libevent2 upgrade (#3836), r11594 changed how the buffer is searched by replacing the (deprecated) event_find() call with libevent2's evbuffer_search(). However the latter's semantics are different in that searching stops when '\0' is reached, so '\0' is no longer a good filename delimiter. Fixed by changing watch.c's internal delimiter from '\0' to '\t' ... so all those torrents with tabs in their filenames had better watch out.

comment:10 Changed 11 years ago by jordan

  • Summary changed from Transmission-Daemon 2.20 does not add new torrents from watch-dir to regression: watch.c's readdir() implementation broke between 2.13 and 2.20b1

comment:11 Changed 11 years ago by jordan

bulljit: thanks very much for getting me looking in the right direction. you definitely helped this ticket get fixed :)

comment:12 Changed 11 years ago by bulljit

jordan: ummm, you rock!

Note: See TracTickets for help on using tickets.