Changeset 13909
- Timestamp:
- Jan 31, 2013, 5:39:06 PM (8 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/cache.c
r13868 r13909 22 22 #include "ptrarray.h" 23 23 #include "torrent.h" 24 #include "trevent.h" 24 25 #include "utils.h" 25 26 … … 333 334 { 334 335 struct cache_block * cb = findBlock (cache, torrent, piece, offset); 336 337 assert (tr_amInEventThread (torrent->session)); 335 338 336 339 if (cb == NULL) -
trunk/libtransmission/move-test.c
r13882 r13909 14 14 #include "cache.h" 15 15 #include "resume.h" 16 #include "trevent.h" 16 17 #include "torrent.h" /* tr_isTorrent() */ 17 18 #include "utils.h" /* tr_mkdirp() */ … … 23 24 **** 24 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) 25 33 26 34 static void … … 42 50 } while (0) 43 51 52 struct test_incomplete_dir_is_subdir_of_download_dir_data 53 { 54 tr_torrent * tor; 55 tr_block_index_t block; 56 tr_piece_index_t pieceIndex; 57 uint32_t offset; 58 struct evbuffer * buf; 59 bool done; 60 }; 61 62 static void 63 test_incomplete_dir_is_subdir_of_download_dir_threadfunc (void * vdata) 64 { 65 struct test_incomplete_dir_is_subdir_of_download_dir_data * data = vdata; 66 tr_cacheWriteBlock (session->cache, data->tor, 0, data->offset, data->tor->blockSize, data->buf); 67 tr_torrentGotBlock (data->tor, data->block); 68 data->done = true; 69 } 70 71 44 72 static int 45 73 test_incomplete_dir_is_subdir_of_download_dir (void) 46 74 { 75 size_t i; 47 76 char * incomplete_dir; 48 77 tr_torrent * tor; … … 66 95 check_int_eq (tor->info.pieceSize, tr_torrentStat(tor)->leftUntilDone); 67 96 97 completeness = completeness_unset; 98 tr_torrentSetCompletenessCallback (tor, zeroes_completeness_func, &completeness); 99 68 100 /* now finish writing it */ 69 101 { 70 uint32_t offset; 71 tr_block_index_t first, last, i; 72 struct evbuffer * buf = evbuffer_new (); 102 tr_block_index_t first, last; 73 103 char * zero_block = tr_new0 (char, tor->blockSize); 104 struct test_incomplete_dir_is_subdir_of_download_dir_data data; 74 105 75 completeness = completeness_unset; 76 tr_torrentSetCompletenessCallback (tor, zeroes_completeness_func, &completeness); 106 data.tor = tor; 107 data.pieceIndex = 0; 108 data.buf = evbuffer_new (); 77 109 78 tr_torGetPieceBlockRange (tor, 0, &first, &last);79 for ( offset=0, i=first; i<=last; ++i, offset+=tor->blockSize)110 tr_torGetPieceBlockRange (tor, data.pieceIndex, &first, &last); 111 for (i=first; i<=last; ++i) 80 112 { 81 evbuffer_add (buf, zero_block, tor->blockSize); 82 tr_cacheWriteBlock (session->cache, tor, 0, offset, tor->blockSize, buf); 83 tr_torrentGotBlock (tor, i); 113 evbuffer_add (data.buf, zero_block, tor->blockSize); 114 data.block = i; 115 data.done = false; 116 data.offset = data.block * tor->blockSize; 117 tr_runInEventThread (session, test_incomplete_dir_is_subdir_of_download_dir_threadfunc, &data); 118 do { tr_wait_msec(50); } while (!data.done); 84 119 } 85 sync ();86 120 87 tr_torrentVerify (tor); 88 while ((completeness==completeness_unset) && (time(NULL)<=deadline)) 89 tr_wait_msec (50); 90 check_int_eq (TR_SEED, completeness); 91 for (i=0; i<tor->info.fileCount; ++i) 92 check_file_location (tor, i, tr_buildPath (downloadDir, tor->info.files[i].name, NULL)); 93 94 evbuffer_free (buf); 121 evbuffer_free (data.buf); 95 122 tr_free (zero_block); 96 123 } 97 124 125 verify_and_block_until_done (tor); 126 check_int_eq (0, tr_torrentStat(tor)->leftUntilDone); 127 128 while ((completeness==completeness_unset) && (time(NULL)<=deadline)) 129 tr_wait_msec (50); 130 131 check_int_eq (TR_SEED, completeness); 132 for (i=0; i<tor->info.fileCount; ++i) 133 check_file_location (tor, i, tr_buildPath (downloadDir, tor->info.files[i].name, NULL)); 98 134 99 135 /* cleanup */ -
trunk/libtransmission/torrent.c
r13905 r13909 2951 2951 /* blow away the leftover subdirectories in the old location */ 2952 2952 if (do_move) 2953 2953 tr_torrentDeleteLocalData (tor, remove); 2954 2954 2955 2955 /* set the new location and reverify */ … … 3066 3066 { 3067 3067 const bool block_is_new = !tr_cpBlockIsComplete (&tor->completion, block); 3068 3069 assert (tr_isTorrent (tor)); 3070 assert (tr_amInEventThread (tor->session)); 3068 3071 3069 3072 if (block_is_new)
Note: See TracChangeset
for help on using the changeset viewer.