Commit d8d106e
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 2c226bb commit d8d106e
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 | | |
| |||
91 | 101 | | |
92 | 102 | | |
93 | 103 | | |
| 104 | + | |
94 | 105 | | |
| 106 | + | |
95 | 107 | | |
96 | 108 | | |
97 | 109 | | |
| |||
124 | 136 | | |
125 | 137 | | |
126 | 138 | | |
127 | | - | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
128 | 144 | | |
129 | 145 | | |
130 | 146 | | |
| 147 | + | |
| 148 | + | |
131 | 149 | | |
| 150 | + | |
132 | 151 | | |
133 | 152 | | |
134 | 153 | | |
| |||
0 commit comments