Changeset 14651
- Timestamp:
- Jan 2, 2016, 2:28:59 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 8 added
- 2 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Transmission.xcodeproj/project.pbxproj
r14630 r14651 294 294 A2D307A40D9EC6870051FD27 /* BlocklistDownloader.m in Sources */ = {isa = PBXBuildFile; fileRef = A2D307A30D9EC6870051FD27 /* BlocklistDownloader.m */; }; 295 295 A2D307B10D9EC9F50051FD27 /* BlocklistStatusWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = A2D307B00D9EC9F50051FD27 /* BlocklistStatusWindow.xib */; }; 296 A2D5972A0F5AE49E0001AB3C /* watch.c in Sources */ = {isa = PBXBuildFile; fileRef = A2D597280F5AE49E0001AB3C /* watch.c */; };297 296 A2D77451154CC25700A62B93 /* WebSeedTableView.h in Headers */ = {isa = PBXBuildFile; fileRef = A2D7744F154CC25700A62B93 /* WebSeedTableView.h */; }; 298 297 A2D77452154CC25700A62B93 /* WebSeedTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = A2D77450154CC25700A62B93 /* WebSeedTableView.m */; }; … … 474 473 C1639A7D1A55F57200E42033 /* cencode.h in Headers */ = {isa = PBXBuildFile; fileRef = C1639A7B1A55F57200E42033 /* cencode.h */; }; 475 474 C1F690FD1AD0627500D95CF0 /* daemon-posix.c in Sources */ = {isa = PBXBuildFile; fileRef = C1F690FC1AD0627500D95CF0 /* daemon-posix.c */; }; 475 C1FEE5771C3223CC00D62832 /* watchdir-common.h in Headers */ = {isa = PBXBuildFile; fileRef = C1FEE5721C3223CC00D62832 /* watchdir-common.h */; }; 476 C1FEE5781C3223CC00D62832 /* watchdir-generic.c in Sources */ = {isa = PBXBuildFile; fileRef = C1FEE5731C3223CC00D62832 /* watchdir-generic.c */; }; 477 C1FEE5791C3223CC00D62832 /* watchdir-kqueue.c in Sources */ = {isa = PBXBuildFile; fileRef = C1FEE5741C3223CC00D62832 /* watchdir-kqueue.c */; }; 478 C1FEE57A1C3223CC00D62832 /* watchdir.c in Sources */ = {isa = PBXBuildFile; fileRef = C1FEE5751C3223CC00D62832 /* watchdir.c */; }; 479 C1FEE57B1C3223CC00D62832 /* watchdir.h in Headers */ = {isa = PBXBuildFile; fileRef = C1FEE5761C3223CC00D62832 /* watchdir.h */; }; 476 480 D4AF3B2F0C41F7A500D46B6B /* list.c in Sources */ = {isa = PBXBuildFile; fileRef = D4AF3B2D0C41F7A500D46B6B /* list.c */; }; 477 481 D4AF3B300C41F7A600D46B6B /* list.h in Headers */ = {isa = PBXBuildFile; fileRef = D4AF3B2E0C41F7A500D46B6B /* list.h */; }; … … 1035 1039 A2D307A30D9EC6870051FD27 /* BlocklistDownloader.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = BlocklistDownloader.m; path = macosx/BlocklistDownloader.m; sourceTree = "<group>"; }; 1036 1040 A2D307B00D9EC9F50051FD27 /* BlocklistStatusWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = BlocklistStatusWindow.xib; path = macosx/BlocklistStatusWindow.xib; sourceTree = "<group>"; }; 1037 A2D597280F5AE49E0001AB3C /* watch.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = watch.c; path = daemon/watch.c; sourceTree = "<group>"; };1038 A2D597290F5AE49E0001AB3C /* watch.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = watch.h; path = daemon/watch.h; sourceTree = "<group>"; };1039 1041 A2D7744F154CC25700A62B93 /* WebSeedTableView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WebSeedTableView.h; path = macosx/WebSeedTableView.h; sourceTree = "<group>"; }; 1040 1042 A2D77450154CC25700A62B93 /* WebSeedTableView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = WebSeedTableView.m; path = macosx/WebSeedTableView.m; sourceTree = "<group>"; }; … … 1231 1233 C1F690FC1AD0627500D95CF0 /* daemon-posix.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = "daemon-posix.c"; path = "daemon/daemon-posix.c"; sourceTree = "<group>"; }; 1232 1234 C1F690FE1AD0628400D95CF0 /* daemon.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = daemon.h; path = daemon/daemon.h; sourceTree = "<group>"; }; 1235 C1FEE5721C3223CC00D62832 /* watchdir-common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "watchdir-common.h"; path = "libtransmission/watchdir-common.h"; sourceTree = "<group>"; }; 1236 C1FEE5731C3223CC00D62832 /* watchdir-generic.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = "watchdir-generic.c"; path = "libtransmission/watchdir-generic.c"; sourceTree = "<group>"; }; 1237 C1FEE5741C3223CC00D62832 /* watchdir-kqueue.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = "watchdir-kqueue.c"; path = "libtransmission/watchdir-kqueue.c"; sourceTree = "<group>"; }; 1238 C1FEE5751C3223CC00D62832 /* watchdir.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = watchdir.c; path = libtransmission/watchdir.c; sourceTree = "<group>"; }; 1239 C1FEE5761C3223CC00D62832 /* watchdir.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = watchdir.h; path = libtransmission/watchdir.h; sourceTree = "<group>"; }; 1233 1240 D4AF3B2D0C41F7A500D46B6B /* list.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = list.c; path = libtransmission/list.c; sourceTree = "<group>"; }; 1234 1241 D4AF3B2E0C41F7A500D46B6B /* list.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = list.h; path = libtransmission/list.h; sourceTree = "<group>"; }; … … 1811 1818 A2A4EA0A0DE106E8000CE197 /* ConvertUTF.c */, 1812 1819 4DB74F070E8CD75100AEB1A8 /* wildmat.c */, 1820 C1FEE5751C3223CC00D62832 /* watchdir.c */, 1821 C1FEE5761C3223CC00D62832 /* watchdir.h */, 1822 C1FEE5731C3223CC00D62832 /* watchdir-generic.c */, 1823 C1FEE5741C3223CC00D62832 /* watchdir-kqueue.c */, 1824 C1FEE5721C3223CC00D62832 /* watchdir-common.h */, 1813 1825 ); 1814 1826 name = libtransmission; … … 2013 2025 C1F690FC1AD0627500D95CF0 /* daemon-posix.c */, 2014 2026 BEFC1C140C07756200B0BB3C /* remote.c */, 2015 A2D597280F5AE49E0001AB3C /* watch.c */,2016 A2D597290F5AE49E0001AB3C /* watch.h */,2017 2027 ); 2018 2028 name = daemon; … … 2123 2133 BEFC1E490C07861A00B0BB3C /* metainfo.h in Headers */, 2124 2134 BEFC1E4D0C07861A00B0BB3C /* session.h in Headers */, 2135 C1FEE5771C3223CC00D62832 /* watchdir-common.h in Headers */, 2125 2136 BEFC1E4E0C07861A00B0BB3C /* inout.h in Headers */, 2126 2137 BEFC1E520C07861A00B0BB3C /* fdlimit.h in Headers */, … … 2141 2152 A29DF8BB0DB2544C00D04E5A /* torrent.h in Headers */, 2142 2153 A29DF8BE0DB2545F00D04E5A /* verify.h in Headers */, 2154 C1FEE57B1C3223CC00D62832 /* watchdir.h in Headers */, 2143 2155 A2AAB6650DE0D08B00E04DDA /* blocklist.h in Headers */, 2144 2156 A2A4E9210DE0F7E9000CE197 /* web.h in Headers */, … … 2754 2766 BEFC1E4F0C07861A00B0BB3C /* inout.c in Sources */, 2755 2767 BEFC1E530C07861A00B0BB3C /* fdlimit.c in Sources */, 2768 C1FEE5781C3223CC00D62832 /* watchdir-generic.c in Sources */, 2756 2769 BEFC1E560C07861A00B0BB3C /* completion.c in Sources */, 2757 2770 BEFC1E580C07861A00B0BB3C /* clients.c in Sources */, … … 2787 2800 A209EE5C1144B51E002B02D1 /* history.c in Sources */, 2788 2801 A220EC5B118C8A060022B4BE /* tr-lpd.c in Sources */, 2802 C1FEE57A1C3223CC00D62832 /* watchdir.c in Sources */, 2789 2803 A23547E211CD0B090046EAE6 /* cache.c in Sources */, 2790 2804 A284214412DA663E00FBDDBB /* tr-udp.c in Sources */, 2791 2805 A2679294130E00A000CB7464 /* tr-utp.c in Sources */, 2792 2806 A23F29A2132A447400E9A83B /* announcer-http.c in Sources */, 2807 C1FEE5791C3223CC00D62832 /* watchdir-kqueue.c in Sources */, 2793 2808 A2AA9BE1132CAC8E00FA131E /* announcer-udp.c in Sources */, 2794 2809 A2D77452154CC25700A62B93 /* WebSeedTableView.m in Sources */, … … 2967 2982 files = ( 2968 2983 BEFC1C1A0C07756200B0BB3C /* daemon.c in Sources */, 2969 A2D5972A0F5AE49E0001AB3C /* watch.c in Sources */,2970 2984 C1F690FD1AD0627500D95CF0 /* daemon-posix.c in Sources */, 2971 2985 ); -
trunk/configure.ac
r14645 r14651 205 205 dnl file monitoring for the daemon 206 206 207 AC_CHECK_HEADER([sys/inotify.h],208 [AC_CHECK_FUNC([inotify_init],[have_inotify="yes"],[have_inotify="no"])],209 [have_inotify="no"])210 207 AC_ARG_WITH([inotify], 211 [AS_HELP_STRING([--with-inotify],[Enable inotify support (default=auto)])], 212 [want_inotify=${withval}], 213 [want_inotify=${have_inotify}]) 214 if test "x$want_inotify" = "xyes" ; then 215 if test "x$have_inotify" = "xyes"; then 216 AC_DEFINE([WITH_INOTIFY],[1]) 217 else 218 AC_MSG_ERROR("inotify not found!") 219 fi 220 fi 221 222 AC_CHECK_HEADER([sys/event.h], 223 [AC_CHECK_FUNC([kqueue],[have_kqueue="yes"],[have_kqueue="no"])], 224 [have_kqueue="no"]) 208 [AS_HELP_STRING([--with-inotify], [Enable inotify support (default=auto)])], 209 [WANT_INOTIFY=${withval}], 210 [WANT_INOTIFY=auto]) 211 HAVE_INOTIFY=0 212 AS_IF([test "x$WANT_INOTIFY" != "xno"], 213 [AC_CHECK_HEADER([sys/inotify.h], 214 [AC_CHECK_FUNC([inotify_init], 215 [HAVE_INOTIFY=1])], 216 [AS_IF([test "x$WANT_INOTIFY" = "xyes"], 217 [AC_MSG_ERROR("inotify not found!")])])]) 218 AM_CONDITIONAL([USE_INOTIFY], [test "x$WANT_INOTIFY" != "xno" -a $HAVE_INOTIFY -eq 1]) 219 225 220 AC_ARG_WITH([kqueue], 226 221 [AS_HELP_STRING([--with-kqueue],[Enable kqueue support (default=auto)])], 227 [want_kqueue=${withval}], 228 [want_kqueue=${have_kqueue}]) 229 if test "x$want_kqueue" = "xyes" ; then 230 if test "x$have_kqueue" = "xyes"; then 231 AC_DEFINE([WITH_KQUEUE],[1]) 232 else 233 AC_MSG_ERROR("kqueue not found!") 234 fi 235 fi 222 [WITH_KQUEUE=${withval}], 223 [WITH_KQUEUE=auto]) 224 HAVE_KQUEUE=0 225 AS_IF([test "x$WITH_KQUEUE" != "xno"], 226 [AC_CHECK_HEADER([sys/event.h], 227 [AC_CHECK_FUNC([kqueue], 228 [HAVE_KQUEUE=1])], 229 [AS_IF([test "x$WANT_KQUEUE" = "xyes"], 230 [AC_MSG_ERROR("kqueue not found!")])])]) 231 AM_CONDITIONAL([USE_KQUEUE], [test "x$WITH_KQUEUE" != "xno" -a $HAVE_KQUEUE -eq 1]) 232 236 233 237 234 AC_CHECK_HEADERS([sys/statvfs.h \ -
trunk/daemon/CMakeLists.txt
r14643 r14651 1 1 project(trdaemon) 2 3 if(WITH_INOTIFY)4 add_definitions(-DWITH_INOTIFY)5 endif()6 7 if(WITH_KQUEUE)8 add_definitions(-DWITH_KQUEUE)9 endif()10 2 11 3 if(WITH_SYSTEMD) … … 23 15 daemon-posix.c 24 16 daemon-win32.c 25 watch.c26 17 ) 27 18 … … 34 25 set(${PROJECT_NAME}_HEADERS 35 26 daemon.h 36 watch.h37 27 ) 38 28 -
trunk/daemon/Makefile.am
r14487 r14651 35 35 ${LIBM} 36 36 37 noinst_HEADERS = \ 38 daemon.h \ 39 watch.h 37 noinst_HEADERS = daemon.h 40 38 41 transmission_daemon_SOURCES = daemon.c watch.c39 transmission_daemon_SOURCES = daemon.c 42 40 transmission_remote_SOURCES = remote.c 43 41 -
trunk/daemon/daemon.c
r14615 r14651 22 22 #endif 23 23 24 #include <event2/buffer.h>25 24 #include <event2/event.h> 26 25 … … 33 32 #include <libtransmission/variant.h> 34 33 #include <libtransmission/version.h> 34 #include <libtransmission/watchdir.h> 35 35 36 36 #ifdef USE_SYSTEMD_DAEMON … … 42 42 43 43 #include "daemon.h" 44 #include "watch.h"45 44 46 45 #define MY_NAME "transmission-daemon" … … 186 185 } 187 186 188 static void 189 onFileAdded (tr_session * session, const char * dir, const char * file) 190 { 191 char * filename = tr_buildPath (dir, file, NULL); 187 static tr_watchdir_status 188 onFileAdded (tr_watchdir_t dir, 189 const char * name, 190 void * context) 191 { 192 tr_session * session = context; 193 194 if (!tr_str_has_suffix (name, ".torrent")) 195 return TR_WATCHDIR_IGNORE; 196 197 char * filename = tr_buildPath (tr_watchdir_get_path (dir), name, NULL); 192 198 tr_ctor * ctor = tr_ctorNew (session); 193 199 int err = tr_ctorSetMetainfoFromFile (ctor, filename); … … 198 204 199 205 if (err == TR_PARSE_ERR) 200 tr_logAddError ("Error parsing .torrent file \"%s\"", file);206 tr_logAddError ("Error parsing .torrent file \"%s\"", name); 201 207 else 202 208 { … … 204 210 const bool test = tr_ctorGetDeleteSource (ctor, &trash); 205 211 206 tr_logAddInfo ("Parsing .torrent file successful \"%s\"", file);212 tr_logAddInfo ("Parsing .torrent file successful \"%s\"", name); 207 213 208 214 if (test && trash) … … 210 216 tr_error * error = NULL; 211 217 212 tr_logAddInfo ("Deleting input .torrent file \"%s\"", file);218 tr_logAddInfo ("Deleting input .torrent file \"%s\"", name); 213 219 if (!tr_sys_path_remove (filename, &error)) 214 220 { … … 225 231 } 226 232 } 233 else 234 { 235 err = TR_PARSE_ERR; 236 } 227 237 228 238 tr_ctorFree (ctor); 229 239 tr_free (filename); 240 241 return err == TR_PARSE_ERR ? TR_WATCHDIR_RETRY : TR_WATCHDIR_ACCEPT; 230 242 } 231 243 … … 294 306 295 307 static void 296 periodicUpdate (evutil_socket_t fd UNUSED, short what UNUSED, void *watchdir)297 { 298 dtr_watchdir_update (watchdir);299 308 periodicUpdate (evutil_socket_t fd UNUSED, 309 short what UNUSED, 310 void * context UNUSED) 311 { 300 312 pumpLogMessages (logfile); 301 302 313 reportStatus (); 303 314 } … … 480 491 bool boolVal; 481 492 const char * pid_filename; 482 dtr_watchdir * watchdir = NULL;483 493 bool pidfile_created = false; 484 494 tr_session * session = NULL; 485 struct event *status_ev; 495 struct event * status_ev = NULL; 496 tr_watchdir_t watchdir = NULL; 486 497 487 498 struct daemon_data * const arg = raw_arg; … … 559 570 { 560 571 tr_logAddInfo ("Watching \"%s\" for new .torrent files", dir); 561 watchdir = dtr_watchdir_new (mySession, dir, onFileAdded); 572 if ((watchdir = tr_watchdir_new (dir, &onFileAdded, mySession, ev_base)) == NULL) 573 goto cleanup; 562 574 } 563 575 } … … 582 594 { 583 595 struct timeval one_sec = { 1, 0 }; 584 status_ev = event_new(ev_base, -1, EV_PERSIST, &periodicUpdate, watchdir);596 status_ev = event_new(ev_base, -1, EV_PERSIST, &periodicUpdate, NULL); 585 597 if (status_ev == NULL) 586 598 { … … 608 620 printf ("Closing transmission session..."); 609 621 622 tr_watchdir_free (watchdir); 623 610 624 if (status_ev) 611 625 { … … 616 630 617 631 tr_sessionSaveSettings (mySession, configDir, settings); 618 dtr_watchdir_free (watchdir);619 632 tr_sessionClose (mySession); 620 633 pumpLogMessages (logfile); -
trunk/libtransmission/CMakeLists.txt
r14643 r14651 63 63 variant-json.c 64 64 verify.c 65 watchdir.c 66 watchdir-generic.c 67 watchdir-inotify.c 68 watchdir-kqueue.c 69 watchdir-win32.c 65 70 web.c 66 71 webseed.c … … 75 80 endforeach() 76 81 82 if(WITH_INOTIFY) 83 add_definitions(-DWITH_INOTIFY) 84 else() 85 set_source_files_properties(watchdir-inotify.c PROPERTIES HEADER_FILE_ONLY ON) 86 endif() 87 88 if(WITH_KQUEUE) 89 add_definitions(-DWITH_KQUEUE) 90 else() 91 set_source_files_properties(watchdir-kqueue.c PROPERTIES HEADER_FILE_ONLY ON) 92 endif() 93 77 94 if(WIN32) 78 95 set_source_files_properties(file-posix.c PROPERTIES HEADER_FILE_ONLY ON) 79 96 else() 80 set_source_files_properties(file-win32.c PROPERTIES HEADER_FILE_ONLY ON)97 set_source_files_properties(file-win32.c watchdir-win32.c PROPERTIES HEADER_FILE_ONLY ON) 81 98 endif() 82 99 … … 93 110 utils.h 94 111 variant.h 112 watchdir.h 95 113 web.h 96 114 ${PROJECT_BINARY_DIR}/version.h … … 141 159 verify.h 142 160 version.h 161 watchdir-common.h 143 162 webseed.h 144 163 ) … … 241 260 set(crypto-test_ADD_SOURCES crypto-test-ref.h) 242 261 243 foreach(T bitfield blocklist clients crypto error file history json magnet metainfo move peer-msgs quark rename rpc session tr-getopt utils variant) 262 foreach(T bitfield blocklist clients crypto error file history json magnet metainfo move peer-msgs quark rename rpc session 263 tr-getopt utils variant watchdir) 244 264 set(TP ${TR_NAME}-test-${T}) 245 265 add_executable(${TP} ${T}-test.c ${${T}-test_ADD_SOURCES}) -
trunk/libtransmission/Makefile.am
r14459 r14651 73 73 variant-json.c \ 74 74 verify.c \ 75 watchdir.c \ 76 watchdir-generic.c \ 75 77 web.c \ 76 78 webseed.c \ 77 79 wildmat.c 78 80 81 if USE_INOTIFY 82 libtransmission_a_SOURCES += watchdir-inotify.c 83 endif 84 85 if USE_KQUEUE 86 libtransmission_a_SOURCES += watchdir-kqueue.c 87 endif 88 79 89 if WIN32 80 libtransmission_a_SOURCES += file-win32.c 90 libtransmission_a_SOURCES += file-win32.c watchdir-win32.c 81 91 else 82 92 libtransmission_a_SOURCES += file-posix.c … … 151 161 verify.h \ 152 162 version.h \ 163 watchdir.h \ 164 watchdir-common.h \ 153 165 web.h \ 154 166 webseed.h … … 174 186 tr-getopt-test \ 175 187 utils-test \ 176 variant-test 188 variant-test \ 189 watchdir-test 177 190 178 191 noinst_PROGRAMS = $(TESTS) … … 271 284 variant_test_LDFLAGS = ${apps_ldflags} 272 285 286 watchdir_test_SOURCES = watchdir-test.c $(TEST_SOURCES) 287 watchdir_test_LDADD = ${apps_ldadd} 288 watchdir_test_LDFLAGS = ${apps_ldflags} 289 273 290 rename_test_SOURCES = rename-test.c $(TEST_SOURCES) 274 291 rename_test_LDADD = ${apps_ldadd}
Note: See TracChangeset
for help on using the changeset viewer.