| ... | @@ -612,8 +612,6 @@ const Os = switch (builtin.os.tag) { | ... | @@ -612,8 +612,6 @@ const Os = switch (builtin.os.tag) { |
| 612 | /// -1. Otherwise, it needs to be opened in update(), and will be | 612 | /// -1. Otherwise, it needs to be opened in update(), and will be |
| 613 | /// stored here. | 613 | /// stored here. |
| 614 | dir_fd: i32, | 614 | dir_fd: i32, |
| 615 | /// Number of files being watched by this directory handle. | | |
| 616 | ref_count: u32, | | |
| 617 | }), | 615 | }), |
| 618 | | 616 | |
| 619 | const dir_open_flags: posix.O = f: { | 617 | const dir_open_flags: posix.O = f: { |
| ... | @@ -673,11 +671,9 @@ const Os = switch (builtin.os.tag) { | ... | @@ -673,11 +671,9 @@ const Os = switch (builtin.os.tag) { |
| 673 | try handles.append(gpa, .{ | 671 | try handles.append(gpa, .{ |
| 674 | .rs = .{}, | 672 | .rs = .{}, |
| 675 | .dir_fd = if (skip_open_dir) -1 else dir_fd, | 673 | .dir_fd = if (skip_open_dir) -1 else dir_fd, |
| 676 | .ref_count = 1, | | |
| 677 | }); | 674 | }); |
| 678 | } else { | | |
| 679 | handles.items(.ref_count)[gop.index] += 1; | | |
| 680 | } | 675 | } |
| | 676 | |
| 681 | break :rs &handles.items(.rs)[gop.index]; | 677 | break :rs &handles.items(.rs)[gop.index]; |
| 682 | }; | 678 | }; |
| 683 | for (files.items) |basename| { | 679 | for (files.items) |basename| { |
| ... | @@ -718,10 +714,6 @@ const Os = switch (builtin.os.tag) { | ... | @@ -718,10 +714,6 @@ const Os = switch (builtin.os.tag) { |
| 718 | } | 714 | } |
| 719 | } | 715 | } |
| 720 | | 716 | |
| 721 | const ref_count_ptr = &handles.items(.ref_count)[i]; | | |
| 722 | ref_count_ptr.* -= 1; | | |
| 723 | if (ref_count_ptr.* > 0) continue; | | |
| 724 | | | |
| 725 | // If the sub_path == "" then this patch has already the | 717 | // If the sub_path == "" then this patch has already the |
| 726 | // dir fd that we need to use as the ident to remove the | 718 | // dir fd that we need to use as the ident to remove the |
| 727 | // event. If it was opened above with openat() then we need | 719 | // event. If it was opened above with openat() then we need |
| ... | @@ -738,10 +730,10 @@ const Os = switch (builtin.os.tag) { | ... | @@ -738,10 +730,10 @@ const Os = switch (builtin.os.tag) { |
| 738 | // index in the udata field. | 730 | // index in the udata field. |
| 739 | const last_dir_fd = fd: { | 731 | const last_dir_fd = fd: { |
| 740 | const last_path = w.dir_table.keys()[handles.len - 1]; | 732 | const last_path = w.dir_table.keys()[handles.len - 1]; |
| 741 | const last_dir_fd = if (last_path.sub_path.len != 0) | 733 | const last_dir_fd = if (last_path.sub_path.len == 0) |
| 742 | last_path.root_dir.handle.fd | 734 | last_path.root_dir.handle.fd |
| 743 | else | 735 | else |
| 744 | handles.items(.dir_fd)[i]; | 736 | handles.items(.dir_fd)[handles.len - 1]; |
| 745 | assert(last_dir_fd != -1); | 737 | assert(last_dir_fd != -1); |
| 746 | break :fd last_dir_fd; | 738 | break :fd last_dir_fd; |
| 747 | }; | 739 | }; |