mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:37:37 +00:00
Kernel: Allow File::close() to fail
And pass the result through to sys$close() return value. Fixes https://github.com/SerenityOS/serenity/issues/427
This commit is contained in:
parent
d4ddb0013c
commit
1b4e88fb59
12 changed files with 23 additions and 15 deletions
|
@ -564,9 +564,10 @@ int IPv4Socket::ioctl(FileDescription&, unsigned request, FlatPtr arg)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
void IPv4Socket::close()
|
||||
KResult IPv4Socket::close()
|
||||
{
|
||||
shutdown(SHUT_RDWR);
|
||||
(void)shutdown(SHUT_RDWR);
|
||||
return KSuccess;
|
||||
}
|
||||
|
||||
void IPv4Socket::shut_down_for_reading()
|
||||
|
|
|
@ -48,7 +48,7 @@ public:
|
|||
|
||||
static Lockable<HashTable<IPv4Socket*>>& all_sockets();
|
||||
|
||||
virtual void close() override;
|
||||
virtual KResult close() override;
|
||||
virtual KResult bind(const sockaddr*, socklen_t) override;
|
||||
virtual KResult connect(FileDescription&, const sockaddr*, socklen_t, ShouldBlock = ShouldBlock::Yes) override;
|
||||
virtual KResult listen(size_t) override;
|
||||
|
|
|
@ -440,9 +440,9 @@ void TCPSocket::shut_down_for_writing()
|
|||
}
|
||||
}
|
||||
|
||||
void TCPSocket::close()
|
||||
KResult TCPSocket::close()
|
||||
{
|
||||
IPv4Socket::close();
|
||||
auto result = IPv4Socket::close();
|
||||
if (state() == State::CloseWait) {
|
||||
#ifdef TCP_SOCKET_DEBUG
|
||||
dbg() << " Sending FIN from CloseWait and moving into LastAck";
|
||||
|
@ -453,6 +453,7 @@ void TCPSocket::close()
|
|||
|
||||
LOCKER(closing_sockets().lock());
|
||||
closing_sockets().resource().set(tuple(), *this);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -165,7 +165,7 @@ public:
|
|||
void release_to_originator();
|
||||
void release_for_accept(RefPtr<TCPSocket>);
|
||||
|
||||
virtual void close() override;
|
||||
virtual KResult close() override;
|
||||
|
||||
protected:
|
||||
void set_direction(Direction direction) { m_direction = direction; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue