Browse Source

Synchronized access to methods in all torrent adapters (notably Transmission) to ensure parallel execution of requests don't interfere with static session codes/authentication tokens.

pull/11/head
Eric Kok 11 years ago
parent
commit
acd0057b52
  1. BIN
      core/libs/transdroid-connect.jar
  2. 2
      core/src/org/transdroid/core/gui/DetailsActivity.java
  3. 2
      core/src/org/transdroid/core/gui/DetailsFragment.java
  4. 2
      lib/src/org/transdroid/daemon/Deluge/DelugeAdapter.java
  5. 2
      lib/src/org/transdroid/daemon/Qbittorrent/QbittorrentAdapter.java
  6. 4
      lib/src/org/transdroid/daemon/Transmission/TransmissionAdapter.java
  7. 2
      lib/src/org/transdroid/daemon/Utorrent/UtorrentAdapter.java
  8. 2
      lib/src/org/transdroid/daemon/Vuze/VuzeAdapter.java

BIN
core/libs/transdroid-connect.jar

Binary file not shown.

2
core/src/org/transdroid/core/gui/DetailsActivity.java

@ -112,7 +112,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent @@ -112,7 +112,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
protected void init() {
// We require a torrent to be specified; otherwise close the activity
if (torrent == null || currentLabels == null) {
if (torrent == null) {
finish();
return;
}

2
core/src/org/transdroid/core/gui/DetailsFragment.java

@ -187,7 +187,7 @@ public class DetailsFragment extends SherlockFragment implements OnTrackersUpdat @@ -187,7 +187,7 @@ public class DetailsFragment extends SherlockFragment implements OnTrackersUpdat
* @param currentLabels The list of known server labels
*/
public void updateLabels(ArrayList<Label> currentLabels) {
this.currentLabels = new ArrayList<Label>(currentLabels);
this.currentLabels = currentLabels == null? null: new ArrayList<Label>(currentLabels);
}
/**

2
lib/src/org/transdroid/daemon/Deluge/DelugeAdapter.java

@ -433,7 +433,7 @@ public class DelugeAdapter implements IDaemonAdapter { @@ -433,7 +433,7 @@ public class DelugeAdapter implements IDaemonAdapter {
}
private JSONObject makeRequest(JSONObject data) throws DaemonException {
private synchronized JSONObject makeRequest(JSONObject data) throws DaemonException {
try {

2
lib/src/org/transdroid/daemon/Qbittorrent/QbittorrentAdapter.java

@ -86,7 +86,7 @@ public class QbittorrentAdapter implements IDaemonAdapter { @@ -86,7 +86,7 @@ public class QbittorrentAdapter implements IDaemonAdapter {
this.settings = settings;
}
private void ensureVersion() throws DaemonException {
private synchronized void ensureVersion() throws DaemonException {
if (version > 0)
return;
// We still need to retrieve the version number from the server

4
lib/src/org/transdroid/daemon/Transmission/TransmissionAdapter.java

@ -375,7 +375,7 @@ public class TransmissionAdapter implements IDaemonAdapter { @@ -375,7 +375,7 @@ public class TransmissionAdapter implements IDaemonAdapter {
return request;
}
private JSONObject makeRequest(JSONObject data) throws DaemonException {
private synchronized JSONObject makeRequest(JSONObject data) throws DaemonException {
try {
@ -412,6 +412,8 @@ public class TransmissionAdapter implements IDaemonAdapter { @@ -412,6 +412,8 @@ public class TransmissionAdapter implements IDaemonAdapter {
DLog.d(LOG_NAME, "Receive HTTP 409 with new session code; now try again for the actual request");
sessionToken = response.getFirstHeader(sessionHeader).getValue();
httppost.addHeader(sessionHeader, sessionToken);
DLog.d(LOG_NAME, "Retry to execute " + data.getString("method") + " request, now with " + sessionHeader
+ ": " + sessionToken);
response = httpclient.execute(httppost);
}

2
lib/src/org/transdroid/daemon/Utorrent/UtorrentAdapter.java

@ -323,7 +323,7 @@ public class UtorrentAdapter implements IDaemonAdapter { @@ -323,7 +323,7 @@ public class UtorrentAdapter implements IDaemonAdapter {
}
private void ensureToken() throws IOException, ClientProtocolException, DaemonException {
private synchronized void ensureToken() throws IOException, ClientProtocolException, DaemonException {
// Make sure we have a valid token
if (authtoken == null) {

2
lib/src/org/transdroid/daemon/Vuze/VuzeAdapter.java

@ -219,7 +219,7 @@ public class VuzeAdapter implements IDaemonAdapter { @@ -219,7 +219,7 @@ public class VuzeAdapter implements IDaemonAdapter {
return makeVuzeCall(method, serverMethod, null, new Object[] {}, null);
}
private Map<String, Object> makeVuzeCall(DaemonMethod method, String serverMethod, Long actOnObject, Object[] params, TorrentStatus torrentStatus) throws DaemonException {
private synchronized Map<String, Object> makeVuzeCall(DaemonMethod method, String serverMethod, Long actOnObject, Object[] params, TorrentStatus torrentStatus) throws DaemonException {
// TODO: It would be nicer to now split each of these steps into separate makeVuzeCalls when there are multiple logical steps such as stopping a torrent before removing it

Loading…
Cancel
Save