Commit 23ec785
committed
Handle Link_download errors in cache
If Link_download fails and returns a negative value, the
background download thread (Cache_bgdl) and the segment reader
(Cache_read_segment) should immediately clean up their allocated
resources (specifically freeing recv_buf), unlock cf->w_lock, and
exit/return appropriately.
This prevents the download path from proceeding with a negative
length value, avoiding potential crashes or undefined behaviors when
writing to the file or using memcpy.
Additionally, propagate segment download errors from Cache_read to
its callers, and log w_lock unlocking in Cache_bgdl and
Cache_read_segment error paths for consistent lock tracing.1 parent 61ef581 commit 23ec785
1 file changed
Lines changed: 17 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
988 | 988 | | |
989 | 989 | | |
990 | 990 | | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
991 | 997 | | |
992 | 998 | | |
993 | 999 | | |
| |||
1089 | 1095 | | |
1090 | 1096 | | |
1091 | 1097 | | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
1092 | 1103 | | |
1093 | 1104 | | |
1094 | 1105 | | |
| |||
1157 | 1168 | | |
1158 | 1169 | | |
1159 | 1170 | | |
1160 | | - | |
1161 | | - | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
1162 | 1177 | | |
1163 | 1178 | | |
1164 | 1179 | | |
0 commit comments