diff options
| author | Maxime Coste <mawww@kakoune.org> | 2016-12-01 20:11:09 +0000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2016-12-01 20:11:09 +0000 |
| commit | 8c862c4eea636b2d60c360e1fdebc94e2bdfd6d1 (patch) | |
| tree | ebdfe70be9ec8eaf16490b4d2c6ecc0c7ac9ee07 /src/file.cc | |
| parent | 95c1528342c83a8ec599b2f49957d840d9695e8f (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.cc | 10 |
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; |
