Commit 44a336a
committed
fix(imc): make frame timestamp cache thread-local and fix has_pending race
Convert g_FrameTimestampNs from a global variable to thread_local storage
to prevent timestamp leakage across threads in multi-threaded publish
scenarios.
Use atomic exchange for has_pending flag in Pump() to eliminate the race
between checking and clearing. Set has_pending after successful enqueue
in both backpressure paths and re-check queue after drain to handle
concurrent publishes correctly.
Add test to verify frame timestamp cache isolation between threads.1 parent 810f0e4 commit 44a336a
3 files changed
Lines changed: 58 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
212 | 212 | | |
213 | 213 | | |
214 | 214 | | |
| 215 | + | |
215 | 216 | | |
216 | 217 | | |
217 | 218 | | |
| |||
230 | 231 | | |
231 | 232 | | |
232 | 233 | | |
| 234 | + | |
233 | 235 | | |
234 | 236 | | |
235 | 237 | | |
| |||
915 | 917 | | |
916 | 918 | | |
917 | 919 | | |
918 | | - | |
| 920 | + | |
919 | 921 | | |
920 | 922 | | |
921 | | - | |
| 923 | + | |
| 924 | + | |
922 | 925 | | |
923 | 926 | | |
924 | 927 | | |
925 | 928 | | |
926 | 929 | | |
927 | 930 | | |
928 | | - | |
| 931 | + | |
929 | 932 | | |
930 | 933 | | |
931 | 934 | | |
932 | 935 | | |
933 | 936 | | |
934 | 937 | | |
935 | 938 | | |
936 | | - | |
| 939 | + | |
937 | 940 | | |
938 | | - | |
939 | 941 | | |
940 | 942 | | |
941 | 943 | | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
942 | 947 | | |
943 | 948 | | |
944 | 949 | | |
| |||
952 | 957 | | |
953 | 958 | | |
954 | 959 | | |
955 | | - | |
| 960 | + | |
956 | 961 | | |
957 | 962 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
69 | 75 | | |
70 | 76 | | |
71 | | - | |
| 77 | + | |
| 78 | + | |
72 | 79 | | |
73 | 80 | | |
74 | 81 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
1137 | 1138 | | |
1138 | 1139 | | |
1139 | 1140 | | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
1140 | 1148 | | |
1141 | 1149 | | |
1142 | 1150 | | |
| |||
1146 | 1154 | | |
1147 | 1155 | | |
1148 | 1156 | | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
1149 | 1184 | | |
1150 | 1185 | | |
1151 | 1186 | | |
| |||
0 commit comments