-Lock fix
This commit is contained in:
tonikelope 2016-11-30 17:26:00 +01:00
parent 6766c9fcde
commit 7ab4d9a62c
4 changed files with 21 additions and 7 deletions

View File

@ -62,6 +62,7 @@ public final class Download implements Transference, Runnable, SecureNotifiable
private volatile SpeedMeter _speed_meter = null; //lazy init
private volatile ProgressMeter _progress_meter = null; //lazy init;
private final Object _secure_notify_lock;
private final Object _workers_lock;
private boolean _notified;
private final String _url;
private final String _download_path;
@ -121,6 +122,7 @@ public final class Download implements Transference, Runnable, SecureNotifiable
_slots = slots;
_restart = restart;
_secure_notify_lock = new Object();
_workers_lock = new Object();
_chunkworkers = new ArrayList<>();
_partialProgressQueue = new ConcurrentLinkedQueue<>();
_rejectedChunkIds = new ConcurrentLinkedQueue<>();
@ -317,10 +319,13 @@ public final class Download implements Transference, Runnable, SecureNotifiable
getSpeed_meter().secureNotify();
synchronized (_workers_lock) {
for (ChunkDownloader downloader : getChunkworkers()) {
downloader.secureNotify();
}
}
getView().resume();
@ -1114,7 +1119,7 @@ public final class Download implements Transference, Runnable, SecureNotifiable
getView().stop("Stopping download safely, please wait...");
synchronized (this) {
synchronized (_workers_lock) {
for (ChunkDownloader downloader : _chunkworkers) {
@ -1122,6 +1127,8 @@ public final class Download implements Transference, Runnable, SecureNotifiable
}
}
System.out.println("stop4");
secureNotify();
}
}

View File

@ -354,12 +354,14 @@ public final class DownloadView extends javax.swing.JPanel implements Transferen
private void stop_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stop_buttonActionPerformed
_download.stop();
System.out.println("stopped");
}//GEN-LAST:event_stop_buttonActionPerformed
private void pause_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pause_buttonActionPerformed
_download.pause();
System.out.println("paused!");
}//GEN-LAST:event_pause_buttonActionPerformed
@Override

View File

@ -61,7 +61,7 @@ import org.apache.http.auth.UsernamePasswordCredentials;
*/
public final class MainPanel {
public static final String VERSION = "1.62";
public static final String VERSION = "1.63";
public static final int THROTTLE_SLICE_SIZE = 16 * 1024;
public static final int STREAMER_PORT = 1337;
public static final int WATCHDOG_PORT = 1338;

View File

@ -42,6 +42,7 @@ public final class Upload implements Transference, Runnable, SecureNotifiable {
private volatile boolean _exit;
private final int _slots;
private final Object _secure_notify_lock;
private final Object _workers_lock;
private byte[] _byte_file_key;
private String _fatal_error;
private volatile long _progress;
@ -97,6 +98,7 @@ public final class Upload implements Transference, Runnable, SecureNotifiable {
_restart = restart;
_completion_handle = null;
_secure_notify_lock = new Object();
_workers_lock = new Object();
_chunkworkers = new ArrayList<>();
_partialProgressQueue = new ConcurrentLinkedQueue<>();
_rejectedChunkIds = new ConcurrentLinkedQueue<>();
@ -494,10 +496,13 @@ public final class Upload implements Transference, Runnable, SecureNotifiable {
getSpeed_meter().secureNotify();
synchronized (_workers_lock) {
for (ChunkUploader uploader : getChunkworkers()) {
uploader.secureNotify();
}
}
setPaused_workers(0);
@ -988,7 +993,7 @@ public final class Upload implements Transference, Runnable, SecureNotifiable {
getView().stop("Stopping upload safely, please wait...");
synchronized (this) {
synchronized (_workers_lock) {
for (ChunkUploader uploader : _chunkworkers) {