[*] Win32 Shell Opener: do the main operation outside of the lock

[*] Linux IO / AuAsync: always use AU_CO_ROUTINE_SUS_NEVER or bool(false). Fixed dropped IO callbacks.
[*] Linux: Added POLLHUP to the blocking read poll. We shouldn't need this. Sockets and pipes set their read side on relevant events. For instance, async connect results in a writable signal, dropped sockets will become signaled under a select, etc. IPC works. Net works. Just gonna add this to the read trigger just in case.
This commit is contained in:
Reece Wilson 2024-10-16 14:45:07 +01:00
parent 7a0593adeb
commit a2322470b8
3 changed files with 24 additions and 14 deletions

View File

@ -746,12 +746,12 @@ namespace std
void set_exception(exception_ptr const &) noexcept void set_exception(exception_ptr const &) noexcept
{ } { }
AU_CO_ROUTINE_SUS_ALWAYS initial_suspend() noexcept AU_CO_ROUTINE_SUS_NEVER initial_suspend() noexcept
{ {
return {}; return {};
} }
AU_CO_ROUTINE_SUS_ALWAYS final_suspend() noexcept AU_CO_ROUTINE_SUS_NEVER final_suspend() noexcept
{ {
return {}; return {};
} }
@ -775,12 +775,12 @@ namespace std
void set_exception(exception_ptr const &) noexcept void set_exception(exception_ptr const &) noexcept
{ } { }
AU_CO_ROUTINE_SUS_ALWAYS initial_suspend() noexcept AU_CO_ROUTINE_SUS_NEVER initial_suspend() noexcept
{ {
return {}; return {};
} }
AU_CO_ROUTINE_SUS_ALWAYS final_suspend() noexcept AU_CO_ROUTINE_SUS_NEVER final_suspend() noexcept
{ {
return {}; return {};
} }
@ -804,12 +804,12 @@ struct AuVoidTask
return {}; return {};
} }
AU_CO_ROUTINE_SUS_ALWAYS initial_suspend() AU_CO_ROUTINE_SUS_NEVER initial_suspend()
{ {
return {}; return {};
} }
AU_CO_ROUTINE_SUS_ALWAYS final_suspend() noexcept AU_CO_ROUTINE_SUS_NEVER final_suspend() noexcept
{ {
return {}; return {};
} }

View File

@ -515,7 +515,7 @@ namespace Aurora::IO::UNIX
submit.aio_reqprio = 0; submit.aio_reqprio = 0;
submit.aio_fildes = context->GetOrCreateFdPollForBlockingRead(fd); submit.aio_fildes = context->GetOrCreateFdPollForBlockingRead(fd);
submit.aio_offset = 0; submit.aio_offset = 0;
submit.aio_buf = POLLIN; submit.aio_buf = POLLIN | POLLHUP;
submit.aio_nbytes = 0; submit.aio_nbytes = 0;
if (submit.aio_fildes == -1) if (submit.aio_fildes == -1)

View File

@ -1,5 +1,5 @@
/*** /***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved. Copyright (C) 2021 Jamie Reece Wilson (a/k/a "Reece"). All rights reserved.
File: AuOpen.Win32.cpp File: AuOpen.Win32.cpp
Date: 2021-6-12 Date: 2021-6-12
@ -28,8 +28,10 @@ namespace Aurora::Processes
{ {
try try
{ {
for (const auto &[uri, type] : gOpenItems) while (gOpenItems.size())
{ {
auto &[uri, type] = gOpenItems[0];
bool bDirExists {}; bool bDirExists {};
bool bFileExists {}; bool bFileExists {};
@ -75,21 +77,29 @@ namespace Aurora::Processes
} }
} }
auto u16OpenURI = Locale::ConvertFromUTF8(uri);
auto pOpenType = bDirExists ? L"explore" : L"open";
gCondMutex->Unlock();
pShellExecuteW(nullptr, pShellExecuteW(nullptr,
bDirExists ? L"explore" : L"open", pOpenType,
Locale::ConvertFromUTF8(uri).c_str(), u16OpenURI.c_str(),
nullptr, nullptr,
nullptr, nullptr,
SW_SHOWNORMAL); SW_SHOWNORMAL);
gCondMutex->Lock();
// Move all N-1 elements for each N, vs clearing later (requires lock?), vs making a copy of the work (requires another alloc?).
// We can just do ShellExecuteW outside of the lock, and access a locally owned U16-translated string container, without bothering the write side mutex or mutable work container.
// A work queue buffer could solve this, but eh.
gOpenItems.erase(gOpenItems.begin());
} }
gOpenItems.clear();
gCondVariable->WaitForSignal(); gCondVariable->WaitForSignal();
} }
catch (...) catch (...)
{ {
Debug::PrintError(); SysPushErrorCatch("An error occurred while dispatching a ShellExecute runner frame");
AuLogWarn("An error occurred while dispatching a ShellExecute runner frame");
} }
} }
} }