mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-02 12:30:31 +00:00
Share the "blocked-on file descriptor" number between read() and write().
A process can't be reading and writing at the same time, so it's fine for them to share the variable for the blocked FD.
This commit is contained in:
parent
f6e27c2abe
commit
4bc87dc7b9
Notes:
sideshowbarker
2024-07-19 16:09:05 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/4bc87dc7b99
3 changed files with 3 additions and 4 deletions
|
@ -1055,7 +1055,7 @@ ssize_t Process::sys$read(int fd, void* outbuf, size_t nread)
|
|||
return -EBADF;
|
||||
if (descriptor->is_blocking()) {
|
||||
if (!descriptor->has_data_available_for_reading()) {
|
||||
m_fdBlockedOnRead = fd;
|
||||
m_blocked_fd = fd;
|
||||
block(BlockedRead);
|
||||
sched_yield();
|
||||
if (m_was_interrupted_while_blocked)
|
||||
|
|
|
@ -266,7 +266,6 @@ private:
|
|||
void* m_kernelStack { nullptr };
|
||||
dword m_timesScheduled { 0 };
|
||||
pid_t m_waitee_pid { -1 };
|
||||
int m_fdBlockedOnRead { -1 };
|
||||
int m_blocked_fd { -1 };
|
||||
size_t m_max_open_file_descriptors { 16 };
|
||||
SignalActionData m_signal_action_data[32];
|
||||
|
|
|
@ -49,9 +49,9 @@ bool Scheduler::pick_next()
|
|||
}
|
||||
|
||||
if (process.state() == Process::BlockedRead) {
|
||||
ASSERT(process.m_fdBlockedOnRead != -1);
|
||||
ASSERT(process.m_blocked_fd != -1);
|
||||
// FIXME: Block until the amount of data wanted is available.
|
||||
if (process.m_fds[process.m_fdBlockedOnRead].descriptor->has_data_available_for_reading())
|
||||
if (process.m_fds[process.m_blocked_fd].descriptor->has_data_available_for_reading())
|
||||
process.unblock();
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue