mirror of
https://github.com/neovim/neovim.git
synced 2025-09-29 06:28:35 +00:00
refactor(fs): now it is time to get rid of fs_loop and fs_loop_mutex
Here's the headline: when run in sync mode (last argument cb=NULL), these functions don't actually use the uv_loop_t. An earlier version of this patch instead replaced fs_loop with using main_loop.uv on the main thread and luv_loop() on luv worker threads. However this made the code more complicated for no reason. Also arbitrarily, half of these functions would attempt to handle UV_ENOMEM by try_to_free_memory(). This would mostly happen on windows because it needs to allocate a converted WCHAR buffer. This should be a quite rare situation. Your system is pretty much hosed already if you cannot allocate like 50 WCHAR:s. Therefore, take the liberty of simply removing this fallback. In addition, we tried to "recover" from ENOMEM in read()/readv() this way which doesn't make any sense. The read buffer(s) are already allocated at this point. This would also be an issue when using these functions on a worker thread, as try_to_free_memory() is not thread-safe. Currently os_file_is_readable() and os_is_dir() is used by worker threads (as part of nvim__get_runtime(), to implement require from 'rtp' in threads). In the end, these changes makes _all_ os/fs.c functions thread-safe, and we thus don't need to document and maintain a thread-safe subset.
This commit is contained in:
@@ -266,10 +266,6 @@ int main(int argc, char **argv)
|
||||
// `argc` and `argv` are also copied, so that they can be changed.
|
||||
init_params(¶ms, argc, argv);
|
||||
|
||||
// Since os_open is called during the init_startuptime, we need to call
|
||||
// fs_init before it.
|
||||
fs_init();
|
||||
|
||||
init_startuptime(¶ms);
|
||||
|
||||
// Need to find "--clean" before actually parsing arguments.
|
||||
@@ -1479,7 +1475,7 @@ static void init_startuptime(mparm_T *paramp)
|
||||
{
|
||||
for (int i = 1; i < paramp->argc - 1; i++) {
|
||||
if (STRICMP(paramp->argv[i], "--startuptime") == 0) {
|
||||
time_fd = os_fopen(paramp->argv[i + 1], "a");
|
||||
time_fd = fopen(paramp->argv[i + 1], "a");
|
||||
time_start("--- NVIM STARTING ---");
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user