Commit 8571175
committed
system/nxpkg: fix concurrency and versioning bugs found in review.
- pkg_sync(): index.jsn and repo.url were updated as two independent
atomic writes with nothing serializing the pair against a second,
concurrent pkg_sync() call - each write stayed internally
consistent, but the pair didn't, so one sync's index could end up on
disk next to a different sync's source URL. Add a dedicated sync
lock (pkg_repo_acquire_sync_lock(), mirroring the existing installed-
db lock's blocking-retry-with-stale-reclaim pattern) around the
whole read-fetch-write sequence. Also renew the lock's mtime as data
actually arrives (pkg_repo_sink(), via a new renew_lock_path field
threaded through pkg_acquire_source()) rather than only stamping it
once at acquire time - a lock acquired once and then measured
against a fixed 10-minute staleness window could otherwise be
reclaimed mid-download on a large-enough file over a slow-enough
link, even though the download was still genuinely in progress.
pkg_reclaim_stale_lock() (renamed from pkg_install_reclaim_stale_lock,
made public) is shared between both lock kinds rather than
duplicated.
- pkg_install_prune_oldest_version(): deleted the pruned version's
on-disk payload directory before the updated installed database was
even durably saved. If pkg_metadata_save_installed() subsequently
failed, the payload was already gone but the last successfully-saved
instpkg.jsn could still list that version as installed. The victim
version is now handed back to the caller (threaded through
pkg_install_add_version()/pkg_install_update_installed()) so
pkg_install() can defer the actual directory removal until after the
save succeeds.
- pkg_metadata_version_token_cmp(): two version tokens with equal
numeric prefixes (e.g. "1a" and "1b", both parsing as 1) compared as
equal instead of falling back to a lexical comparison of what
follows the number, contradicting this function's own documented
behavior and silently treating genuinely different versions as the
same one. Compare the non-numeric remainder lexically when the
numeric prefixes match instead of falling through.
Assisted-by: Claude:claude-sonnet-5
Signed-off-by: aviralgarg05 <gargaviral99@gmail.com>1 parent 455af49 commit 8571175
4 files changed
Lines changed: 246 additions & 70 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
259 | 259 | | |
260 | 260 | | |
261 | 261 | | |
262 | | - | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
263 | 265 | | |
264 | 266 | | |
265 | 267 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | 43 | | |
77 | 44 | | |
78 | 45 | | |
| |||
94 | 61 | | |
95 | 62 | | |
96 | 63 | | |
97 | | - | |
| 64 | + | |
98 | 65 | | |
99 | 66 | | |
100 | 67 | | |
| |||
176 | 143 | | |
177 | 144 | | |
178 | 145 | | |
179 | | - | |
| 146 | + | |
180 | 147 | | |
181 | 148 | | |
182 | 149 | | |
| |||
201 | 168 | | |
202 | 169 | | |
203 | 170 | | |
204 | | - | |
| 171 | + | |
| 172 | + | |
205 | 173 | | |
206 | 174 | | |
207 | 175 | | |
| |||
228 | 196 | | |
229 | 197 | | |
230 | 198 | | |
231 | | - | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
232 | 212 | | |
233 | 213 | | |
234 | 214 | | |
| |||
241 | 221 | | |
242 | 222 | | |
243 | 223 | | |
244 | | - | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
245 | 227 | | |
246 | 228 | | |
247 | 229 | | |
| |||
252 | 234 | | |
253 | 235 | | |
254 | 236 | | |
255 | | - | |
| 237 | + | |
| 238 | + | |
256 | 239 | | |
257 | 240 | | |
258 | 241 | | |
| |||
278 | 261 | | |
279 | 262 | | |
280 | 263 | | |
281 | | - | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
282 | 267 | | |
283 | 268 | | |
284 | 269 | | |
| |||
332 | 317 | | |
333 | 318 | | |
334 | 319 | | |
335 | | - | |
| 320 | + | |
| 321 | + | |
336 | 322 | | |
337 | 323 | | |
338 | 324 | | |
| |||
380 | 366 | | |
381 | 367 | | |
382 | 368 | | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
383 | 405 | | |
384 | 406 | | |
385 | 407 | | |
| |||
393 | 415 | | |
394 | 416 | | |
395 | 417 | | |
| 418 | + | |
396 | 419 | | |
397 | 420 | | |
398 | 421 | | |
399 | 422 | | |
400 | 423 | | |
| 424 | + | |
| 425 | + | |
401 | 426 | | |
402 | 427 | | |
403 | 428 | | |
| |||
525 | 550 | | |
526 | 551 | | |
527 | 552 | | |
528 | | - | |
| 553 | + | |
529 | 554 | | |
530 | 555 | | |
531 | 556 | | |
| |||
667 | 692 | | |
668 | 693 | | |
669 | 694 | | |
670 | | - | |
| 695 | + | |
| 696 | + | |
671 | 697 | | |
672 | 698 | | |
673 | 699 | | |
| |||
681 | 707 | | |
682 | 708 | | |
683 | 709 | | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
684 | 722 | | |
685 | 723 | | |
686 | 724 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
404 | 404 | | |
405 | 405 | | |
406 | 406 | | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
407 | 410 | | |
408 | 411 | | |
409 | 412 | | |
| |||
419 | 422 | | |
420 | 423 | | |
421 | 424 | | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
422 | 438 | | |
423 | 439 | | |
424 | 440 | | |
425 | | - | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
426 | 444 | | |
427 | | - | |
428 | | - | |
429 | | - | |
430 | | - | |
431 | | - | |
432 | | - | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
433 | 451 | | |
434 | | - | |
435 | | - | |
436 | | - | |
437 | | - | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
438 | 455 | | |
439 | 456 | | |
440 | 457 | | |
| |||
0 commit comments