Commit 3e71995
committed
polycubed: fix packet out deadlock when attaching transparent cubes
A dead lock is possible when a transparent cube is added to a port
and there is a packetout operation at the same time.
If port1 and port2 are connected, a packetout operation is going
on port1 and a cube is attached to port2
Thread1: | Thread2:
port1->send_packet_out() | port2->add_cube()
lock(port1) | lock(port2)
... | ...
port2->get_index() | port1->set_next_index()
lock(port2) | lock(port1)
The main cause of this is that send_packet_out() uses get_index() that
internally uses a lock. This commit modifies get_index() so it doesn't
require to lock but returns a variable that is calculated before.
Signed-off-by: Mauricio Vasquez B <mauriciovasquezbernal@gmail.com>1 parent b64e0fa commit 3e71995
2 files changed
Lines changed: 7 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
53 | | - | |
| 52 | + | |
54 | 53 | | |
55 | 54 | | |
56 | | - | |
| 55 | + | |
57 | 56 | | |
58 | 57 | | |
59 | 58 | | |
| |||
230 | 229 | | |
231 | 230 | | |
232 | 231 | | |
| 232 | + | |
| 233 | + | |
233 | 234 | | |
234 | 235 | | |
235 | | - | |
| 236 | + | |
236 | 237 | | |
237 | 238 | | |
238 | 239 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
103 | | - | |
| 103 | + | |
| 104 | + | |
104 | 105 | | |
105 | 106 | | |
106 | 107 | | |
| |||
0 commit comments