Skip to content
Snippets Groups Projects
Commit 578472ed authored by bontric's avatar bontric
Browse files

Handle SyncSession writer errors

parent 4f18303a
No related branches found
No related tags found
No related merge requests found
......@@ -15,4 +15,6 @@ public interface SyncSession {
* the next opportunity.
*/
void interrupt();
void writerException(IOException e);
}
......@@ -174,6 +174,7 @@ class ConnectionManagerImpl implements ConnectionManager {
private final ContactId contactId;
private final TransportId transportId;
private final TransportConnectionWriter writer;
private SyncSession outgoingSession;
private ManageOutgoingSimplexConnection(ContactId contactId,
TransportId transportId, TransportConnectionWriter writer) {
......@@ -202,7 +203,8 @@ class ConnectionManagerImpl implements ConnectionManager {
false);
try {
// Create and run the outgoing session
createSimplexOutgoingSession(ctx, writer).run();
outgoingSession = createSimplexOutgoingSession(ctx, writer);
outgoingSession.run();
disposeWriter(false);
} catch (IOException e) {
logException(LOG, WARNING, e);
......@@ -218,6 +220,7 @@ class ConnectionManagerImpl implements ConnectionManager {
writer.dispose(exception);
} catch (IOException e) {
logException(LOG, WARNING, e);
outgoingSession.writerException(e);
}
}
}
......
......@@ -195,6 +195,11 @@ class DuplexOutgoingSession implements SyncSession, EventListener {
writerTasks.add(CLOSE);
}
@Override
public void writerException(IOException e) {
// No handling required for now
}
@Override
public void eventOccurred(Event e) {
if (e instanceof ContactRemovedEvent) {
......
......@@ -105,6 +105,11 @@ class SimplexOutgoingSession implements SyncSession, EventListener {
writerTasks.add(CLOSE);
}
@Override
public void writerException(IOException e) {
// TODO: reset send times for messages
}
private void decrementOutstandingQueries() {
if (outstandingQueries.decrementAndGet() == 0) writerTasks.add(CLOSE);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment