]
Bela Ban resolved JGRP-536.
---------------------------
Resolution: Done
fixed in FC and SFC
Catching InterruptedException and setting interrupt bit in a loop
might cause infinite loop
-------------------------------------------------------------------------------------------
Key: JGRP-536
URL:
http://jira.jboss.com/jira/browse/JGRP-536
Project: JGroups
Issue Type: Bug
Reporter: Bela Ban
Assigned To: Bela Ban
Fix For: 2.5
FC.handleDownMessage() has the following code:
while(length > lowest_credit && running) {
try {
boolean rc=credits_available.await(max_block_time,
TimeUnit.MILLISECONDS);
if(rc || length <= lowest_credit || !running)
break;
long wait_time=System.currentTimeMillis() -
last_credit_request;
if(wait_time >= max_block_time) {
// we have to set this var now, because we release the
lock below (for sending a
// credit request), so all blocked threads would send a
credit request, leading to
// a credit request storm
last_credit_request=System.currentTimeMillis();
// we need to send the credit requests down *without*
holding the sent_lock, otherwise we might
// run into the deadlock described in
http://jira.jboss.com/jira/browse/JGRP-292
Map<Address,Long> sent_copy=new
HashMap<Address,Long>(sent);
sent_copy.keySet().retainAll(creditors);
sent_lock.unlock();
try {
// System.out.println(new Date() + " -->
credit request");
for(Map.Entry<Address,Long> entry:
sent_copy.entrySet()) {
sendCreditRequest(entry.getKey(),
entry.getValue());
}
}
finally {
sent_lock.lock();
}
}
}
catch(InterruptedException e) {
// set the interrupted flag again, so the caller's thread
can handle the interrupt as well
Thread.currentThread().interrupt();
}
}
So if the thread is interrupted, unless
length < lowest_credit || !running,
we will have an infinite loop !
SOLUTION: we cannot set the interrupt flag again, because we *don't* return from the
loop !
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: