Commit d3e4661
fix: Prevent deadlock in loadListing unlock/relock pattern (#43)
* fix: Prevent deadlock in loadListing unlock/relock pattern
This fixes potential deadlocks in the loadListing() function where
unlock/relock patterns could cause circular lock dependencies.
The deadlock could occur in two places:
1. When calling slurpOnce() at line 718-725
2. When calling listObjectsFlat() at line 737-742
Both cases released parent.mu (and dh.mu in case 1) while other
goroutines could be holding different locks and waiting, creating
circular dependencies.
The solution uses the generation counter approach from PR #39:
- Check generation before unlocking
- After relocking, detect if generation changed
- If changed, reset directory handle position
This ensures proper synchronization without risking deadlocks.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>1 parent 97e8dc9 commit d3e4661
1 file changed
+22
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
716 | 716 | | |
717 | 717 | | |
718 | 718 | | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
719 | 722 | | |
720 | 723 | | |
721 | 724 | | |
722 | 725 | | |
723 | 726 | | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
724 | 734 | | |
725 | 735 | | |
726 | 736 | | |
| |||
734 | 744 | | |
735 | 745 | | |
736 | 746 | | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
737 | 750 | | |
738 | 751 | | |
739 | 752 | | |
740 | 753 | | |
741 | 754 | | |
742 | 755 | | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
743 | 765 | | |
744 | 766 | | |
745 | 767 | | |
| |||
0 commit comments