Commit 5249b87
committed
Fix data race in host infrastructure proxy context map
This commit fixes a data race in the host infrastructure where
proxyContextMap was being accessed concurrently without synchronization.
The race occurred between:
- runEnvoy() writing to the map (line 92)
- Close() reading from the map (line 37)
- stopEnvoy() reading and deleting from the map (lines 125, 129)
Added a sync.RWMutex to protect all accesses to proxyContextMap:
- Use RLock for reads in Close() and CreateOrUpdateProxyInfra()
- Use Lock for writes in runEnvoy() and stopEnvoy()
- Extract map keys before iteration in Close() to avoid holding
the lock while calling stopEnvoy()
This ensures thread-safe access to the proxy context map during
concurrent infrastructure operations.
Signed-off-by: Adrian Cole <[email protected]>1 parent 9155924 commit 5249b87
2 files changed
+24
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| 50 | + | |
| 51 | + | |
49 | 52 | | |
50 | 53 | | |
51 | 54 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
37 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
38 | 45 | | |
39 | 46 | | |
40 | 47 | | |
| |||
53 | 60 | | |
54 | 61 | | |
55 | 62 | | |
56 | | - | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
57 | 67 | | |
58 | 68 | | |
59 | 69 | | |
| |||
89 | 99 | | |
90 | 100 | | |
91 | 101 | | |
| 102 | + | |
92 | 103 | | |
| 104 | + | |
93 | 105 | | |
94 | 106 | | |
95 | 107 | | |
| |||
122 | 134 | | |
123 | 135 | | |
124 | 136 | | |
125 | | - | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
126 | 142 | | |
127 | 143 | | |
128 | 144 | | |
| 145 | + | |
| 146 | + | |
129 | 147 | | |
| 148 | + | |
130 | 149 | | |
131 | 150 | | |
132 | 151 | | |
| |||
0 commit comments