1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-26 09:47:13 +00:00

Close connection on boundary end

This commit is contained in:
M66B 2020-07-27 15:52:50 +02:00
parent 0234827b41
commit 7460f960c3
2 changed files with 17 additions and 7 deletions

View file

@ -133,7 +133,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
executor.submit(new Runnable() {
@Override
public void run() {
close(state);
close(state, true);
}
});
queue_load(state);
@ -162,7 +162,7 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
throw ex;
Log.w("Boundary", ex);
close(state);
close(state, true);
// Retry
load_server(state);
@ -529,6 +529,11 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
}
}
if (state.index < 0) {
Log.i("Boundary server end");
close(state, false);
}
Log.i("Boundary server done");
return found;
}
@ -579,29 +584,30 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
executor.submit(new Runnable() {
@Override
public void run() {
close(old);
close(old, true);
}
});
}
private void close(State state) {
private void close(State state, boolean reset) {
Log.i("Boundary close");
try {
if (state.ifolder != null)
if (state.ifolder != null && state.ifolder.isOpen())
state.ifolder.close();
} catch (Throwable ex) {
Log.e("Boundary", ex);
}
try {
if (state.iservice != null)
if (state.iservice != null && state.iservice.isOpen())
state.iservice.close();
} catch (Throwable ex) {
Log.e("Boundary", ex);
}
state.reset();
if (reset)
state.reset();
}
private class State {

View file

@ -674,6 +674,10 @@ public class EmailService implements AutoCloseable {
return false;
}
public boolean isOpen() {
return (iservice != null && iservice.isConnected());
}
public void close() throws MessagingException {
try {
if (iservice != null && iservice.isConnected())