mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 02:30:08 -08:00
other: fixed rare errors on images download opening, fixed wrong code in chats and preferences store;
This commit is contained in:
parent
3d6a2817ae
commit
e386210b91
4 changed files with 31 additions and 9 deletions
|
|
@ -132,7 +132,7 @@ public class ChatSession {
|
|||
}
|
||||
}
|
||||
if (!clientsToRemove.isEmpty()) {
|
||||
final Lock w = lock.readLock();
|
||||
final Lock w = lock.writeLock();
|
||||
w.lock();
|
||||
try {
|
||||
users.keySet().removeAll(clientsToRemove);
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import java.util.concurrent.Executors;
|
|||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReadWriteLock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
|
||||
|
|
@ -53,13 +54,14 @@ public enum ServerMessagesUtil {
|
|||
}
|
||||
|
||||
public List<String> getMessages() {
|
||||
lock.readLock().lock();
|
||||
final Lock r = lock.readLock();
|
||||
r.lock();
|
||||
try {
|
||||
List<String> res = new ArrayList<>(this.newsMessages);
|
||||
res.add(this.statsMessage);
|
||||
return res;
|
||||
} finally {
|
||||
lock.readLock().unlock();
|
||||
r.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -68,13 +70,14 @@ public enum ServerMessagesUtil {
|
|||
List<String> updatedMessages = new ArrayList<>(readFromFile());
|
||||
String updatedStats = getServerStatsMessage();
|
||||
|
||||
lock.writeLock().lock();
|
||||
final Lock w = lock.writeLock();
|
||||
w.lock();
|
||||
try {
|
||||
this.newsMessages.clear();
|
||||
this.newsMessages.addAll(updatedMessages);
|
||||
this.statsMessage = updatedStats;
|
||||
} finally {
|
||||
lock.writeLock().unlock();
|
||||
w.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue