From b4023a19dd7ec7a099d2e0df491547cf3bb6bec3 Mon Sep 17 00:00:00 2001 From: Benjamin Fleischer Date: Fri, 20 Jan 2012 09:22:54 +0100 Subject: Apply modified sshfs 2.2 patch from MacFUSE Based on Amit Singh's work at http://code.google.com/p/macfuse/ --- sshnodelay.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'sshnodelay.c') diff --git a/sshnodelay.c b/sshnodelay.c index 7518089..e1d9220 100644 --- a/sshnodelay.c +++ b/sshnodelay.c @@ -5,6 +5,32 @@ #include #include +#if __APPLE__ + +int custom_connect(int sock, const struct sockaddr *addr, socklen_t addrlen); + +typedef struct interpose_s { + void *new_func; + void *orig_func; +} interpose_t; + +static const interpose_t interposers[] \ + __attribute__ ((section("__DATA, __interpose"))) = { + { (void *)custom_connect, (void *)connect }, +}; + +int custom_connect(int sock, const struct sockaddr *addr, socklen_t addrlen) +{ + int res = connect(sock, addr, addrlen); + if (!res && addr->sa_family == AF_INET) { + int opt = 1; + setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, &opt, sizeof(opt)); + } + return res; +} + +#else /* !__APPLE__ */ + int connect(int sock, const struct sockaddr *addr, socklen_t addrlen) { int (*next_connect)(int, const struct sockaddr *, socklen_t) = @@ -16,3 +42,5 @@ int connect(int sock, const struct sockaddr *addr, socklen_t addrlen) } return res; } + +#endif /* !__APPLE__ */ -- cgit v1.2.3