Skip to content

Commit 2ee6741

Browse files
committed
Fix Orchid deadlock 3
subgraph/Orchid#10
1 parent 0464aa7 commit 2ee6741

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

orchid/src/com/subgraph/orchid/connections/ConnectionImpl.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -289,29 +289,33 @@ private void processCell(Cell cell) {
289289
}
290290

291291
private void processRelayCell(Cell cell) {
292+
Circuit circuit;
292293
circuitsLock.lock();
293294
try {
294-
final Circuit circuit = circuitMap.get(cell.getCircuitId());
295+
circuit = circuitMap.get(cell.getCircuitId());
295296
if(circuit == null) {
296297
logger.warning("Could not deliver relay cell for circuit id = "+ cell.getCircuitId() +" on connection "+ this +". Circuit not found");
297298
return;
298299
}
299-
circuit.deliverRelayCell(cell);
300300
} finally {
301301
circuitsLock.unlock();
302302
}
303+
304+
circuit.deliverRelayCell(cell);
303305
}
304306

305307
private void processControlCell(Cell cell) {
308+
Circuit circuit;
306309
circuitsLock.lock();
307310
try {
308-
final Circuit circuit = circuitMap.get(cell.getCircuitId());
309-
if(circuit != null) {
310-
circuit.deliverControlCell(cell);
311-
}
311+
circuit = circuitMap.get(cell.getCircuitId());
312312
} finally {
313313
circuitsLock.unlock();
314314
}
315+
316+
if(circuit != null) {
317+
circuit.deliverControlCell(cell);
318+
}
315319
}
316320

317321
void idleCloseCheck() {

0 commit comments

Comments
 (0)