Skip to content

Commit

Permalink
gc
Browse files Browse the repository at this point in the history
Improved fix for #170 [long-polling] Message losts during concurrent suspend/broadcast
  • Loading branch information
jfarcand committed Feb 1, 2012
1 parent a72bc42 commit 01a1988
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,6 @@ public synchronized void resume() {
}
} catch (Throwable t) {
logger.trace("Wasn't able to resume a connection {}", this, t);
} finally {
event.setMessage(null);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,6 @@ protected void executeAsyncWrite(final AsyncWriteToken token) {
cacheLostMessage(r, token);
}
token.destroy();
event.setMessage(null);
}
}

Expand Down Expand Up @@ -1034,8 +1033,11 @@ public <T> Future<T> broadcast(T msg, Set<AtmosphereResource<?, ?>> subset) {
BroadcasterFactory.getDefault().add(this, name);
}

resources.add(r);
checkCachedAndPush(r, r.getAtmosphereResourceEvent());
if (!AtmosphereResourceImpl.class.cast(r).isResumed() ||
AtmosphereResourceImpl.class.cast(r).isCancelled()) {
resources.add(r);
}
}
} finally {
// OK reset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ public final static void broadcast(final AtmosphereResource<?, ?> r, final Atmos
cr.setResponse(Response.ok(msg).build());
cr.getHttpHeaders().add(HttpHeaders.CONTENT_TYPE, m);
cr.write();
}

// https://github.com/Atmosphere/atmosphere/issues/169
if (!cr.isCommitted()) {
cr.getOutputStream().flush();
// https://github.com/Atmosphere/atmosphere/issues/169
if (!cr.isCommitted()) {
cr.getOutputStream().flush();
}
}
} else {
if (e.getMessage() == null) {
Expand All @@ -87,7 +87,7 @@ public final static void broadcast(final AtmosphereResource<?, ?> r, final Atmos
if (DefaultBroadcaster.class.isAssignableFrom(broadcaster.getClass())) {
DefaultBroadcaster.class.cast(broadcaster).onException(t, r);
} else {
onException(t,r);
onException(t, r);
}
} finally {
if (cr != null) {
Expand Down

0 comments on commit 01a1988

Please sign in to comment.