[Pkg-privacy-commits] [torsocks] 04/38: Block, rather than busy-wait, in send/recv_data_impl.
Intrigeri
intrigeri at moszumanska.debian.org
Thu Jun 23 15:18:22 UTC 2016
This is an automated email from the git hooks/post-receive script.
intrigeri pushed a commit to branch experimental/master
in repository torsocks.
commit 6e36f49c5f08cc96b4c8469e245c28c3b58c23bb
Author: Taylor R Campbell <campbell+torsocks at mumble.net>
Date: Wed Jun 17 17:39:02 2015 +0000
Block, rather than busy-wait, in send/recv_data_impl.
---
src/common/socks5.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/src/common/socks5.c b/src/common/socks5.c
index 3f284ca..f56d69c 100644
--- a/src/common/socks5.c
+++ b/src/common/socks5.c
@@ -49,9 +49,13 @@ static ssize_t recv_data_impl(int fd, void *buf, size_t len)
/* Try again after interruption. */
continue;
} else if (errno == EAGAIN || errno == EWOULDBLOCK) {
- if (index) {
- /* Return the number of bytes received up to this point. */
- ret = index;
+ /* Wait for data to become available */
+ fd_set readfds;
+ FD_ZERO(&readfds);
+ FD_SET(fd, &readfds);
+ if (select(fd + 1, &readfds, NULL, NULL, NULL) < 0) {
+ ret = -errno;
+ goto error;
}
continue;
} else if (read_len == 0) {
@@ -102,9 +106,13 @@ static ssize_t send_data_impl(int fd, const void *buf, size_t len)
/* Send again after interruption. */
continue;
} else if (errno == EAGAIN || errno == EWOULDBLOCK) {
- if (index) {
- /* Return the number of bytes sent up to this point. */
- ret = index;
+ /* Wait for buffer space to become available */
+ fd_set writefds;
+ FD_ZERO(&writefds);
+ FD_SET(fd, &writefds);
+ if (select(fd + 1, NULL, &writefds, NULL, NULL) < 0) {
+ ret = -errno;
+ goto error;
}
continue;
} else {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/torsocks.git
More information about the Pkg-privacy-commits
mailing list