summaryrefslogtreecommitdiff
path: root/Kernel/Net/Socket.h
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-01-26 17:54:23 +0100
committerAndreas Kling <kling@serenityos.org>2020-01-26 17:54:23 +0100
commit137a45dff2a6c60dbca34ee6b1e27ff476fe9b40 (patch)
tree49e38ba4b9d8938a34ef7a38bd0e856077bcd5f8 /Kernel/Net/Socket.h
parentd1721c761e3dce78ceb27aaaba2ad7836e669306 (diff)
downloadserenity-137a45dff2a6c60dbca34ee6b1e27ff476fe9b40.zip
Kernel: read()/write() should respect timeouts when used on a sockets
Move timeout management to the ReadBlocker and WriteBlocker classes. Also get rid of the specialized ReceiveBlocker since it no longer does anything that ReadBlocker can't do.
Diffstat (limited to 'Kernel/Net/Socket.h')
-rw-r--r--Kernel/Net/Socket.h16
1 files changed, 7 insertions, 9 deletions
diff --git a/Kernel/Net/Socket.h b/Kernel/Net/Socket.h
index 68f076ccef..aa794dadd2 100644
--- a/Kernel/Net/Socket.h
+++ b/Kernel/Net/Socket.h
@@ -112,9 +112,6 @@ public:
uid_t acceptor_uid() const { return m_acceptor.uid; }
gid_t acceptor_gid() const { return m_acceptor.gid; }
- timeval receive_deadline() const { return m_receive_deadline; }
- timeval send_deadline() const { return m_send_deadline; }
-
Lock& lock() { return m_lock; }
// ^File
@@ -122,14 +119,18 @@ public:
virtual ssize_t write(FileDescription&, const u8*, ssize_t) override final;
virtual String absolute_path(const FileDescription&) const override = 0;
+
+ bool has_receive_timeout() const { return m_receive_timeout.tv_sec || m_receive_timeout.tv_usec; }
+ const timeval& receive_timeout() const { return m_receive_timeout; }
+
+ bool has_send_timeout() const { return m_send_timeout.tv_sec || m_send_timeout.tv_usec; }
+ const timeval& send_timeout() const { return m_send_timeout; }
+
protected:
Socket(int domain, int type, int protocol);
KResult queue_connection_from(NonnullRefPtr<Socket>);
- void load_receive_deadline();
- void load_send_deadline();
-
int backlog() const { return m_backlog; }
void set_backlog(int backlog) { m_backlog = backlog; }
@@ -156,9 +157,6 @@ private:
timeval m_receive_timeout { 0, 0 };
timeval m_send_timeout { 0, 0 };
- timeval m_receive_deadline { 0, 0 };
- timeval m_send_deadline { 0, 0 };
-
NonnullRefPtrVector<Socket> m_pending;
};