Skip to content

Commit

Permalink
UNICAST3/NAKACK2: synchronization around avg_batch_size
Browse files Browse the repository at this point in the history
  • Loading branch information
belaban committed Sep 2, 2024
1 parent f322e34 commit 5e2b14c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/org/jgroups/protocols/UNICAST3.java
Original file line number Diff line number Diff line change
Expand Up @@ -1164,8 +1164,11 @@ protected void deliverBatch(MessageBatch batch) {
sb.append(" (" + batch.size()).append(" messages)");
log.trace(sb);
}
if(stats)
avg_delivery_batch_size.add(batch.size());
if(stats) {
synchronized(avg_delivery_batch_size) { // can be accessed by different threads concurrently
avg_delivery_batch_size.add(batch.size());
}
}
up_prot.up(batch);
}
catch(Throwable t) {
Expand Down
8 changes: 6 additions & 2 deletions src/org/jgroups/protocols/pbcast/NAKACK2.java
Original file line number Diff line number Diff line change
Expand Up @@ -905,8 +905,12 @@ protected void removeAndDeliver(Table<Message> buf, Address sender, boolean loop
}
int size=batch.size();
if(size > 0) {
if(stats)
avg_batch_size.add(size);
if(stats) {
synchronized(avg_batch_size) {
// accessed by multiple threads concurrently
avg_batch_size.add(size);
}
}
deliverBatch(batch);
}
}
Expand Down

0 comments on commit 5e2b14c

Please sign in to comment.