From 3a221c1f3a413103a32aea71451ab7cd82222edf Mon Sep 17 00:00:00 2001
From: Sergei Reznikov <diver@gelios.net>
Date: Thu, 3 Jan 2019 11:47:05 +0300
Subject: Fix build on Haiku


diff --git a/src/net/socket_fd.cc b/src/net/socket_fd.cc
old mode 100755
new mode 100644
index 54cb6de..fba9d7c
--- a/src/net/socket_fd.cc
+++ b/src/net/socket_fd.cc
@@ -70,9 +70,11 @@ SocketFd::set_priority(priority_type p) {
   check_valid();
   int opt = p;
 
+#ifndef __HAIKU__
   if (m_ipv6_socket)
     return setsockopt(m_fd, IPPROTO_IPV6, IPV6_TCLASS, &opt, sizeof(opt)) == 0;
   else
+#endif
     return setsockopt(m_fd, IPPROTO_IP, IP_TOS, &opt, sizeof(opt)) == 0;
 }
 
-- 
2.19.1


From 6ca0922b9b43d10199357c1e4a97506431452ad5 Mon Sep 17 00:00:00 2001
From: Sergei Reznikov <diver@gelios.net>
Date: Mon, 4 Mar 2019 15:51:53 +0300
Subject: Workaround a bug "rtorrent: Could not allocate socket for listening."

https://github.com/rakshasa/rtorrent/issues/820#issuecomment-455900997

diff --git a/src/net/socket_fd.cc b/src/net/socket_fd.cc
index fba9d7c..725e76e 100644
--- a/src/net/socket_fd.cc
+++ b/src/net/socket_fd.cc
@@ -128,40 +128,14 @@ SocketFd::get_error() const {
 
 bool
 SocketFd::open_stream() {
-  m_fd = socket(rak::socket_address::pf_inet6, SOCK_STREAM, IPPROTO_TCP);
-
-  if (m_fd == -1) {
-    m_ipv6_socket = false;
-    return (m_fd = socket(rak::socket_address::pf_inet, SOCK_STREAM, IPPROTO_TCP)) != -1;
-  }
-
-  m_ipv6_socket = true;
-
-  if (!set_ipv6_v6only(false)) {
-    close();
-    return false;
-  }
-
-  return true;
+  m_ipv6_socket = false;
+  return (m_fd = socket(rak::socket_address::pf_inet, SOCK_STREAM, IPPROTO_TCP)) != -1;
 }
 
 bool
 SocketFd::open_datagram() {
-  m_fd = socket(rak::socket_address::pf_inet6, SOCK_DGRAM, 0);
-
-  if (m_fd == -1) {
-    m_ipv6_socket = false;
-    return (m_fd = socket(rak::socket_address::pf_inet, SOCK_DGRAM, 0)) != -1;
-  }
-
-  m_ipv6_socket = true;
-
-  if (!set_ipv6_v6only(false)) {
-    close();
-    return false;
-  }
-
-  return true;
+  m_ipv6_socket = false;
+  return (m_fd = socket(rak::socket_address::pf_inet, SOCK_DGRAM, 0)) != -1;
 }
 
 bool
-- 
2.19.1

