Fix deadlock when calling LiveReloadServer.stop()
Update LiveReloadServer so that different synchronization blocks are used for the sockets and connection lists. Prior to this commit calling `LiveReloadServer.stop()` would always result in a 60 second delay since `stop()` owned the monitor add `removeConnection()` (called from a different thread) needs it to remove the active connection. Fixes gh-7749
This commit is contained in:
parent
42cfef8ec1
commit
5299db3806
|
|
@ -199,7 +199,7 @@ public class LiveReloadServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void closeAllConnections() throws IOException {
|
private void closeAllConnections() throws IOException {
|
||||||
synchronized (this.monitor) {
|
synchronized (this.connections) {
|
||||||
for (Connection connection : this.connections) {
|
for (Connection connection : this.connections) {
|
||||||
connection.close();
|
connection.close();
|
||||||
}
|
}
|
||||||
|
|
@ -211,25 +211,27 @@ public class LiveReloadServer {
|
||||||
*/
|
*/
|
||||||
public void triggerReload() {
|
public void triggerReload() {
|
||||||
synchronized (this.monitor) {
|
synchronized (this.monitor) {
|
||||||
for (Connection connection : this.connections) {
|
synchronized (this.connections) {
|
||||||
try {
|
for (Connection connection : this.connections) {
|
||||||
connection.triggerReload();
|
try {
|
||||||
}
|
connection.triggerReload();
|
||||||
catch (Exception ex) {
|
}
|
||||||
logger.debug("Unable to send reload message", ex);
|
catch (Exception ex) {
|
||||||
|
logger.debug("Unable to send reload message", ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addConnection(Connection connection) {
|
private void addConnection(Connection connection) {
|
||||||
synchronized (this.monitor) {
|
synchronized (this.connections) {
|
||||||
this.connections.add(connection);
|
this.connections.add(connection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeConnection(Connection connection) {
|
private void removeConnection(Connection connection) {
|
||||||
synchronized (this.monitor) {
|
synchronized (this.connections) {
|
||||||
this.connections.remove(connection);
|
this.connections.remove(connection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue