chrg6
b8b57cfd53
Take the file lock at the end of a save file call only when a CloseFile is pending, not at the end of every call.
...
The review of the save file use count found that fs_host.c file_release took `lock` exclusive whenever users dropped
to 0, which is the end of every single read_file, write_file, file_size, set_file_size and flush_file, not only when
a CloseFile had marked the slot. The exclusive acquisition waits for every shared holder, such as the fsync loop of a
non-save Commit (commit, FlushFileBuffers under the shared lock), and while it waits it holds up new file_of callers:
a new wait on the guest threads that the change had said it did not add.
file_release now takes the lock only when it finds closing set after its decrement. The decrement and the load of
closing, and close_file's store of closing and load of users, are sequentially consistent pairs, so either the last
call out sees the mark or close_file sees users at 0 and closes the file itself; the check under the lock still keeps
the close to one. closing is an int32_t read and stored with atomics; a slot is emptied by the new file_clear, which
stores users and closing as atomics because the call that has just left the slot may read closing without the lock,
and open_file fills only h, mode and save.
Not reproduced in the game before the change. tests/fs_file_use_check.py gains a case: 1000 reads with no close take
the exclusive lock 0 times, and a read ends while another thread holds the lock shared. It failed on the code before
this change (1000 exclusive takes, the read waited) and passes after it, as do its close-during-a-read case and its
20000 closes and opens beside a reader (six runs, no foreign bytes, no double close). The compile check of fs_host.c
passes with no -Wall warnings.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com >
2026-11-13 18:43:23 -05:00
..
2026-11-11 00:39:50 -05:00
2026-11-13 18:43:23 -05:00
2026-11-13 12:54:24 -05:00
2026-11-13 04:37:01 -05:00
2026-11-13 18:41:39 -05:00
2026-11-11 00:39:50 -05:00
2026-11-10 23:16:17 -05:00
2026-11-07 05:04:38 -05:00
2026-11-07 05:04:38 -05:00
2026-11-12 02:11:46 -05:00
2026-11-10 22:59:02 -05:00
2026-11-09 08:19:19 -05:00
2026-11-07 05:04:40 -05:00
2026-11-07 05:04:40 -05:00
2026-11-13 18:41:46 -05:00
2026-11-07 05:04:40 -05:00
2026-11-07 05:04:40 -05:00
2026-11-13 18:41:46 -05:00
2026-11-13 18:41:46 -05:00
2026-11-12 22:24:22 -05:00
2026-11-13 18:42:10 -05:00
2026-11-13 06:22:18 -05:00
2026-11-13 06:22:18 -05:00
2026-11-13 18:41:46 -05:00
2026-11-13 03:37:26 -05:00
2026-11-13 09:08:40 -05:00
2026-11-13 18:42:34 -05:00
2026-11-13 06:23:01 -05:00
2026-11-13 18:43:23 -05:00
2026-11-07 05:04:38 -05:00
2026-11-07 05:04:40 -05:00
2026-11-13 09:08:40 -05:00
2026-11-13 06:22:18 -05:00
2026-11-08 01:25:12 -05:00
2026-11-09 09:10:36 -05:00
2026-11-13 18:43:23 -05:00
2026-11-13 18:42:10 -05:00
2026-11-07 05:04:38 -05:00
2026-11-09 03:34:46 -05:00
2026-11-12 15:16:30 -05:00
2026-11-13 18:41:39 -05:00
2026-11-13 09:52:43 -05:00
2026-11-13 07:08:49 -05:00
2026-11-13 07:08:49 -05:00
2026-11-07 05:04:40 -05:00
2026-11-09 13:13:43 -05:00
2026-11-09 13:13:43 -05:00
2026-11-11 00:11:41 -05:00
2026-11-13 18:41:39 -05:00
2026-11-13 15:57:52 -05:00
2026-11-13 18:43:23 -05:00
2026-11-13 18:42:10 -05:00
2026-11-11 14:06:16 -05:00
2026-11-12 17:41:47 -05:00
2026-11-13 18:43:23 -05:00
2026-11-13 07:55:56 -05:00
2026-11-13 07:55:56 -05:00
2026-11-13 18:41:45 -05:00
2026-11-07 05:04:38 -05:00
2026-11-11 19:38:18 -05:00
2026-11-13 18:43:23 -05:00
2026-11-07 05:04:38 -05:00
2026-11-13 18:42:34 -05:00
2026-11-10 23:24:12 -05:00
2026-11-13 18:42:34 -05:00
2026-11-13 18:43:23 -05:00
2026-11-07 05:04:40 -05:00
2026-11-09 08:21:07 -05:00
2026-11-09 08:21:07 -05:00
2026-11-09 08:21:07 -05:00
2026-11-13 06:06:27 -05:00
2026-11-13 06:06:27 -05:00
2026-11-10 12:48:50 -05:00
2026-11-13 06:22:18 -05:00
2026-11-09 03:34:46 -05:00
2026-11-07 05:04:38 -05:00
2026-11-09 03:34:46 -05:00
2026-11-07 05:04:38 -05:00
2026-11-07 05:04:38 -05:00
2026-11-13 18:42:10 -05:00
2026-11-13 09:52:43 -05:00
2026-11-13 18:41:46 -05:00
2026-11-13 18:41:46 -05:00
2026-11-09 21:54:40 -05:00
2026-11-10 23:16:17 -05:00
2026-11-13 18:42:34 -05:00
2026-11-09 20:48:10 -05:00
2026-11-11 19:38:18 -05:00
2026-11-13 18:43:23 -05:00
2026-11-13 18:43:23 -05:00
2026-11-13 18:43:23 -05:00
2026-11-13 07:55:56 -05:00
2026-11-13 07:55:56 -05:00
2026-11-13 06:46:31 -05:00
2026-11-11 04:48:36 -05:00
2026-11-13 18:41:40 -05:00
2026-11-11 00:39:08 -05:00
2026-11-07 09:26:51 -05:00
2026-11-10 23:14:00 -05:00
2026-11-08 15:51:48 -05:00
2026-11-07 05:04:40 -05:00
2026-11-12 16:23:02 +01:00
2026-11-12 16:23:02 +01:00
2026-11-11 05:58:43 -05:00
2026-11-11 19:38:17 -05:00
2026-11-11 05:58:32 -05:00
2026-11-08 15:51:48 -05:00
2026-11-09 08:09:25 -05:00
2026-11-08 15:51:48 -05:00
2026-11-07 05:04:40 -05:00
2026-11-12 14:38:26 -05:00
2026-11-12 12:09:37 -05:00
2026-11-11 02:36:54 -05:00
2026-11-11 00:39:58 -05:00
2026-11-07 05:04:40 -05:00
2026-11-07 18:03:20 -05:00
2026-11-07 05:04:38 -05:00
2026-11-07 05:04:38 -05:00
2026-11-13 18:41:46 -05:00
2026-11-13 00:50:21 -05:00
2026-11-13 18:41:39 -05:00
2026-11-13 15:57:52 -05:00
2026-11-12 12:09:36 -05:00
2026-11-07 05:04:40 -05:00
2026-11-12 12:09:36 -05:00
2026-11-07 05:04:40 -05:00
2026-11-11 19:38:17 -05:00
2026-11-07 05:04:39 -05:00
2026-11-07 05:04:39 -05:00
2026-11-11 19:38:18 -05:00
2026-11-11 19:38:18 -05:00
2026-11-11 19:38:18 -05:00
2026-11-07 05:04:38 -05:00
2026-11-09 08:54:25 -05:00
2026-11-08 15:51:48 -05:00
2026-11-07 05:04:38 -05:00
2026-11-10 22:59:02 -05:00
2026-11-07 13:31:07 -05:00
2026-11-13 00:53:22 -05:00
2026-11-07 05:04:40 -05:00
2026-11-13 18:41:46 -05:00
2026-11-07 05:04:40 -05:00
2026-11-09 13:13:43 -05:00
2026-11-09 02:40:51 -05:00
2026-11-12 15:18:25 -05:00
2026-11-09 02:40:51 -05:00
2026-11-13 08:35:42 -05:00
2026-11-13 08:35:42 -05:00
2026-11-12 22:34:22 -05:00
2026-11-13 05:54:58 -05:00
2026-11-13 18:41:39 -05:00
2026-11-13 18:43:23 -05:00
2026-11-10 06:35:28 -05:00
2026-11-10 06:35:28 -05:00
2026-11-13 07:08:49 -05:00
2026-11-13 07:08:49 -05:00
2026-11-13 15:57:51 -05:00
2026-11-13 15:57:51 -05:00
2026-11-11 04:36:33 -05:00
2026-11-07 05:04:38 -05:00
2026-11-12 22:09:37 -05:00
2026-11-07 05:04:38 -05:00
2026-11-07 05:04:38 -05:00
2026-11-07 05:04:40 -05:00
2026-11-13 08:23:11 -05:00
2026-11-13 18:41:39 -05:00
2026-11-13 18:41:39 -05:00
2026-11-12 22:28:36 -05:00
2026-11-12 22:28:36 -05:00
2026-11-10 23:16:17 -05:00
2026-11-10 23:16:17 -05:00
2026-11-13 03:37:26 -05:00
2026-11-09 13:13:43 -05:00
2026-11-09 13:13:43 -05:00
2026-11-09 13:13:43 -05:00
2026-11-07 05:04:38 -05:00
2026-11-07 05:04:38 -05:00
2026-11-07 05:04:40 -05:00
2026-11-12 21:33:21 -05:00
2026-11-12 20:03:45 -05:00
2026-11-12 07:55:57 -05:00
2026-11-12 07:55:57 -05:00
2026-11-13 03:42:40 -05:00
2026-11-12 22:57:56 -05:00
2026-11-13 07:55:56 -05:00
2026-11-13 18:43:23 -05:00
2026-11-13 18:43:23 -05:00
2026-11-13 18:42:10 -05:00
2026-11-07 05:04:38 -05:00
2026-11-07 05:04:38 -05:00
2026-11-07 05:04:40 -05:00
2026-11-07 05:04:38 -05:00
2026-11-13 03:37:26 -05:00
2026-11-07 05:04:38 -05:00
2026-11-12 02:11:46 -05:00
2026-11-12 02:11:46 -05:00
2026-11-13 08:35:42 -05:00
2026-11-12 22:18:14 -05:00
2026-11-13 08:35:42 -05:00
2026-11-13 00:53:22 -05:00
2026-11-13 00:53:22 -05:00
2026-11-13 18:41:39 -05:00
2026-11-13 18:41:39 -05:00
2026-11-07 05:04:38 -05:00
2026-11-13 06:23:01 -05:00
2026-11-13 18:41:40 -05:00
2026-11-13 18:41:39 -05:00
2026-11-11 04:42:07 -05:00
2026-11-11 04:29:31 -05:00
2026-11-12 16:22:15 +01:00
2026-11-09 03:34:46 -05:00
2026-11-12 04:39:12 -05:00
2026-11-13 12:54:24 -05:00
2026-11-13 18:42:10 -05:00
2026-11-13 07:55:56 -05:00
2026-11-13 00:49:30 -05:00
2026-11-13 18:41:39 -05:00
2026-11-13 00:49:30 -05:00
2026-11-13 09:52:43 -05:00
2026-11-13 18:41:40 -05:00
2026-11-13 15:57:52 -05:00
2026-11-11 04:35:30 -05:00
2026-11-13 12:54:24 -05:00
2026-11-13 18:41:40 -05:00
2026-11-13 06:46:31 -05:00
2026-11-11 04:49:01 -05:00
2026-11-13 06:46:31 -05:00
2026-11-13 06:46:31 -05:00
2026-11-13 06:46:31 -05:00
2026-11-13 06:46:31 -05:00
2026-11-12 20:03:59 -05:00
2026-11-12 12:09:37 -05:00
2026-11-13 18:41:39 -05:00
2026-11-13 06:46:31 -05:00
2026-11-07 05:04:40 -05:00
2026-11-13 06:23:01 -05:00
2026-11-12 22:18:14 -05:00
2026-11-12 22:18:14 -05:00
2026-11-13 00:46:26 -05:00
2026-11-13 18:41:39 -05:00
2026-11-13 08:36:46 -05:00
2026-11-13 06:06:27 -05:00
2026-11-12 22:30:56 -05:00
2026-11-13 18:41:40 -05:00
2026-11-13 12:54:24 -05:00
2026-11-13 12:54:24 -05:00
2026-11-13 12:54:24 -05:00
2026-11-07 05:04:38 -05:00
2026-11-13 00:49:30 -05:00
2026-11-07 05:04:38 -05:00
2026-11-13 08:36:46 -05:00
2026-11-13 18:43:23 -05:00
2026-11-12 13:00:13 -05:00
2026-11-11 05:58:42 -05:00
2026-11-11 05:25:38 -05:00
2026-11-12 23:21:17 -05:00
2026-11-13 00:49:30 -05:00
2026-11-13 12:54:24 -05:00
2026-11-13 18:42:34 -05:00
2026-11-10 12:14:29 -05:00
2026-11-12 22:33:29 -05:00
2026-11-13 15:57:52 -05:00
2026-11-13 18:41:45 -05:00
2026-11-13 00:50:21 -05:00
2026-11-13 00:49:30 -05:00
2026-11-13 05:09:47 -05:00
2026-11-07 05:04:38 -05:00
2026-11-10 09:13:35 -05:00
2026-11-13 18:43:23 -05:00
2026-11-10 15:20:47 -05:00
2026-11-13 00:43:03 -05:00