Skip to content

Commit

Permalink
GroupRequest: moved checkCompletion() into lock scope (https://issues…
Browse files Browse the repository at this point in the history
  • Loading branch information
belaban committed Mar 15, 2016
1 parent 51bb6e1 commit 47530ce
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
19 changes: 7 additions & 12 deletions src/org/jgroups/blocks/GroupRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,23 +134,21 @@ public void suspect(Address suspected_member) {

boolean changed=false;
Rsp<T> rsp=requests.get(suspected_member);
if(rsp != null) {
if(rsp != null) {
if(rsp.setSuspected()) {
changed=true;
lock.lock();
try {
if(!(rsp.wasReceived() || rsp.wasUnreachable()))
num_received++;
cond.signal(true);
checkCompletion(this);
}
finally {
lock.unlock();
}
}
}

if(changed)
checkCompletion(this);
}

public void siteUnreachable(String site) {
Expand All @@ -171,15 +169,13 @@ public void siteUnreachable(String site) {
if(!(rsp.wasReceived() || rsp.wasSuspected()))
num_received++;
cond.signal(true);
checkCompletion(this);
}
finally {
lock.unlock();
}
}
}

if(changed)
checkCompletion(this);
}
}
}
Expand Down Expand Up @@ -225,14 +221,14 @@ public void viewChange(View new_view) {
}
}
}
if(changed)
if(changed) {
cond.signal(true);
checkCompletion(this);
}
}
finally {
lock.unlock();
}
if(changed)
checkCompletion(this);
}

/** Marks all responses with an exception (unless a response was already marked as done) */
Expand All @@ -251,13 +247,12 @@ public void transportClosed() {
}
if(changed) {
cond.signal(true);
checkCompletion(this);
}
}
finally {
lock.unlock();
}
if(changed)
checkCompletion(this);
}

/* -------------------- End of Interface RspCollector ----------------------------------- */
Expand Down
11 changes: 5 additions & 6 deletions src/org/jgroups/blocks/UnicastRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ public void receiveResponse(Object response_value, Address sender, boolean is_ex
done=responsesComplete() || (rsp_filter != null && !rsp_filter.needMoreResponses());
if(done && corr != null && this.req_id > 0)
corr.done(this.req_id);
checkCompletion(this);
}
finally {
cond.signal(true); // wakes up execute()
lock.unlock();
}
checkCompletion(this);
}

public boolean responseReceived() {return num_received >= 1;}
Expand All @@ -98,11 +98,11 @@ public void suspect(Address suspected_member) {
if(corr != null && this.req_id > 0)
corr.done(this.req_id);
cond.signal(true);
checkCompletion(this);
}
finally {
lock.unlock();
}
checkCompletion(this);
}

public void siteUnreachable(String site) {
Expand All @@ -122,11 +122,11 @@ public void siteUnreachable(String site) {
if(corr != null && this.req_id > 0)
corr.done(this.req_id);
cond.signal(true);
checkCompletion(this);
}
finally {
lock.unlock();
}
checkCompletion(this);
}

/**
Expand All @@ -147,13 +147,12 @@ public void viewChange(View new_view) {
if(corr != null && this.req_id > 0)
corr.done(this.req_id);
cond.signal(true);
checkCompletion(this);
}
}
finally {
lock.unlock();
}

checkCompletion(this);
}

public void transportClosed() {
Expand All @@ -167,11 +166,11 @@ public void transportClosed() {
if(corr != null && this.req_id > 0)
corr.done(this.req_id);
cond.signal(true);
checkCompletion(this);
}
finally {
lock.unlock();
}
checkCompletion(this);
}

/* -------------------- End of Interface RspCollector ----------------------------------- */
Expand Down

0 comments on commit 47530ce

Please sign in to comment.