Changeset 13913
- Timestamp:
- Jan 31, 2013, 9:58:25 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cli/cli.c
r13842 r13913 329 329 { 330 330 verify = false; 331 tr_torrentVerify (tor );331 tr_torrentVerify (tor, NULL, NULL); 332 332 } 333 333 -
trunk/gtk/open-dialog.c
r13683 r13913 164 164 gtk_widget_set_sensitive (o->file_list, tr_torrentHasMetadata (o->tor)); 165 165 gtr_file_list_set_torrent (o->file_list, tr_torrentId (o->tor)); 166 tr_torrentVerify (o->tor );166 tr_torrentVerify (o->tor, NULL, NULL); 167 167 } 168 168 } -
trunk/libtransmission/fail.sh
r13909 r13913 4 4 count=$((count+1)) 5 5 echo starting run number $count 6 make check6 ./rename-test 7 7 err=$? 8 8 done -
trunk/libtransmission/libtransmission-test.c
r13908 r13913 5 5 #include "platform.h" /* TR_PATH_DELIMETER */ 6 6 #include "torrent.h" 7 #include "trevent.h" 7 8 #include "libtransmission-test.h" 8 9 … … 324 325 } 325 326 326 #define verify_and_block_until_done(tor) \327 do { \328 do { tr_wait_msec (10); } while (tor->verifyState != TR_VERIFY_NONE); \329 tr_torrentVerify (tor); \330 do { tr_wait_msec (10); } while (tor->verifyState != TR_VERIFY_NONE); \331 } while (0)332 333 334 327 void 335 328 libtransmission_test_zero_torrent_populate (tr_torrent * tor, bool complete) … … 369 362 370 363 sync (); 371 verify_and_block_until_done(tor);364 libttest_blockingTorrentVerify (tor); 372 365 373 366 if (complete) … … 376 369 assert (tr_torrentStat(tor)->leftUntilDone == tor->info.pieceSize); 377 370 } 371 372 /*** 373 **** 374 ***/ 375 376 static void 377 onVerifyDone (tr_torrent * tor UNUSED, bool aborted UNUSED, void * done) 378 { 379 *(bool*)done = true; 380 } 381 382 void 383 libttest_blockingTorrentVerify (tr_torrent * tor) 384 { 385 bool done = false; 386 387 assert (session != NULL); 388 assert (!tr_amInEventThread (session)); 389 390 tr_torrentVerify (tor, onVerifyDone, &done); 391 while (!done) 392 tr_wait_msec (10); 393 } -
trunk/libtransmission/libtransmission-test.h
r13879 r13913 82 82 tr_torrent * libtransmission_test_zero_torrent_init (void); 83 83 84 void libttest_blockingTorrentVerify (tr_torrent * tor); 85 84 86 85 87 -
trunk/libtransmission/move-test.c
r13909 r13913 24 24 **** 25 25 ***/ 26 27 #define verify_and_block_until_done(tor) \28 do { \29 do { tr_wait_msec (10); } while (tor->verifyState != TR_VERIFY_NONE); \30 tr_torrentVerify (tor); \31 do { tr_wait_msec (10); } while (tor->verifyState != TR_VERIFY_NONE); \32 } while (0)33 26 34 27 static void … … 123 116 } 124 117 125 verify_and_block_until_done(tor);118 libttest_blockingTorrentVerify (tor); 126 119 check_int_eq (0, tr_torrentStat(tor)->leftUntilDone); 127 120 -
trunk/libtransmission/rename-test.c
r13911 r13913 20 20 **** 21 21 ***/ 22 23 #define verify_and_block_until_done(tor) \24 do { \25 do { tr_wait_msec (10); } while (tor->verifyState != TR_VERIFY_NONE); \26 tr_torrentVerify (tor); \27 do { tr_wait_msec (10); } while (tor->verifyState != TR_VERIFY_NONE); \28 } while (0)29 22 30 23 #define check_have_none(tor, totalSize) \ … … 173 166 174 167 /* sanity check the (empty) stats */ 175 verify_and_block_until_done(tor);168 libttest_blockingTorrentVerify (tor); 176 169 check_have_none (tor, totalSize); 177 170 … … 179 172 180 173 /* sanity check the stats again, now that we've added the file */ 181 verify_and_block_until_done(tor);174 libttest_blockingTorrentVerify (tor); 182 175 st = tr_torrentStat (tor); 183 176 check_int_eq (TR_STATUS_STOPPED, st->activity); … … 329 322 330 323 /* sanity check the (empty) stats */ 331 verify_and_block_until_done(tor);324 libttest_blockingTorrentVerify (tor); 332 325 check_have_none (tor, totalSize); 333 326 … … 336 329 337 330 /* sanity check the (full) stats */ 338 verify_and_block_until_done(tor);331 libttest_blockingTorrentVerify (tor); 339 332 st = tr_torrentStat (tor); 340 333 check_int_eq (TR_STATUS_STOPPED, st->activity); … … 415 408 tr_free (str); 416 409 sync (); 417 verify_and_block_until_done(tor);410 libttest_blockingTorrentVerify (tor); 418 411 testFileExistsAndConsistsOfThisString (tor, 0, expected_contents[0]); 419 412 for (i=1; i<=2; ++i) -
trunk/libtransmission/rpcimpl.c
r13868 r13913 396 396 { 397 397 tr_torrent * tor = torrents[i]; 398 tr_torrentVerify (tor );398 tr_torrentVerify (tor, NULL, NULL); 399 399 notify (session, TR_RPC_TORRENT_CHANGED, tor); 400 400 } -
trunk/libtransmission/torrent.c
r13909 r13913 919 919 { 920 920 tor->startAfterVerify = doStart; 921 tr_torrentVerify (tor );921 tr_torrentVerify (tor, NULL, NULL); 922 922 } 923 923 else if (doStart) … … 1683 1683 } 1684 1684 1685 struct verify_data 1686 { 1687 bool aborted; 1688 tr_torrent * tor; 1689 tr_verify_done_func callback_func; 1690 void * callback_data; 1691 }; 1692 1685 1693 static void 1686 torrentRecheckDoneImpl (void * vtor) 1687 { 1688 tr_torrent * tor = vtor; 1689 assert (tr_isTorrent (tor)); 1690 1694 onVerifyDoneThreadFunc (void * vdata) 1695 { 1696 struct verify_data * data = vdata; 1697 tr_torrent * tor = data->tor; 1698 1699 if (!data->aborted) 1691 1700 tr_torrentRecheckCompleteness (tor); 1692 1701 1693 if (tor->startAfterVerify) { 1694 tor->startAfterVerify = false; 1695 torrentStart (tor, false); 1696 } 1702 if (data->callback_func != NULL) 1703 (*data->callback_func)(tor, data->aborted, data->callback_data); 1704 1705 if (!data->aborted && tor->startAfterVerify) 1706 { 1707 tor->startAfterVerify = false; 1708 torrentStart (tor, false); 1709 } 1710 1711 tr_free (data); 1697 1712 } 1698 1713 1699 1714 static void 1700 torrentRecheckDoneCB (tr_torrent * tor) 1701 { 1702 assert (tr_isTorrent (tor)); 1703 1704 tr_runInEventThread (tor->session, torrentRecheckDoneImpl, tor); 1715 onVerifyDone (tr_torrent * tor, bool aborted, void * vdata) 1716 { 1717 struct verify_data * data = vdata; 1718 assert (data->tor == tor); 1719 data->aborted = aborted; 1720 tr_runInEventThread (tor->session, onVerifyDoneThreadFunc, data); 1705 1721 } 1706 1722 1707 1723 static void 1708 verifyTorrent (void * vtor) 1709 { 1710 bool startAfter; 1711 tr_torrent * tor = vtor; 1712 1713 tr_sessionLock (tor->session); 1714 1715 /* if the torrent's already being verified, stop it */ 1716 tr_verifyRemove (tor); 1717 1718 startAfter = (tor->isRunning || tor->startAfterVerify) && !tor->isStopping; 1719 1720 if (tor->isRunning) 1721 tr_torrentStop (tor); 1722 1723 tor->startAfterVerify = startAfter; 1724 1725 if (setLocalErrorIfFilesDisappeared (tor)) 1726 tor->startAfterVerify = false; 1727 else 1728 tr_verifyAdd (tor, torrentRecheckDoneCB); 1729 1730 tr_sessionUnlock (tor->session); 1731 } 1732 1733 void 1734 tr_torrentVerify (tr_torrent * tor) 1735 { 1736 if (tr_isTorrent (tor)) 1737 tr_runInEventThread (tor->session, verifyTorrent, tor); 1724 verifyTorrent (void * vdata) 1725 { 1726 bool startAfter; 1727 struct verify_data * data = vdata; 1728 tr_torrent * tor = data->tor; 1729 tr_sessionLock (tor->session); 1730 1731 /* if the torrent's already being verified, stop it */ 1732 tr_verifyRemove (tor); 1733 1734 startAfter = (tor->isRunning || tor->startAfterVerify) && !tor->isStopping; 1735 if (tor->isRunning) 1736 tr_torrentStop (tor); 1737 tor->startAfterVerify = startAfter; 1738 1739 if (setLocalErrorIfFilesDisappeared (tor)) 1740 tor->startAfterVerify = false; 1741 else 1742 tr_verifyAdd (tor, onVerifyDone, data); 1743 1744 tr_sessionUnlock (tor->session); 1745 } 1746 1747 void 1748 tr_torrentVerify (tr_torrent * tor, 1749 tr_verify_done_func callback_func, 1750 void * callback_data) 1751 { 1752 struct verify_data * data; 1753 1754 data = tr_new (struct verify_data, 1); 1755 data->tor = tor; 1756 data->aborted = false; 1757 data->callback_func = callback_func; 1758 data->callback_data = callback_data; 1759 tr_runInEventThread (tor->session, verifyTorrent, data); 1738 1760 } 1739 1761 -
trunk/libtransmission/transmission.h
r13868 r13913 1440 1440 1441 1441 typedef void (tr_torrent_metadata_func)(tr_torrent * torrent, 1442 1442 void * user_data); 1443 1443 /** 1444 1444 * Register to be notified whenever a torrent changes from … … 1723 1723 int size); 1724 1724 1725 void tr_torrentVerify (tr_torrent * torrent); 1725 /** 1726 * Callback function invoked when a torrent finishes being verified. 1727 * 1728 * @param torrent the torrent that was verified 1729 * @param aborted true if the verify ended prematurely for some reason, 1730 * such as tr_torrentStop() or tr_torrentSetLocation() 1731 * being called during verification. 1732 * @param callback_data the user-defined pointer from tr_torrentVerify() 1733 */ 1734 typedef void (*tr_verify_done_func)(tr_torrent * torrent, 1735 bool aborted, 1736 void * user_data); 1737 1738 /** 1739 * Queue a torrent for verification. 1740 * 1741 * If callback_func is non-NULL, it will be called from the libtransmission 1742 * thread after the torrent's completness state is updated after the 1743 * file verification pass. 1744 */ 1745 void tr_torrentVerify (tr_torrent * torrent, 1746 tr_verify_done_func callback_func_or_NULL, 1747 void * callback_data_or_NULL); 1726 1748 1727 1749 /*********************************************************************** -
trunk/libtransmission/verify.c
r13868 r13913 174 174 struct verify_node 175 175 { 176 tr_torrent * torrent; 177 tr_verify_done_cb verify_done_cb; 178 uint64_t current_size; 176 tr_torrent * torrent; 177 tr_verify_done_func callback_func; 178 void * callback_data; 179 uint64_t current_size; 179 180 }; 180 181 static void182 fireCheckDone (tr_torrent * tor, tr_verify_done_cb verify_done_cb)183 {184 assert (tr_isTorrent (tor));185 186 if (verify_done_cb)187 verify_done_cb (tor);188 }189 181 190 182 static struct verify_node currentNode; … … 234 226 assert (tr_isTorrent (tor)); 235 227 236 if (!stopCurrent) 237 { 238 if (changed) 239 tr_torrentSetDirty (tor); 240 fireCheckDone (tor, currentNode.verify_done_cb); 241 } 228 if (!stopCurrent && changed) 229 tr_torrentSetDirty (tor); 230 231 if (currentNode.callback_func) 232 (*currentNode.callback_func)(tor, stopCurrent, currentNode.callback_data); 242 233 } 243 234 … … 267 258 268 259 void 269 tr_verifyAdd (tr_torrent * tor, tr_verify_done_cb verify_done_cb) 260 tr_verifyAdd (tr_torrent * tor, 261 tr_verify_done_func callback_func, 262 void * callback_data) 270 263 { 271 264 struct verify_node * node; … … 276 269 node = tr_new (struct verify_node, 1); 277 270 node->torrent = tor; 278 node->verify_done_cb = verify_done_cb; 271 node->callback_func = callback_func; 272 node->callback_data = callback_data; 279 273 node->current_size = tr_torrentGetCurrentSizeOnDisk (tor); 280 274 -
trunk/libtransmission/verify.h
r13625 r13913 23 23 */ 24 24 25 typedef void (*tr_verify_done_cb)(tr_torrent * tor); 26 27 void tr_verifyAdd (tr_torrent * tor, 28 tr_verify_done_cb recheck_done_cb); 25 void tr_verifyAdd (tr_torrent * tor, 26 tr_verify_done_func callback_func, 27 void * callback_user_data); 29 28 30 29 void tr_verifyRemove (tr_torrent * tor); -
trunk/macosx/Torrent.m
r13872 r13913 407 407 - (void) resetCache 408 408 { 409 tr_torrentVerify(fHandle );409 tr_torrentVerify(fHandle, NULL, NULL); 410 410 [self update]; 411 411 }
Note: See TracChangeset
for help on using the changeset viewer.