20
20
*/
21
21
public class ChunkDownloader implements Runnable , SecureSingleThreadNotifiable {
22
22
23
+ public static final int DISABLE_SMART_PROXY_TIMEOUT = 3600 ;
23
24
private final int _id ;
24
25
private final Download _download ;
25
26
private volatile boolean _exit ;
26
27
private final Object _secure_notify_lock ;
27
28
private volatile boolean _error_wait ;
28
29
private boolean _notified ;
29
- private boolean _error_no_proxy ;
30
- private String _proxy ;
30
+ private volatile boolean _use_smart_proxy ;
31
31
32
32
public ChunkDownloader (int id , Download download ) {
33
33
_notified = false ;
@@ -36,15 +36,15 @@ public ChunkDownloader(int id, Download download) {
36
36
_id = id ;
37
37
_download = download ;
38
38
_error_wait = false ;
39
- _error_no_proxy = false ;
39
+ _use_smart_proxy = false ;
40
40
}
41
41
42
- public boolean isError_no_proxy () {
43
- return _error_no_proxy ;
42
+ public boolean isUse_smart_proxy () {
43
+ return _use_smart_proxy ;
44
44
}
45
45
46
- public void setError_no_proxy (boolean _error_no_proxy ) {
47
- this . _error_no_proxy = _error_no_proxy ;
46
+ public void setUse_smart_proxy (boolean value ) {
47
+ _use_smart_proxy = value ;
48
48
}
49
49
50
50
public void setExit (boolean exit ) {
@@ -101,6 +101,24 @@ public void secureWait() {
101
101
102
102
@ Override
103
103
public void run () {
104
+
105
+ THREAD_POOL .execute (new Runnable () {
106
+
107
+ @ Override
108
+ public void run () {
109
+
110
+ while (!_exit ) {
111
+
112
+ try {
113
+ _use_smart_proxy = false ;
114
+ Thread .sleep (DISABLE_SMART_PROXY_TIMEOUT * 1000 );
115
+ } catch (InterruptedException ex ) {
116
+ Logger .getLogger (ChunkDownloader .class .getName ()).log (Level .SEVERE , null , ex );
117
+ }
118
+ }
119
+ }
120
+ });
121
+
104
122
String worker_url = null ;
105
123
Chunk chunk ;
106
124
int reads , conta_error , http_status ;
@@ -120,13 +138,18 @@ public void run() {
120
138
121
139
while (!_exit && !_download .isStopped ()) {
122
140
123
- if (httpclient == null || error || (MainPanel .isUse_smart_proxy () && _error_no_proxy )) {
141
+ if (_use_smart_proxy && !MainPanel .isUse_smart_proxy ()) {
142
+
143
+ _use_smart_proxy = false ;
144
+ }
145
+
146
+ if (httpclient == null || error || (MainPanel .isUse_smart_proxy () && _use_smart_proxy )) {
124
147
125
- if (error ) {
126
- _error_no_proxy = true ;
148
+ if (error && ! _use_smart_proxy ) {
149
+ _use_smart_proxy = true ;
127
150
}
128
151
129
- if (MainPanel . isUse_smart_proxy () && _error_no_proxy ) {
152
+ if (_use_smart_proxy && ! MainPanel . isUse_proxy () ) {
130
153
131
154
if (error && current_proxy != null ) {
132
155
0 commit comments