#include <sys/socket.h>
#include <sys/un.h>
#include <arpa/inet.h>
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+
#include <fcntl.h>
#include <errno.h>
#include <pwd.h>
bool sign = readInt(from) == 1;
startWork();
TunnelSink sink(to);
- store->exportPath(path, sign, sink);
+ try {
+ store->exportPath(path, sign, sink);
+ }
+ catch (Error &e) {
+ /* Flush SINK beforehand or its destructor will rightfully trigger
+ an assertion failure. */
+ sink.flush();
+ throw e;
+ }
sink.flush();
stopWork();
writeInt(1, to);
closeOnExec(remote);
+ {
+ int enabled = 1;
+
+ /* If we're on a TCP connection, disable Nagle's algorithm so that
+ data is sent as soon as possible. */
+ (void) setsockopt(remote, SOL_TCP, TCP_NODELAY,
+ &enabled, sizeof enabled);
+
+#if defined(TCP_QUICKACK)
+ /* Enable TCP quick-ack if applicable; this might help a little. */
+ (void) setsockopt(remote, SOL_TCP, TCP_QUICKACK,
+ &enabled, sizeof enabled);
+#endif
+ }
+
pid_t clientPid = -1;
bool trusted = false;
if (remoteAddr.ss_family == AF_INET) {
struct sockaddr_in *addr = (struct sockaddr_in *) &remoteAddr;
- struct in_addr inaddr = { addr->sin_addr };
- result = inet_ntop(AF_INET, &inaddr,
+ result = inet_ntop(AF_INET, &addr->sin_addr,
address_str, sizeof address_str);
} else if (remoteAddr.ss_family == AF_INET6) {
struct sockaddr_in6 *addr = (struct sockaddr_in6 *) &remoteAddr;
- struct in6_addr inaddr = { addr->sin6_addr };
- result = inet_ntop(AF_INET6, &inaddr,
+ result = inet_ntop(AF_INET6, &addr->sin6_addr,
address_str, sizeof address_str);
} else {
result = NULL;