Browse Source

- Handle timeouts from recv(2) properly.

- Increase timeout to 8 seconds (should be made configurable).

Reported by:	Ulrich Spoerlein <uspoerlein@gmail.com>
Reported by:	Christian Laursen <xi@borderworlds.dk>
PR:		kern/104829
MFC after:	1 week
tags/ggatessh-v1.0.0
pjd 18 years ago
parent
commit
186e33abdc
1 changed files with 6 additions and 2 deletions
  1. +6
    -2
      shared/ggate.c

+ 6
- 2
shared/ggate.c View File

@@ -250,8 +250,12 @@ g_gate_send(int s, const void *buf, size_t len, int flags)
ssize_t ssize_t
g_gate_recv(int s, void *buf, size_t len, int flags) g_gate_recv(int s, void *buf, size_t len, int flags)
{ {
ssize_t done;


return (recv(s, buf, len, flags));
do {
done = recv(s, buf, len, flags);
} while (done == -1 && errno == EAGAIN);
return (done);
} }


int nagle = 1; int nagle = 1;
@@ -280,7 +284,7 @@ g_gate_socket_settings(int sfd)
bsize = sndbuf; bsize = sndbuf;
if (setsockopt(sfd, SOL_SOCKET, SO_SNDBUF, &bsize, sizeof(bsize)) == -1) if (setsockopt(sfd, SOL_SOCKET, SO_SNDBUF, &bsize, sizeof(bsize)) == -1)
g_gate_xlog("setsockopt(SO_SNDBUF): %s.", strerror(errno)); g_gate_xlog("setsockopt(SO_SNDBUF): %s.", strerror(errno));
tv.tv_sec = 1;
tv.tv_sec = 8;
tv.tv_usec = 0; tv.tv_usec = 0;
if (setsockopt(sfd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)) == -1) { if (setsockopt(sfd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)) == -1) {
g_gate_log(LOG_ERR, "setsockopt(SO_SNDTIMEO) error: %s.", g_gate_log(LOG_ERR, "setsockopt(SO_SNDTIMEO) error: %s.",


Loading…
Cancel
Save