diff --git a/base/message_loop/message_pump_io_starboard.cc b/base/message_loop/message_pump_io_starboard.cc index 8cee057454e3..64709fa51c9d 100644 --- a/base/message_loop/message_pump_io_starboard.cc +++ b/base/message_loop/message_pump_io_starboard.cc @@ -14,7 +14,7 @@ #include "base/message_loop/message_pump_io_starboard.h" -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) #include #include #include @@ -34,7 +34,7 @@ namespace base { MessagePumpIOStarboard::SocketWatcher::SocketWatcher(const Location& from_here) : created_from_location_(from_here), interests_(kSbSocketWaiterInterestNone), -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) socket_(-1), #else socket_(kSbSocketInvalid), @@ -44,7 +44,7 @@ MessagePumpIOStarboard::SocketWatcher::SocketWatcher(const Location& from_here) weak_factory_(this) {} MessagePumpIOStarboard::SocketWatcher::~SocketWatcher() { -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) if (socket_ >= 0) { StopWatchingFileDescriptor(); } @@ -55,7 +55,7 @@ MessagePumpIOStarboard::SocketWatcher::~SocketWatcher() { #endif } -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) bool MessagePumpIOStarboard::SocketWatcher::StopWatchingFileDescriptor() { watcher_ = nullptr; interests_ = kSbSocketWaiterInterestNone; @@ -94,7 +94,7 @@ bool MessagePumpIOStarboard::SocketWatcher::StopWatchingSocket() { } #endif -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) void MessagePumpIOStarboard::SocketWatcher::Init(int socket, bool persistent) { DCHECK(socket >= 0); @@ -109,7 +109,7 @@ void MessagePumpIOStarboard::SocketWatcher::Init(SbSocket socket, persistent_ = persistent; } -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) int MessagePumpIOStarboard::SocketWatcher::Release() { int socket = socket_; socket_ = -1; @@ -123,7 +123,7 @@ SbSocket MessagePumpIOStarboard::SocketWatcher::Release() { } #endif -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) void MessagePumpIOStarboard::SocketWatcher::OnFileCanReadWithoutBlocking( int socket, MessagePumpIOStarboard* pump) { @@ -176,7 +176,7 @@ MessagePumpIOStarboard::~MessagePumpIOStarboard() { SbSocketWaiterDestroy(waiter_); } -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) bool MessagePumpIOStarboard::WatchFileDescriptor(int socket, bool persistent, int mode, @@ -206,7 +206,7 @@ bool MessagePumpIOStarboard::Watch(SbSocket socket, interests |= kSbSocketWaiterInterestWrite; } -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) int old_socket = controller->Release(); if (old_socket >= 0) { #else @@ -229,23 +229,23 @@ bool MessagePumpIOStarboard::Watch(SbSocket socket, interests |= old_interest_mask; // Must disarm the event before we can reuse it. -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) SbPosixSocketWaiterRemove(waiter_, old_socket); #else SbSocketWaiterRemove(waiter_, old_socket); -#endif // SB_API_VERSION >= 16 +#endif // SB_API_VERSION >= 16 && !defined(_MSC_VER) } // Set current interest mask and waiter for this event. bool result = false; -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) result = SbPosixSocketWaiterAdd(waiter_, socket, controller, OnPosixSocketWaiterNotification, interests, persistent); #else result = SbSocketWaiterAdd(waiter_, socket, controller, OnSocketWaiterNotification, interests, persistent); -#endif // SB_API_VERSION >= 16 +#endif // SB_API_VERSION >= 16 && !defined(_MSC_VER) if (result == false) { return false; } @@ -257,7 +257,7 @@ bool MessagePumpIOStarboard::Watch(SbSocket socket, return true; } -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) bool MessagePumpIOStarboard::StopWatchingFileDescriptor(int socket) { return SbPosixSocketWaiterRemove(waiter_, socket); } @@ -265,7 +265,7 @@ bool MessagePumpIOStarboard::StopWatchingFileDescriptor(int socket) { bool MessagePumpIOStarboard::StopWatching(SbSocket socket) { return SbSocketWaiterRemove(waiter_, socket); } -#endif // SB_API_VERSION >= 16 +#endif // SB_API_VERSION >= 16 && !defined(_MSC_VER) void MessagePumpIOStarboard::AddIOObserver(IOObserver* obs) { io_observers_.AddObserver(obs); @@ -358,7 +358,7 @@ void MessagePumpIOStarboard::DidProcessIOEvent() { } } -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) // static void MessagePumpIOStarboard::OnPosixSocketWaiterNotification(SbSocketWaiter waiter, @@ -415,5 +415,5 @@ void MessagePumpIOStarboard::OnSocketWaiterNotification(SbSocketWaiter waiter, } } -#endif // SB_API_VERSION >= 16 +#endif // SB_API_VERSION >= 16 && !defined(_MSC_VER) } // namespace base diff --git a/base/message_loop/message_pump_io_starboard.h b/base/message_loop/message_pump_io_starboard.h index 887cec12f01f..55ce21570e80 100644 --- a/base/message_loop/message_pump_io_starboard.h +++ b/base/message_loop/message_pump_io_starboard.h @@ -51,7 +51,7 @@ class BASE_EXPORT MessagePumpIOStarboard : public MessagePump { public: // These methods are called from MessageLoop::Run when a socket can be // interacted with without blocking. -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) virtual void OnFileCanReadWithoutBlocking(int socket) {} virtual void OnFileCanWriteWithoutBlocking(int socket) {} #else @@ -77,7 +77,7 @@ class BASE_EXPORT MessagePumpIOStarboard : public MessagePump { // Stops watching the socket, always safe to call. No-op if there's nothing // to do. -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) bool StopWatchingFileDescriptor(); #else bool StopWatchingSocket(); @@ -90,7 +90,7 @@ class BASE_EXPORT MessagePumpIOStarboard : public MessagePump { friend class MessagePumpIOStarboardTest; // Called by MessagePumpIOStarboard. -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) void Init(int socket, bool persistent); int Release(); #else @@ -106,7 +106,7 @@ class BASE_EXPORT MessagePumpIOStarboard : public MessagePump { void set_watcher(Watcher* watcher) { watcher_ = watcher; } -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) void OnFileCanReadWithoutBlocking(int socket, MessagePumpIOStarboard* pump); void OnFileCanWriteWithoutBlocking(int socket, MessagePumpIOStarboard* pump); #else @@ -116,7 +116,7 @@ class BASE_EXPORT MessagePumpIOStarboard : public MessagePump { const Location created_from_location_; int interests_; -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) int socket_; #else SbSocket socket_; @@ -148,7 +148,7 @@ class BASE_EXPORT MessagePumpIOStarboard : public MessagePump { // If an error occurs while calling this method in a cumulative fashion, the // event previously attached to |controller| is aborted. Returns true on // success. Must be called on the same thread the message_pump is running on. -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) bool WatchFileDescriptor(int socket, bool persistent, int mode, @@ -185,7 +185,7 @@ class BASE_EXPORT MessagePumpIOStarboard : public MessagePump { // Called by SbSocketWaiter to tell us a registered socket can be read and/or // written to. -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) static void OnPosixSocketWaiterNotification(SbSocketWaiter waiter, int socket, void* context, diff --git a/base/message_loop/message_pump_io_starboard_unittest.cc b/base/message_loop/message_pump_io_starboard_unittest.cc index f6874839cbd1..4b4c7dcac6d9 100644 --- a/base/message_loop/message_pump_io_starboard_unittest.cc +++ b/base/message_loop/message_pump_io_starboard_unittest.cc @@ -18,7 +18,7 @@ #include -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) #include #include #include @@ -48,7 +48,7 @@ class MessagePumpIOStarboardTest : public testing::Test { void SetUp() override { Thread::Options options(MessagePumpType::IO, 0); ASSERT_TRUE(io_thread_.StartWithOptions(std::move(options))); -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) socket_ = ::socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); #else socket_ = SbSocketCreate(SbSocketAddressType::kSbSocketAddressTypeIpv4, SbSocketProtocol::kSbSocketProtocolTcp); @@ -62,7 +62,7 @@ class MessagePumpIOStarboardTest : public testing::Test { // pipe. io_thread_.Stop(); -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) close(socket_); #else SbSocketDestroy(socket_); @@ -73,7 +73,7 @@ class MessagePumpIOStarboardTest : public testing::Test { return std::make_unique(); } -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) int socket() { return socket_; } @@ -88,7 +88,7 @@ class MessagePumpIOStarboardTest : public testing::Test { } void SimulateIOEvent(MessagePumpIOStarboard::SocketWatcher* controller) { -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) MessagePumpIOStarboard::OnPosixSocketWaiterNotification(nullptr, -1, controller, @@ -107,7 +107,7 @@ class MessagePumpIOStarboardTest : public testing::Test { private: Thread io_thread_; -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) int socket_; #else SbSocket socket_; @@ -123,7 +123,7 @@ class StupidWatcher : public MessagePumpIOStarboard::Watcher { ~StupidWatcher() override = default; // MessagePumpIOStarboard::Watcher interface -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) void OnFileCanReadWithoutBlocking(int socket) override {} void OnFileCanWriteWithoutBlocking(int socket) override {} #else @@ -144,7 +144,7 @@ class BaseWatcher : public MessagePumpIOStarboard::Watcher { ~BaseWatcher() override = default; // MessagePumpIOStarboard::Watcher interface -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) void OnFileCanReadWithoutBlocking(int socket) override { NOTREACHED(); } void OnFileCanWriteWithoutBlocking(int socket) override { NOTREACHED(); } #else @@ -165,7 +165,7 @@ class DeleteWatcher : public BaseWatcher { return controller_.get(); } -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) void OnFileCanWriteWithoutBlocking(int socket) override { #else void OnSocketReadyToWrite(SbSocket socket) override { @@ -183,7 +183,7 @@ TEST_F(MessagePumpIOStarboardTest, DISABLED_DeleteWatcher) { DeleteWatcher delegate( std::make_unique(FROM_HERE)); std::unique_ptr pump = CreateMessagePump(); -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) pump->WatchFileDescriptor(socket(), #else pump->Watch(socket(), @@ -202,7 +202,7 @@ class StopWatcher : public BaseWatcher { ~StopWatcher() override = default; -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) void OnFileCanWriteWithoutBlocking(int socket) override { controller_->StopWatchingFileDescriptor(); } @@ -222,7 +222,7 @@ TEST_F(MessagePumpIOStarboardTest, DISABLED_StopWatcher) { std::unique_ptr pump = CreateMessagePump(); MessagePumpIOStarboard::SocketWatcher controller(FROM_HERE); StopWatcher delegate(&controller); -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) pump->WatchFileDescriptor(socket(), #else pump->Watch(socket(), @@ -248,7 +248,7 @@ class NestedPumpWatcher : public MessagePumpIOStarboard::Watcher { NestedPumpWatcher() = default; ~NestedPumpWatcher() override = default; -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) void OnFileCanReadWithoutBlocking(int socket) override { #else void OnSocketReadyToRead(SbSocket socket) override { @@ -259,7 +259,7 @@ class NestedPumpWatcher : public MessagePumpIOStarboard::Watcher { runloop.Run(); } -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) void OnFileCanWriteWithoutBlocking(int socket) override {} }; #else @@ -272,7 +272,7 @@ TEST_F(MessagePumpIOStarboardTest, DISABLED_NestedPumpWatcher) { NestedPumpWatcher delegate; std::unique_ptr pump = CreateMessagePump(); MessagePumpIOStarboard::SocketWatcher controller(FROM_HERE); -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) pump->WatchFileDescriptor(socket(), #else pump->Watch(socket(), @@ -293,7 +293,7 @@ class QuitWatcher : public BaseWatcher { QuitWatcher(base::OnceClosure quit_closure) : quit_closure_(std::move(quit_closure)) {} -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) void OnFileCanReadWithoutBlocking(int socket) override { #else void OnSocketReadyToRead(SbSocket socket) override { @@ -331,7 +331,7 @@ TEST_F(MessagePumpIOStarboardTest, DISABLED_QuitWatcher) { std::unique_ptr watcher(new WaitableEventWatcher); // Tell the pump to watch the pipe. -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) pump->WatchFileDescriptor(socket(), #else pump->Watch(socket(), diff --git a/base/task/current_thread.cc b/base/task/current_thread.cc index c3a8274ed15c..72d61befbf8a 100644 --- a/base/task/current_thread.cc +++ b/base/task/current_thread.cc @@ -212,7 +212,7 @@ MessagePumpForIO* CurrentIOThread::GetMessagePumpForIO() const { #if !BUILDFLAG(IS_NACL) #if defined(STARBOARD) -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) bool CurrentIOThread::WatchFileDescriptor(int socket, bool persistent, int mode, diff --git a/base/task/current_thread.h b/base/task/current_thread.h index 36f9664d0276..5303e2b2abbf 100644 --- a/base/task/current_thread.h +++ b/base/task/current_thread.h @@ -279,7 +279,7 @@ class BASE_EXPORT CurrentIOThread : public CurrentThread { WATCH_WRITE = base::MessagePumpIOStarboard::WATCH_WRITE, WATCH_READ_WRITE = base::MessagePumpIOStarboard::WATCH_READ_WRITE}; -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) bool WatchFileDescriptor(int socket, bool persistent, int mode, diff --git a/cobalt/webdriver/server.cc b/cobalt/webdriver/server.cc index 50668ca7087b..b1bb2071b89b 100644 --- a/cobalt/webdriver/server.cc +++ b/cobalt/webdriver/server.cc @@ -204,12 +204,7 @@ WebDriverServer::WebDriverServer(int port, const std::string& listen_ip, // Create http server std::unique_ptr server_socket = std::make_unique(nullptr, net::NetLogSource()); - int rv = - server_socket->ListenWithAddressAndPort(listen_ip, port, 1 /*backlog*/); - if (rv != 0) { - LOG(ERROR) << "Listen WebDriver failed " << rv << " errno " << errno; - return; - } + server_socket->ListenWithAddressAndPort(listen_ip, port, 1 /*backlog*/); server_ = std::make_unique(std::move(server_socket), this); net::IPEndPoint ip_addr; int result = server_->GetLocalInterfaceAddress(&ip_addr); diff --git a/net/base/address_family.cc b/net/base/address_family.cc index 54e9dd0b3d5a..835f55801211 100644 --- a/net/base/address_family.cc +++ b/net/base/address_family.cc @@ -20,7 +20,7 @@ AddressFamily GetAddressFamily(const IPAddress& address) { } } -#if defined(STARBOARD) && SB_API_VERSION <= 15 +#if defined(STARBOARD) && (SB_API_VERSION <= 15 || defined(_MSC_VER)) SbSocketAddressType ConvertAddressFamily(AddressFamily address_family) { switch (address_family) { case ADDRESS_FAMILY_IPV4: diff --git a/net/base/address_family.h b/net/base/address_family.h index 0de19b7e277c..9b95f488133e 100644 --- a/net/base/address_family.h +++ b/net/base/address_family.h @@ -42,7 +42,7 @@ typedef int HostResolverFlags; // Returns AddressFamily for |address|. NET_EXPORT AddressFamily GetAddressFamily(const IPAddress& address); -#if defined(STARBOARD) && SB_API_VERSION <= 15 +#if defined(STARBOARD) && (SB_API_VERSION <= 15 || defined(_MSC_VER)) NET_EXPORT SbSocketAddressType ConvertAddressFamily( AddressFamily address_family); #else @@ -50,6 +50,7 @@ NET_EXPORT SbSocketAddressType ConvertAddressFamily( NET_EXPORT int ConvertAddressFamily(AddressFamily address_family); #endif + // Maps AF_INET, AF_INET6 or AF_UNSPEC to an AddressFamily. NET_EXPORT AddressFamily ToAddressFamily(int family); diff --git a/net/base/features.cc b/net/base/features.cc index 1f1e5baf2e04..3bc1d079d179 100644 --- a/net/base/features.cc +++ b/net/base/features.cc @@ -212,7 +212,8 @@ BASE_FEATURE(kDocumentReporting, base::FEATURE_ENABLED_BY_DEFAULT); #endif // BUILDFLAG(ENABLE_REPORTING) -#if BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) || SB_API_VERSION >= 16 +#if BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) || \ + (SB_API_VERSION >= 16 && !defined(_MSC_VER)) BASE_FEATURE(kUdpSocketPosixAlwaysUpdateBytesReceived, "UdpSocketPosixAlwaysUpdateBytesReceived", base::FEATURE_ENABLED_BY_DEFAULT); diff --git a/net/base/features.h b/net/base/features.h index dd6a84f0c8ef..e06f1c4a5c92 100644 --- a/net/base/features.h +++ b/net/base/features.h @@ -261,14 +261,16 @@ NET_EXPORT extern const base::FeatureParam NET_EXPORT BASE_DECLARE_FEATURE(kDocumentReporting); #endif // BUILDFLAG(ENABLE_REPORTING) -#if BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) || SB_API_VERSION >= 16 +#if BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) || \ + (SB_API_VERSION >= 16 && !defined(_MSC_VER)) // When enabled, UDPSocketPosix increments the global counter of bytes received // every time bytes are received, instead of using a timer to batch updates. // This should reduce the number of wake ups and improve battery consumption. // TODO(https://crbug.com/1189805): Cleanup the feature after verifying that it // doesn't negatively affect performance. NET_EXPORT BASE_DECLARE_FEATURE(kUdpSocketPosixAlwaysUpdateBytesReceived); -#endif // BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) || SB_API_VERSION >= 16 +#endif // BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) || + // (SB_API_VERSION >= 16 && !defined(_MSC_VER)) // When this feature is enabled, redirected requests will be considered // cross-site for the purpose of SameSite cookies if any redirect hop was diff --git a/net/base/net_errors_posix.cc b/net/base/net_errors_posix.cc index e3145c787b51..9cc87db6246c 100644 --- a/net/base/net_errors_posix.cc +++ b/net/base/net_errors_posix.cc @@ -15,7 +15,7 @@ namespace net { -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) Error MapSystemError(logging::SystemErrorCode os_error) { if (os_error != 0) @@ -138,6 +138,5 @@ Error MapSystemError(logging::SystemErrorCode os_error) { } } -#endif // SB_API_VERSION >= 16 - +#endif // SB_API_VERSION >= 16 && !defined(WIN32) } // namespace net diff --git a/net/base/net_errors_starboard.cc b/net/base/net_errors_starboard.cc index 329ec117d82a..ed4dc7f40599 100644 --- a/net/base/net_errors_starboard.cc +++ b/net/base/net_errors_starboard.cc @@ -24,7 +24,7 @@ namespace net { -#if SB_API_VERSION <= 15 +#if SB_API_VERSION <= 15 || defined(_MSC_VER) Error MapSystemError(logging::SystemErrorCode error) { if (error != 0) { @@ -60,6 +60,6 @@ Error MapSocketError(SbSocketError error) { } } -#endif // SB_API_VERSION <= 15 +#endif // SB_API_VERSION <= 15 || defined(_MSC_VER) } // namespace net diff --git a/net/base/sockaddr_util_posix.cc b/net/base/sockaddr_util_posix.cc index 583b15a23ac7..cb33e47d0867 100644 --- a/net/base/sockaddr_util_posix.cc +++ b/net/base/sockaddr_util_posix.cc @@ -16,6 +16,8 @@ namespace net { +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) + bool FillUnixAddress(const std::string& socket_path, bool use_abstract_namespace, SockaddrStorage* address) { @@ -54,4 +56,6 @@ bool FillUnixAddress(const std::string& socket_path, #endif } +#endif // SB_API_VERSION >= 16 && !defined(WIN32) + } // namespace net diff --git a/net/server/http_server.cc b/net/server/http_server.cc index 2dc2fd166000..bc7dea5cc615 100644 --- a/net/server/http_server.cc +++ b/net/server/http_server.cc @@ -208,7 +208,6 @@ void HttpServer::DoAcceptLoop() { rv = server_socket_->Accept(&accepted_socket_, base::BindOnce(&HttpServer::OnAcceptCompleted, weak_ptr_factory_.GetWeakPtr())); - DLOG(ERROR) << "HttpServer::DoAcceptLoop, rv = " << rv; if (rv == ERR_IO_PENDING) return; rv = HandleAcceptResult(rv); diff --git a/net/socket/socket_descriptor.cc b/net/socket/socket_descriptor.cc index 649bd77e373a..7a3c18602ce7 100644 --- a/net/socket/socket_descriptor.cc +++ b/net/socket/socket_descriptor.cc @@ -6,13 +6,14 @@ #include "build/build_config.h" -#if defined(STARBOARD) && SB_API_VERSION <= 15 +#if defined(STARBOARD) && (SB_API_VERSION <= 15 || defined(_MSC_VER)) #include "starboard/socket.h" #include "base/notreached.h" #elif BUILDFLAG(IS_WIN) #include #include "net/base/winsock_init.h" -#elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) || SB_API_VERSION >= 16 +#elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) || \ + (SB_API_VERSION >= 16 && !defined(_MSC_VER)) #include #include #endif @@ -24,7 +25,7 @@ namespace net { SocketDescriptor CreatePlatformSocket(int family, int type, int protocol) { -#if defined(STARBOARD) && SB_API_VERSION <= 15 +#if defined(STARBOARD) && (SB_API_VERSION <= 15 || defined(_MSC_VER)) NOTREACHED(); return kSbSocketInvalid; #elif BUILDFLAG(IS_WIN) @@ -40,7 +41,8 @@ SocketDescriptor CreatePlatformSocket(int family, int type, int protocol) { } } return result; -#elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) || SB_API_VERSION >= 16 +#elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) || \ + (SB_API_VERSION >= 16 && !defined(_MSC_VER)) SocketDescriptor result = ::socket(family, type, protocol); #if BUILDFLAG(IS_APPLE) // Disable SIGPIPE on this socket. Although Chromium globally disables diff --git a/net/socket/socket_descriptor.h b/net/socket/socket_descriptor.h index 5e96cbdd8ea6..c79c0221bd97 100644 --- a/net/socket/socket_descriptor.h +++ b/net/socket/socket_descriptor.h @@ -17,12 +17,13 @@ namespace net { -#if defined(STARBOARD) && SB_API_VERSION <= 15 +#if defined(STARBOARD) && (SB_API_VERSION <= 15 || defined(_MSC_VER)) typedef SbSocket SocketDescriptor; #elif BUILDFLAG(IS_WIN) typedef UINT_PTR SocketDescriptor; const SocketDescriptor kInvalidSocket = (SocketDescriptor)(~0); -#elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) || SB_API_VERSION >= 16 +#elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) || \ + (SB_API_VERSION >= 16 && !defined(_MSC_VER)) typedef int SocketDescriptor; const SocketDescriptor kInvalidSocket = -1; #endif diff --git a/net/socket/socket_options.cc b/net/socket/socket_options.cc index 42cc6c25aba9..cb9a327b19fc 100644 --- a/net/socket/socket_options.cc +++ b/net/socket/socket_options.cc @@ -9,12 +9,13 @@ #include "build/build_config.h" #include "net/base/net_errors.h" -#if defined(STARBOARD) && SB_API_VERSION <= 15 +#if defined(STARBOARD) && (SB_API_VERSION <= 15 || defined(_MSC_VER)) #include "base/notreached.h" #elif BUILDFLAG(IS_WIN) #include #include -#elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) || SB_API_VERSION >= 16 +#elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) || \ + (SB_API_VERSION >= 16 && !defined(_MSC_VER)) #include #include #include @@ -23,13 +24,14 @@ namespace net { int SetTCPNoDelay(SocketDescriptor fd, bool no_delay) { -#if defined(STARBOARD) && SB_API_VERSION <= 15 +#if defined(STARBOARD) && (SB_API_VERSION <= 15 || defined(_MSC_VER)) return SbSocketSetTcpNoDelay(fd, no_delay) ? OK : ERR_FAILED; #else #if BUILDFLAG(IS_WIN) BOOL on = no_delay ? TRUE : FALSE; -#elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) || SB_API_VERSION >= 16 +#elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) || \ + (SB_API_VERSION >= 16 && !defined(_MSC_VER)) int on = no_delay ? 1 : 0; #endif int rv = setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, @@ -39,7 +41,7 @@ int SetTCPNoDelay(SocketDescriptor fd, bool no_delay) { } int SetReuseAddr(SocketDescriptor fd, bool reuse) { -#if defined(STARBOARD) && SB_API_VERSION <= 15 +#if defined(STARBOARD) && (SB_API_VERSION <= 15 || defined(_MSC_VER)) return SbSocketSetReuseAddress(fd, reuse) ? OK : ERR_FAILED; #else // SO_REUSEADDR is useful for server sockets to bind to a recently unbound @@ -57,7 +59,8 @@ int SetReuseAddr(SocketDescriptor fd, bool reuse) { // SO_REUSEPORT is provided in MacOS X and iOS. #if BUILDFLAG(IS_WIN) BOOL boolean_value = reuse ? TRUE : FALSE; -#elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) || SB_API_VERSION >= 16 +#elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) || \ + (SB_API_VERSION >= 16 && !defined(_MSC_VER)) int boolean_value = reuse ? 1 : 0; #endif int rv = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, @@ -68,14 +71,15 @@ int SetReuseAddr(SocketDescriptor fd, bool reuse) { } int SetSocketReceiveBufferSize(SocketDescriptor fd, int32_t size) { -#if defined(STARBOARD) && SB_API_VERSION <= 15 +#if defined(STARBOARD) && (SB_API_VERSION <= 15 || defined(_MSC_VER)) return SbSocketSetReceiveBufferSize(fd, size) ? OK : ERR_FAILED; #else int rv = setsockopt(fd, SOL_SOCKET, SO_RCVBUF, reinterpret_cast(&size), sizeof(size)); #if BUILDFLAG(IS_WIN) int os_error = WSAGetLastError(); -#elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) || SB_API_VERSION >= 16 +#elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) || \ + (SB_API_VERSION >= 16 && !defined(_MSC_VER)) int os_error = errno; #endif int net_error = (rv == -1) ? MapSystemError(os_error) : OK; @@ -87,14 +91,15 @@ int SetSocketReceiveBufferSize(SocketDescriptor fd, int32_t size) { } int SetSocketSendBufferSize(SocketDescriptor fd, int32_t size) { -#if defined(STARBOARD) && SB_API_VERSION <= 15 +#if defined(STARBOARD) && (SB_API_VERSION <= 15 || defined(_MSC_VER)) return SbSocketSetSendBufferSize(fd, size) ? OK : ERR_FAILED; #else int rv = setsockopt(fd, SOL_SOCKET, SO_SNDBUF, reinterpret_cast(&size), sizeof(size)); #if BUILDFLAG(IS_WIN) int os_error = WSAGetLastError(); -#elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) || SB_API_VERSION >= 16 +#elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) || \ + (SB_API_VERSION >= 16 && !defined(_MSC_VER)) int os_error = errno; #endif int net_error = (rv == -1) ? MapSystemError(os_error) : OK; @@ -106,13 +111,14 @@ int SetSocketSendBufferSize(SocketDescriptor fd, int32_t size) { } int SetIPv6Only(SocketDescriptor fd, bool ipv6_only) { -#if defined(STARBOARD) && SB_API_VERSION <= 15 +#if defined(STARBOARD) && (SB_API_VERSION <= 15 || defined(_MSC_VER)) NOTREACHED(); return -1; #else #if BUILDFLAG(IS_WIN) DWORD on = ipv6_only ? 1 : 0; -#elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) || SB_API_VERSION >= 16 +#elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) || \ + (SB_API_VERSION >= 16 && !defined(_MSC_VER)) int on = ipv6_only ? 1 : 0; #endif int rv = setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, diff --git a/net/socket/socket_posix.cc b/net/socket/socket_posix.cc index 05fc339da581..f09776ba4e20 100644 --- a/net/socket/socket_posix.cc +++ b/net/socket/socket_posix.cc @@ -33,7 +33,7 @@ namespace net { -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) namespace { @@ -144,7 +144,7 @@ int SocketPosix::Bind(const SockaddrStorage& address) { int rv = bind(socket_fd_, address.addr, address.addr_len); if (rv < 0) { - PLOG(ERROR) << "bind() failed -errno- :" << errno; + PLOG(ERROR) << "bind() failed"; return MapSystemError(errno); } @@ -591,6 +591,6 @@ void SocketPosix::StopWatchingAndCleanUp(bool close_socket) { peer_address_.reset(); } -#endif // SB_API_VERSION >= 16 +#endif // SB_API_VERSION >= 16 && !defined(WIN32) } // namespace net diff --git a/net/socket/socket_posix.h b/net/socket/socket_posix.h index 36a7bfeb5396..c009030e8f11 100644 --- a/net/socket/socket_posix.h +++ b/net/socket/socket_posix.h @@ -19,7 +19,7 @@ namespace net { -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) class IOBuffer; struct SockaddrStorage; @@ -165,7 +165,7 @@ class NET_EXPORT_PRIVATE SocketPosix base::ThreadChecker thread_checker_; }; -#endif // SB_API_VERSION >= 16 +#endif // SB_API_VERSION >= 16 && !defined(WIN32) } // namespace net diff --git a/net/socket/tcp_socket.h b/net/socket/tcp_socket.h index 708df595e0f1..1e0fa1ed662d 100644 --- a/net/socket/tcp_socket.h +++ b/net/socket/tcp_socket.h @@ -9,11 +9,12 @@ #include "net/base/net_export.h" #include "net/socket/socket_descriptor.h" -#if defined(STARBOARD) && SB_API_VERSION <= 15 +#if defined(STARBOARD) && (SB_API_VERSION <= 15 || defined(_MSC_VER)) #include "net/socket/tcp_socket_starboard.h" #elif BUILDFLAG(IS_WIN) #include "net/socket/tcp_socket_win.h" -#elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) || SB_API_VERSION >= 16 +#elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) || \ + (SB_API_VERSION >= 16 && !defined(_MSC_VER)) #include "net/socket/tcp_socket_posix.h" #endif @@ -25,11 +26,12 @@ namespace net { // class, unless a clear separation of client and server socket functionality is // not suitable for your use case (e.g., a socket needs to be created and bound // before you know whether it is a client or server socket). -#if defined(STARBOARD) && SB_API_VERSION <= 15 +#if defined(STARBOARD) && (SB_API_VERSION <= 15 || defined(_MSC_VER)) typedef TCPSocketStarboard TCPSocket; #elif BUILDFLAG(IS_WIN) typedef TCPSocketWin TCPSocket; -#elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) || SB_API_VERSION >= 16 +#elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) || \ + (SB_API_VERSION >= 16 && !defined(_MSC_VER)) typedef TCPSocketPosix TCPSocket; #endif diff --git a/net/socket/tcp_socket_posix.cc b/net/socket/tcp_socket_posix.cc index cd6362a1f569..4c1884843f55 100644 --- a/net/socket/tcp_socket_posix.cc +++ b/net/socket/tcp_socket_posix.cc @@ -62,7 +62,7 @@ namespace net { -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) namespace { @@ -239,6 +239,7 @@ int TCPSocketPosix::Bind(const IPEndPoint& address) { SockaddrStorage storage; if (!address.ToSockAddr(storage.addr, &storage.addr_len)) return ERR_ADDRESS_INVALID; + return socket_->Bind(storage); } @@ -715,6 +716,6 @@ bool TCPSocketPosix::GetEstimatedRoundTripTime(base::TimeDelta* out_rtt) const { #endif // defined(TCP_INFO) } -#endif // SB_API_VERSION >= 16 +#endif // SB_API_VERSION >= 16 && !defined(WIN32) } // namespace net diff --git a/net/socket/tcp_socket_posix.h b/net/socket/tcp_socket_posix.h index a84cf61eb469..eff66236e27a 100644 --- a/net/socket/tcp_socket_posix.h +++ b/net/socket/tcp_socket_posix.h @@ -26,7 +26,7 @@ class TimeDelta; namespace net { -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) class AddressList; class IOBuffer; @@ -229,7 +229,7 @@ class NET_EXPORT TCPSocketPosix { SocketTag tag_; }; -#endif // SB_API_VERSION >= 16 +#endif // SB_API_VERSION >= 16 && !defined(WIN32) } // namespace net diff --git a/net/socket/tcp_socket_starboard.cc b/net/socket/tcp_socket_starboard.cc index 43f7a5db2515..e4ca77ecfb39 100644 --- a/net/socket/tcp_socket_starboard.cc +++ b/net/socket/tcp_socket_starboard.cc @@ -28,7 +28,7 @@ namespace net { -#if SB_API_VERSION <= 15 +#if SB_API_VERSION <= 15 || defined(COMPILER_MSVC) TCPSocketStarboard::TCPSocketStarboard( std::unique_ptr socket_performance_watcher, @@ -687,6 +687,6 @@ int TCPSocketStarboard::SetIPv6Only(bool ipv6_only) { return 0; } -#endif // SB_API_VERSION <= 15 +#endif // SB_API_VERSION <= 15 || defined(WIN32) } // namespace net diff --git a/net/socket/tcp_socket_starboard.h b/net/socket/tcp_socket_starboard.h index 329a5d0f278d..5acc64efdb56 100644 --- a/net/socket/tcp_socket_starboard.h +++ b/net/socket/tcp_socket_starboard.h @@ -33,7 +33,7 @@ namespace net { -#if SB_API_VERSION <= 15 +#if SB_API_VERSION <= 15 || defined(COMPILER_MSVC) class NET_EXPORT TCPSocketStarboard : public base::MessagePumpIOStarboard::Watcher { public: @@ -215,7 +215,7 @@ class NET_EXPORT TCPSocketStarboard : public base::MessagePumpIOStarboard::Watch // DISALLOW_COPY_AND_ASSIGN(TCPSocketStarboard); }; -#endif // SB_API_VERSION <= 15 +#endif // SB_API_VERSION <= 15 || defined(WIN32) } // namespace net diff --git a/net/socket/transport_client_socket_unittest.cc b/net/socket/transport_client_socket_unittest.cc index a60a9af4f73c..4b24198eb23b 100644 --- a/net/socket/transport_client_socket_unittest.cc +++ b/net/socket/transport_client_socket_unittest.cc @@ -295,6 +295,7 @@ TEST_F(TransportClientSocketTest, FullDuplex_ReadFirst) { // At this point, both read and write have returned ERR_IO_PENDING, and the // write callback has executed. We wait for the read callback to run now to // make sure that the socket can handle full duplex communications. + rv = callback.WaitForResult(); EXPECT_GE(rv, 0); } @@ -316,6 +317,7 @@ TEST_F(TransportClientSocketTest, FullDuplex_WriteFirst) { sock_->Write(request_buffer.get(), kWriteBufLen, write_callback.callback(), TRAFFIC_ANNOTATION_FOR_TESTS); ASSERT_TRUE(rv >= 0 || rv == ERR_IO_PENDING); + if (rv == ERR_IO_PENDING) break; bytes_written += rv; diff --git a/net/socket/udp_socket.h b/net/socket/udp_socket.h index f57366dab4e5..59d87601436b 100644 --- a/net/socket/udp_socket.h +++ b/net/socket/udp_socket.h @@ -7,11 +7,12 @@ #include "build/build_config.h" -#if defined(STARBOARD) && SB_API_VERSION <= 15 +#if defined(STARBOARD) && (SB_API_VERSION <= 15 || defined(_MSC_VER)) #include "net/socket/udp_socket_starboard.h" #elif BUILDFLAG(IS_WIN) #include "net/socket/udp_socket_win.h" -#elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) || SB_API_VERSION >= 16 +#elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) || \ + (SB_API_VERSION >= 16 && !defined(_MSC_VER)) #include "net/socket/udp_socket_posix.h" #endif @@ -37,11 +38,12 @@ namespace net { // RecvFrom/SendTo // Each read can come from a different client // // Writes need to be directed to a specific // // address. -#if defined(STARBOARD) && SB_API_VERSION <= 15 +#if defined(STARBOARD) && (SB_API_VERSION <= 15 || defined(_MSC_VER)) typedef UDPSocketStarboard UDPSocket; #elif BUILDFLAG(IS_WIN) typedef UDPSocketWin UDPSocket; -#elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) || SB_API_VERSION >= 16 +#elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) || \ + (SB_API_VERSION >= 16 && !defined(_MSC_VER)) typedef UDPSocketPosix UDPSocket; #endif diff --git a/net/socket/udp_socket_posix.cc b/net/socket/udp_socket_posix.cc index 662235c633c1..5515b009c900 100644 --- a/net/socket/udp_socket_posix.cc +++ b/net/socket/udp_socket_posix.cc @@ -64,7 +64,7 @@ namespace net { -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) namespace { @@ -1092,6 +1092,6 @@ int UDPSocketPosix::SetIOSNetworkServiceType(int ios_network_service_type) { return OK; } -#endif // SB_API_VERSION >= 16 +#endif // SB_API_VERSION >= 16 && !defined(WIN32) } // namespace net diff --git a/net/socket/udp_socket_posix.h b/net/socket/udp_socket_posix.h index 44994e51ab0b..6be31f772591 100644 --- a/net/socket/udp_socket_posix.h +++ b/net/socket/udp_socket_posix.h @@ -33,7 +33,7 @@ namespace net { -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) class IPAddress; class NetLog; @@ -467,7 +467,7 @@ class NET_EXPORT UDPSocketPosix { THREAD_CHECKER(thread_checker_); }; -#endif // SB_API_VERSION >= 16 +#endif // SB_API_VERSION >= 16 && !defined(WIN32) } // namespace net diff --git a/net/socket/udp_socket_starboard.cc b/net/socket/udp_socket_starboard.cc index 89218e62b0bc..45cc20cc4936 100644 --- a/net/socket/udp_socket_starboard.cc +++ b/net/socket/udp_socket_starboard.cc @@ -35,7 +35,7 @@ namespace net { -#if SB_API_VERSION <= 15 +#if SB_API_VERSION <= 15 || defined(COMPILER_MSVC) UDPSocketStarboard::UDPSocketStarboard(DatagramSocket::BindType bind_type, net::NetLog* net_log, @@ -902,6 +902,6 @@ int UDPSocketStarboard::ResetWrittenBytes() { return bytes; } -#endif // SB_API_VERSION <= 15 +#endif // SB_API_VERSION <= 15 || defined(WIN32) } // namespace net diff --git a/net/socket/udp_socket_starboard.h b/net/socket/udp_socket_starboard.h index cb8101670e67..0b3707fe0c01 100644 --- a/net/socket/udp_socket_starboard.h +++ b/net/socket/udp_socket_starboard.h @@ -42,7 +42,7 @@ namespace net { -#if SB_API_VERSION <= 15 +#if SB_API_VERSION <= 15 || defined(COMPILER_MSVC) // Sendresult is inspired by sendmmsg, but unlike sendmmsg it is not // convenient to require that a positive |write_count| and a negative @@ -493,7 +493,7 @@ class NET_EXPORT UDPSocketStarboard // DISALLOW_COPY_AND_ASSIGN(UDPSocketStarboard); }; -#endif // SB_API_VERSION <= 15 +#endif // SB_API_VERSION <= 15 || defined(WIN32) } // namespace net diff --git a/starboard/elf_loader/exported_symbols.cc b/starboard/elf_loader/exported_symbols.cc index 69e510c7c9c3..1259ba049276 100644 --- a/starboard/elf_loader/exported_symbols.cc +++ b/starboard/elf_loader/exported_symbols.cc @@ -489,11 +489,11 @@ ExportedSymbols::ExportedSymbols() { REGISTER_SYMBOL(posix_memalign); REGISTER_SYMBOL(realloc); REGISTER_SYMBOL(recv); + REGISTER_SYMBOL(send); REGISTER_SYMBOL(recvfrom); REGISTER_SYMBOL(recvmsg); REGISTER_SYMBOL(rmdir); REGISTER_SYMBOL(sched_yield); - REGISTER_SYMBOL(send); REGISTER_SYMBOL(sendto); REGISTER_SYMBOL(socket); REGISTER_SYMBOL(snprintf); diff --git a/starboard/nplb/posix_compliance/posix_socket_waiter_add_test.cc b/starboard/nplb/posix_compliance/posix_socket_waiter_add_test.cc index 8e7de6bfa7b7..9899741330c4 100644 --- a/starboard/nplb/posix_compliance/posix_socket_waiter_add_test.cc +++ b/starboard/nplb/posix_compliance/posix_socket_waiter_add_test.cc @@ -26,7 +26,7 @@ namespace starboard { namespace nplb { namespace { -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) class SbPosixSocketWaiterAddTest : public ::testing::TestWithParam { public: @@ -175,7 +175,7 @@ TEST(SbPosixSocketWaiterAddTest, RainyDayNoInterest) { EXPECT_TRUE(close(socket) == 0); EXPECT_TRUE(SbSocketWaiterDestroy(waiter)); } -#endif // SB_API_VERSION >= 16 +#endif // SB_API_VERSION >= 16 && !defined(_MSC_VER) } // namespace } // namespace nplb diff --git a/starboard/nplb/posix_compliance/posix_socket_waiter_remove_test.cc b/starboard/nplb/posix_compliance/posix_socket_waiter_remove_test.cc index 881642597558..56e0dea2381c 100644 --- a/starboard/nplb/posix_compliance/posix_socket_waiter_remove_test.cc +++ b/starboard/nplb/posix_compliance/posix_socket_waiter_remove_test.cc @@ -25,7 +25,7 @@ namespace starboard { namespace nplb { namespace { -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) void NoOpSocketWaiterCallback(SbSocketWaiter waiter, int socket, @@ -78,7 +78,7 @@ TEST(SbPosixSocketWaiterRemoveTest, RainyDayAlreadyRemoved) { EXPECT_TRUE(SbSocketWaiterDestroy(waiter)); } -#endif // SB_API_VERSION >= 16 +#endif // SB_API_VERSION >= 16 && !defined(_MSC_VER) } // namespace } // namespace nplb diff --git a/starboard/nplb/posix_compliance/posix_socket_waiter_wait_test.cc b/starboard/nplb/posix_compliance/posix_socket_waiter_wait_test.cc index e7db9d70bac1..76a68ed043df 100644 --- a/starboard/nplb/posix_compliance/posix_socket_waiter_wait_test.cc +++ b/starboard/nplb/posix_compliance/posix_socket_waiter_wait_test.cc @@ -27,7 +27,7 @@ namespace starboard { namespace nplb { namespace { -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(SbPosixSocketWaiterWaitTest); @@ -259,7 +259,7 @@ TEST(SbPosixSocketWaiterWaitTest, RainyDayInvalidWaiter) { WaitShouldNotBlock(kSbSocketWaiterInvalid); } -#endif // SB_API_VERSION >= 16 +#endif // SB_API_VERSION >= 16 && !defined(_MSC_VER) } // namespace } // namespace nplb diff --git a/starboard/nplb/posix_compliance/posix_socket_waiter_wait_timed_test.cc b/starboard/nplb/posix_compliance/posix_socket_waiter_wait_timed_test.cc index bdad638132a6..d6e580667a21 100644 --- a/starboard/nplb/posix_compliance/posix_socket_waiter_wait_timed_test.cc +++ b/starboard/nplb/posix_compliance/posix_socket_waiter_wait_timed_test.cc @@ -25,7 +25,7 @@ namespace starboard { namespace nplb { namespace { -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(SbPosixSocketWaiterWaitTimedTest); @@ -121,7 +121,7 @@ TEST(SbSocketWaiterWaitTimedTest, RainyDayInvalidWaiter) { TimedWaitShouldNotBlock(kSbSocketWaiterInvalid, kSocketTimeout); } -#endif // SB_API_VERSION >= 16 +#endif // SB_API_VERSION >= 16 && !defined(_MSC_VER) } // namespace } // namespace nplb diff --git a/starboard/shared/libevent/socket_waiter_add.cc b/starboard/shared/libevent/socket_waiter_add.cc index d25db10e4292..607b96dd4e7d 100644 --- a/starboard/shared/libevent/socket_waiter_add.cc +++ b/starboard/shared/libevent/socket_waiter_add.cc @@ -47,7 +47,7 @@ bool SbSocketWaiterAdd(SbSocketWaiter waiter, return waiter->Add(socket, context, callback, interests, persistent); } -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) bool SbPosixSocketWaiterAdd(SbSocketWaiter waiter, int socket, @@ -77,4 +77,4 @@ bool SbPosixSocketWaiterAdd(SbSocketWaiter waiter, return waiter->Add(socket, waiter, context, callback, interests, persistent); } -#endif // SB_API_VERSION >= 16 +#endif // SB_API_VERSION >= 16 && !defined(_MSC_VER) diff --git a/starboard/shared/libevent/socket_waiter_remove.cc b/starboard/shared/libevent/socket_waiter_remove.cc index 7c9f7d0b9e71..9361501f961c 100644 --- a/starboard/shared/libevent/socket_waiter_remove.cc +++ b/starboard/shared/libevent/socket_waiter_remove.cc @@ -23,7 +23,7 @@ bool SbSocketWaiterRemove(SbSocketWaiter waiter, SbSocket socket) { return waiter->Remove(socket, waiter); } -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) bool SbPosixSocketWaiterRemove(SbSocketWaiter waiter, int socket) { if (!SbSocketWaiterIsValid(waiter)) { @@ -33,4 +33,4 @@ bool SbPosixSocketWaiterRemove(SbSocketWaiter waiter, int socket) { return waiter->Remove(socket, waiter); } -#endif // SB_API_VERSION >= 16 +#endif // SB_API_VERSION >= 16 && !defined(_MSC_VER) diff --git a/starboard/shared/stub/socket_waiter_add.cc b/starboard/shared/stub/socket_waiter_add.cc index c037a6fb56c8..2529e2c03342 100644 --- a/starboard/shared/stub/socket_waiter_add.cc +++ b/starboard/shared/stub/socket_waiter_add.cc @@ -23,7 +23,7 @@ bool SbSocketWaiterAdd(SbSocketWaiter waiter, return false; } -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) bool SbPosixSocketWaiterAdd(SbSocketWaiter waiter, int socket, void* context, diff --git a/starboard/shared/stub/socket_waiter_remove.cc b/starboard/shared/stub/socket_waiter_remove.cc index 3e28033316b7..26b925ae9bc0 100644 --- a/starboard/shared/stub/socket_waiter_remove.cc +++ b/starboard/shared/stub/socket_waiter_remove.cc @@ -18,7 +18,7 @@ bool SbSocketWaiterRemove(SbSocketWaiter waiter, SbSocket socket) { return false; } -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) bool SbPosixSocketWaiterRemove(SbSocketWaiter waiter, int socket) { return false; } diff --git a/starboard/shared/win32/socket_waiter_add.cc b/starboard/shared/win32/socket_waiter_add.cc index d16114a3993d..35ff11b8f028 100644 --- a/starboard/shared/win32/socket_waiter_add.cc +++ b/starboard/shared/win32/socket_waiter_add.cc @@ -17,7 +17,7 @@ #include "starboard/common/log.h" #include "starboard/shared/win32/socket_waiter_internal.h" -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) bool SbPosixSocketWaiterAdd(SbSocketWaiter waiter, int socket, void* context, @@ -46,7 +46,7 @@ bool SbPosixSocketWaiterAdd(SbSocketWaiter waiter, return waiter->Add(socket, waiter, context, callback, interests, persistent); } -#endif // SB_API_VERSION >= 16 +#endif // SB_API_VERSION >= 16 && !defined(_MSC_VER) bool SbSocketWaiterAdd(SbSocketWaiter waiter, SbSocket socket, diff --git a/starboard/shared/win32/socket_waiter_internal.cc b/starboard/shared/win32/socket_waiter_internal.cc index 7162e358efa8..165fb6e0be6e 100644 --- a/starboard/shared/win32/socket_waiter_internal.cc +++ b/starboard/shared/win32/socket_waiter_internal.cc @@ -145,7 +145,7 @@ SbSocketWaiterPrivate::~SbSocketWaiterPrivate() { for (auto& it : waitees_.GetWaitees()) { if (it) { if (it->use_posix_socket == 1) { -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) SB_DCHECK(CheckSocketWaiterIsThis(it->posix_socket, it->waiter)); #endif } else { @@ -155,7 +155,7 @@ SbSocketWaiterPrivate::~SbSocketWaiterPrivate() { } } -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) bool SbSocketWaiterPrivate::Add(int socket, SbSocketWaiter waiter, void* context, @@ -261,7 +261,7 @@ bool SbSocketWaiterPrivate::Remove(int socket, SbSocketWaiter waiter) { return waitees_.RemoveSocket(socket); } -#endif // SB_API_VERSION >= 16 +#endif // SB_API_VERSION >= 16 && !defined(_MSC_VER) bool SbSocketWaiterPrivate::Add(SbSocket socket, void* context, @@ -379,7 +379,7 @@ void SbSocketWaiterPrivate::ResetWakeupEvent() { WSAResetEvent(wakeup_event_.GetEvent()); } -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) bool SbSocketWaiterPrivate::CheckSocketWaiterIsThis(int socket, SbSocketWaiter waiter) { if (socket < 0) { @@ -407,7 +407,7 @@ bool SbSocketWaiterPrivate::CheckSocketRegistered(int socket) { return true; } -#endif // SB_API_VERSION >= 16 +#endif // SB_API_VERSION >= 16 && !defined(_MSC_VER) bool SbSocketWaiterPrivate::CheckSocketWaiterIsThis(SbSocket socket) { if (!SbSocketIsValid(socket)) { @@ -469,7 +469,7 @@ SbSocketWaiterResult SbSocketWaiterPrivate::WaitTimed(int64_t duration_usec) { // Check existing waitees to find out which type of socket is used // This check applies to SB16 and above only because of the POSIX APIs. int use_posix_socket = 0; -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) for (auto& it : waitees_.GetWaitees()) { if (!it) { continue; @@ -479,16 +479,16 @@ SbSocketWaiterResult SbSocketWaiterPrivate::WaitTimed(int64_t duration_usec) { break; } } -#endif // SB_API_VERSION >= 16 +#endif // SB_API_VERSION >= 16 && !defined(_MSC_VER) // There should always be a wakeup event. SB_DCHECK(number_events > 0); - bool has_writable; + bool has_writable = 0; int posix_maybe_writable_socket = -1; SbSocket maybe_writable_socket = kSbSocketInvalid; if (use_posix_socket == 1) { -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) has_writable = (posix_maybe_writable_socket != -1); #endif } else { @@ -550,7 +550,7 @@ SbSocketWaiterResult SbSocketWaiterPrivate::WaitTimed(int64_t duration_usec) { // that we can add another waitee in the callback if we need to. This // is also why we copy all the fields we need out of waitee. if (use_posix_socket == 1) { -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) const int posix_socket = waitee->posix_socket; const SbPosixSocketWaiterCallback posix_callback = waitee->posix_callback; @@ -626,7 +626,7 @@ void SbSocketWaiterPrivate::WakeUp() { SignalWakeupEvent(); } -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) SbSocketWaiterPrivate::Waitee* SbSocketWaiterPrivate::WaiteeRegistry::GetWaitee( int socket) { starboard::optional token = GetIndex(socket); @@ -673,7 +673,7 @@ bool SbSocketWaiterPrivate::WaiteeRegistry::RemoveSocket(int socket) { return true; } -#endif // SB_API_VERSION >= 16 +#endif // SB_API_VERSION >= 16 && !defined(_MSC_VER) SbSocketWaiterPrivate::Waitee* SbSocketWaiterPrivate::WaiteeRegistry::GetWaitee( SbSocket socket) { @@ -701,13 +701,13 @@ SbSocketWaiterPrivate::WaiteeRegistry::AddSocketEventAndWaitee( SB_DCHECK(socket_events_.size() == waitees_.size()); if (!waitee) { -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) posix_socket_to_index_map_.emplace(-1, socket_events_.size()); #endif socket_to_index_map_.emplace(kSbSocketInvalid, socket_events_.size()); } else { if (waitee->use_posix_socket == 1) { -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) posix_socket_to_index_map_.emplace(waitee->posix_socket, socket_events_.size()); #endif @@ -733,10 +733,10 @@ bool SbSocketWaiterPrivate::WaiteeRegistry::RemoveSocket(SbSocket socket) { const std::size_t socket_index = iterator->second; SbSocket socket_to_swap = waitees_[current_size - 1]->socket; + // Since |EraseIndexFromVector| will swap the last socket and the socket // at current index, |socket_to_index_| will need to be updated. socket_to_index_map_[socket_to_swap] = socket_index; - // Note that |EraseIndexFromVector| only touches the last element and the // element to remove. EraseIndexFromVector(&socket_events_, socket_index); diff --git a/starboard/shared/win32/socket_waiter_internal.h b/starboard/shared/win32/socket_waiter_internal.h index bc3fa2903c66..6b7fb9d06805 100644 --- a/starboard/shared/win32/socket_waiter_internal.h +++ b/starboard/shared/win32/socket_waiter_internal.h @@ -48,7 +48,7 @@ class SbSocketWaiterPrivate { ~SbSocketWaiterPrivate(); // These methods implement the SbSocketWaiter API defined in socket_waiter.h. -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) bool Add(int socket, SbSocketWaiter waiter, void* context, @@ -57,14 +57,13 @@ class SbSocketWaiterPrivate { bool persistent); bool Remove(int socket, SbSocketWaiter waiter); bool CheckSocketRegistered(int socket); -#endif // SB_API_VERSION >= 16 +#endif // SB_API_VERSION >= 16 && !defined(_MSC_VER) bool Add(SbSocket socket, void* context, SbSocketWaiterCallback callback, int interests, bool persistent); bool Remove(SbSocket socket); - void Wait(); SbSocketWaiterResult WaitTimed(int64_t duration_usec); void WakeUp(); @@ -74,7 +73,7 @@ class SbSocketWaiterPrivate { private: // A registration of a socket with a socket waiter. struct Waitee { -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) Waitee(SbSocketWaiter waiter, int socket, sbwin32::AutoEventHandle* socket_event_ptr, @@ -99,7 +98,7 @@ class SbSocketWaiterPrivate { // The event related to the socket_handle. Used for SbSocketWaiter. sbwin32::AutoEventHandle* socket_event_ptr; -#endif // SB_API_VERSION >= 16 +#endif // SB_API_VERSION >= 16 && !defined(_MSC_VER) Waitee(SbSocketWaiter waiter, SbSocket socket, void* context, @@ -142,7 +141,7 @@ class SbSocketWaiterPrivate { typedef std::deque> Waitees; #if SB_API_VERSION >= 16 typedef std::unordered_map posix_SocketToIndex; -#endif // SB_API_VERSION >= 16 +#endif // SB_API_VERSION >= 16 && !defined(_MSC_VER) typedef std::unordered_map SocketToIndex; WSAEVENT* GetHandleArray() { return socket_events_.data(); } @@ -158,7 +157,7 @@ class SbSocketWaiterPrivate { // Returns true if socket was found, and removed. bool RemoveSocket(int socket); -#endif // SB_API_VERSION >= 16 +#endif // SB_API_VERSION >= 16 && !defined(_MSC_VER) // Gets the Waitee associated with the given socket, or nullptr. Waitee* GetWaitee(SbSocket socket); @@ -176,7 +175,7 @@ class SbSocketWaiterPrivate { std::unique_ptr waitee); private: -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) posix_SocketToIndex posix_socket_to_index_map_; #endif // SB_API_VERSION >= 16 SocketToIndex socket_to_index_map_; @@ -188,7 +187,7 @@ class SbSocketWaiterPrivate { void SignalWakeupEvent(); void ResetWakeupEvent(); -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) bool CheckSocketWaiterIsThis(int socket, SbSocketWaiter waiter); #endif // SB_API_VERSION >= 16 bool CheckSocketWaiterIsThis(SbSocket socket); diff --git a/starboard/shared/win32/socket_waiter_remove.cc b/starboard/shared/win32/socket_waiter_remove.cc index 165921b76133..e52195449edb 100644 --- a/starboard/shared/win32/socket_waiter_remove.cc +++ b/starboard/shared/win32/socket_waiter_remove.cc @@ -24,7 +24,7 @@ bool SbSocketWaiterRemove(SbSocketWaiter waiter, SbSocket socket) { return waiter->Remove(socket); } -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) bool SbPosixSocketWaiterRemove(SbSocketWaiter waiter, int socket) { if (!SbSocketWaiterIsValid(waiter)) { return false; diff --git a/starboard/socket_waiter.h b/starboard/socket_waiter.h index 7b5e02fce28b..ab2627a15778 100644 --- a/starboard/socket_waiter.h +++ b/starboard/socket_waiter.h @@ -149,7 +149,7 @@ SB_EXPORT bool SbSocketWaiterAdd(SbSocketWaiter waiter, int interests, bool persistent); -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) SB_EXPORT bool SbPosixSocketWaiterAdd(SbSocketWaiter waiter, int socket, void* context, @@ -171,7 +171,7 @@ SB_EXPORT bool SbPosixSocketWaiterAdd(SbSocketWaiter waiter, // |socket|: The socket to remove from the waiter. SB_EXPORT bool SbSocketWaiterRemove(SbSocketWaiter waiter, SbSocket socket); -#if SB_API_VERSION >= 16 +#if SB_API_VERSION >= 16 && !defined(_MSC_VER) SB_EXPORT bool SbPosixSocketWaiterRemove(SbSocketWaiter waiter, int socket); #endif