Skip to content

Commit

Permalink
fix: osx socket implementation (philips-software#232)
Browse files Browse the repository at this point in the history
Co-authored-by: Ron Jaegers <ron@brutal-monkey.nl>
  • Loading branch information
rjaegers and Ron Jaegers committed Mar 21, 2023
1 parent 89998d6 commit e127311
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions services/network_instantiations/ConnectionBsd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,19 +250,21 @@ namespace services
saddress.sin_port = htons(factory.Port());
if (connect(connectSocket, reinterpret_cast<sockaddr*>(&saddress), sizeof(saddress)) == -1)
{
if (errno != EWOULDBLOCK)
if (errno != EWOULDBLOCK && errno != EINPROGRESS)
std::abort();
}
}

ConnectorBsd::~ConnectorBsd()
{
close(connectSocket);
if (connectSocket != -1)
close(connectSocket);
}

void ConnectorBsd::Connected()
{
infra::SharedPtr<ConnectionBsd> connection = infra::MakeSharedOnHeap<ConnectionBsd>(network, connectSocket);
connectSocket = -1;
factory.ConnectionEstablished([connection](infra::SharedPtr<services::ConnectionObserver> connectionObserver)
{
if (connectionObserver)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ namespace services

for (auto& connector : connectors)
{
AddFileDescriptorToSet(connector.connectSocket, readFileDescriptors);
AddFileDescriptorToSet(connector.connectSocket, writeFileDescriptors);
AddFileDescriptorToSet(connector.connectSocket, exceptFileDescriptors);
}

Expand Down Expand Up @@ -217,7 +217,7 @@ namespace services

for (auto& connector : connectors)
{
if (FD_ISSET(connector.connectSocket, &readFileDescriptors))
if (FD_ISSET(connector.connectSocket, &writeFileDescriptors))
connector.Connected();
else if (FD_ISSET(connector.connectSocket, &exceptFileDescriptors))
connector.Failed();
Expand Down

0 comments on commit e127311

Please sign in to comment.