Skip to content

Commit 9ccb2a7

Browse files
committed
#51 adding the required synchronization
1 parent 518e7e0 commit 9ccb2a7

2 files changed

Lines changed: 10 additions & 9 deletions

File tree

pvAccessJava/src/org/epics/pvaccess/server/impl/remote/ServerChannelImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public Destroyable getRequest(int id) {
158158

159159
}
160160

161-
public Destroyable[] getRequests() {
161+
public synchronized Destroyable[] getRequests() {
162162

163163
Destroyable[] reqs = new Destroyable[requests.size()];
164164
requests.values().toArray(reqs);

pvAccessJava/src/org/epics/pvaccess/server/impl/remote/tcp/NonBlockingServerTCPTransport.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,13 @@ private void destroyAllChannels() {
108108

109109
context.getLogger().fine("Transport to " + socketAddress + " still has " + channels.size() + " channel(s) active and closing...");
110110

111-
112-
for(ServerChannel serverChannel : channels.values()) {
113-
serverChannel.destroy();
114-
}
115-
116-
channels.clear();
111+
synchronized (channels) {
112+
for (ServerChannel serverChannel : channels.values()) {
113+
serverChannel.destroy();
114+
}
115+
116+
channels.clear();
117+
}
117118
}
118119

119120
/**
@@ -122,13 +123,13 @@ private void destroyAllChannels() {
122123
*/
123124
public int preallocateChannelSID()
124125
{
125-
126+
synchronized (channels) {
126127
// search first free (theoretically possible loop of death)
127128
int sid = lastChannelSID.incrementAndGet();
128129
while (channels.containsKey(sid))
129130
sid = lastChannelSID.incrementAndGet();
130131
return sid;
131-
132+
}
132133
}
133134

134135
/**

0 commit comments

Comments
 (0)