The old loop could actually never be executed more than one iteration.
A real good implementation would check whether any of the peers has exited,
but it would involve much more work.
LOCK: {
lock $locks_up[$id];
- for (1 .. 100) {
- my $timeout = time() + 2;
- until ($locks_up[$id] == $peers) {
- if (cond_timedwait $locks_up[$id], $timeout) {
- last LOCK;
- } else {
- return 0;
- }
+ my $timeout = time() + 10;
+ until ($locks_up[$id] == $peers) {
+ if (cond_timedwait $locks_up[$id], $timeout) {
+ last LOCK;
+ } else {
+ return 0;
}
}
}