Skip to content

Commit

Permalink
Fix for #974
Browse files Browse the repository at this point in the history
  • Loading branch information
jfarcand committed Mar 25, 2013
1 parent da76b3d commit 154ede6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -557,9 +557,10 @@ public String toString() {
}

protected Runnable getBroadcastHandler() {
final AtomicBoolean init = new AtomicBoolean(true);
return new Runnable() {
public void run() {
while (!isDestroyed() && !outOfOrderBroadcastSupported.get()) {
while (init.getAndSet(false) || (!isDestroyed() && !outOfOrderBroadcastSupported.get())) {
Entry msg = null;
try {
msg = messages.poll(waitTime, TimeUnit.MILLISECONDS);
Expand All @@ -573,6 +574,7 @@ public void run() {
return;
} finally {
if (outOfOrderBroadcastSupported.get()) {
init.set(true);
bc.getExecutorService().submit(this);
}
}
Expand All @@ -595,9 +597,10 @@ public void run() {
}

protected Runnable getAsyncWriteHandler(final WriteQueue writeQueue) {
final AtomicBoolean init = new AtomicBoolean(true);
return new Runnable() {
public void run() {
while (!isDestroyed() && !outOfOrderBroadcastSupported.get()) {
while (init.getAndSet(false) || (!isDestroyed() && !outOfOrderBroadcastSupported.get())) {
AsyncWriteToken token = null;
try {
token = writeQueue.queue.poll(waitTime, TimeUnit.MILLISECONDS);
Expand All @@ -615,9 +618,9 @@ public void run() {
logger.trace("", ex);
return;
} finally {
if (!bc.getAsyncWriteService().isShutdown() && token == null && outOfOrderBroadcastSupported.get()) {
if (!bc.getAsyncWriteService().isShutdown() && outOfOrderBroadcastSupported.get()) {
init.set(true);
bc.getAsyncWriteService().submit(this);
return;
}
}

Expand Down
10 changes: 7 additions & 3 deletions samples/chat/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:j2ee="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2.5.xsd">
xmlns:j2ee="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2.5.xsd">

<description>Atmosphere Chat</description>
<display-name>Atmosphere Chat</display-name>
Expand All @@ -12,6 +12,10 @@
<servlet-class>org.atmosphere.cpr.AtmosphereServlet</servlet-class>
<async-supported>true</async-supported>
<load-on-startup>0</load-on-startup>
<init-param>
<param-name>org.atmosphere.cpr.Broadcaster.supportOutOfOrderBroadcast</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>AtmosphereServlet</servlet-name>
Expand Down

0 comments on commit 154ede6

Please sign in to comment.