summaryrefslogtreecommitdiff
path: root/src/file.cc
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2016-12-01 20:11:09 +0000
committerMaxime Coste <mawww@kakoune.org>2016-12-01 20:11:09 +0000
commit8c862c4eea636b2d60c360e1fdebc94e2bdfd6d1 (patch)
treeebdfe70be9ec8eaf16490b4d2c6ecc0c7ac9ee07 /src/file.cc
parent95c1528342c83a8ec599b2f49957d840d9695e8f (diff)
Only write to remote socket when we know they are writable
Buffer data (in an horribly innefficient way for now), and use the event manager to watch for the socket being ready for a write. Fixes #945
Diffstat (limited to 'src/file.cc')
-rw-r--r--src/file.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/file.cc b/src/file.cc
index 1455624b..64061d09 100644
--- a/src/file.cc
+++ b/src/file.cc
@@ -143,6 +143,16 @@ bool fd_readable(int fd)
return select(fd+1, &rfds, nullptr, nullptr, &tv) == 1;
}
+bool fd_writable(int fd)
+{
+ fd_set rfds;
+ FD_ZERO(&rfds);
+ FD_SET(fd, &rfds);
+
+ timeval tv{0,0};
+ return select(fd+1, nullptr, &rfds, nullptr, &tv) == 1;
+}
+
String read_fd(int fd, bool text)
{
String content;