]> granicus.if.org Git - transmission/commitdiff
fix race condition triggered in the unit tests by requiring a libtransmission thread...
authorJordan Lee <jordan@transmissionbt.com>
Thu, 31 Jan 2013 05:05:44 +0000 (05:05 +0000)
committerJordan Lee <jordan@transmissionbt.com>
Thu, 31 Jan 2013 05:05:44 +0000 (05:05 +0000)
libtransmission/fdlimit.c
libtransmission/torrent.c

index 9a51c1d0c471b03d42bec0eb0617bf30af3854bb..546e988a286019c424dd7cb3455dae92ffc50413 100644 (file)
@@ -607,7 +607,9 @@ tr_fdFileGetCachedMTime (tr_session * s, int torrent_id, tr_file_index_t i, time
 void
 tr_fdTorrentClose (tr_session * session, int torrent_id)
 {
-    fileset_close_torrent (get_fileset (session), torrent_id);
+  assert (tr_sessionIsLocked (session));
+
+  fileset_close_torrent (get_fileset (session), torrent_id);
 }
 
 /* returns an fd on success, or a -1 on failure and sets errno */
index a27cb0f44351835ce820772d8037b5f384f77e88..d48c6e2226614ef5b8ffa5f3aa3ddc9a36bcc5ef 100644 (file)
@@ -1734,10 +1734,7 @@ void
 tr_torrentVerify (tr_torrent * tor)
 {
   if (tr_isTorrent (tor))
-    {
-      tr_verifyRemove (tor);
-      tr_runInEventThread (tor->session, verifyTorrent, tor);
-    }
+    tr_runInEventThread (tor->session, verifyTorrent, tor);
 }
 
 void
@@ -1848,14 +1845,18 @@ static void tr_torrentDeleteLocalData (tr_torrent *, tr_fileFunc);
 static void
 removeTorrent (void * vdata)
 {
-    struct remove_data * data = vdata;
+  struct remove_data * data = vdata;
+  tr_session * session = data->tor->session;
+  tr_sessionLock (session); 
 
-    if (data->deleteFlag)
-        tr_torrentDeleteLocalData (data->tor, data->deleteFunc);
+  if (data->deleteFlag)
+    tr_torrentDeleteLocalData (data->tor, data->deleteFunc);
 
-    tr_torrentClearCompletenessCallback (data->tor);
-    closeTorrent (data->tor);
-    tr_free (data);
+  tr_torrentClearCompletenessCallback (data->tor);
+  closeTorrent (data->tor);
+  tr_free (data);
+
+  tr_sessionUnlock (session); 
 }
 
 void