Skip to content

Commit

Permalink
handle feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jmillan committed Dec 19, 2023
1 parent 1277f5c commit 8841ec4
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 16 deletions.
12 changes: 1 addition & 11 deletions worker/include/Utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,7 @@ namespace Utils

static void GetAddressInfo(const struct sockaddr* addr, int& family, std::string& ip, uint16_t& port);

static size_t GetAddressLen(const struct sockaddr* addr)
{
if (addr->sa_family == AF_INET)
{
return sizeof(struct sockaddr_in);
}
else
{
return sizeof(struct sockaddr_in6);
}
}
static size_t GetAddressLen(const struct sockaddr* addr);

static bool CompareAddresses(const struct sockaddr* addr1, const struct sockaddr* addr2)
{
Expand Down
10 changes: 5 additions & 5 deletions worker/src/DepLibUring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,22 @@ inline static void onFdEvent(uv_poll_t* handle, int status, int events)
continue;
}

// Failed SQE.
if (cqe->res < 0)
// Successfull SQE.
if (cqe->res >= 0)
{
if (userData->cb)
{
(*userData->cb)(false);
(*userData->cb)(true);
delete userData->cb;
userData->cb = nullptr;
}
}
// Successfull SQE.
// Failed SQE.
else
{
if (userData->cb)
{
(*userData->cb)(true);
(*userData->cb)(false);
delete userData->cb;
userData->cb = nullptr;
}
Expand Down
23 changes: 23 additions & 0 deletions worker/src/Utils/IP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,29 @@ namespace Utils
ip.assign(ipBuffer);
}

size_t IP::GetAddressLen(const struct sockaddr* addr)
{
MS_TRACE();

switch (addr->sa_family)
{
case AF_INET:
{
return sizeof(struct sockaddr_in);
}

case AF_INET6:
{
return sizeof(struct sockaddr_in6);
}

default:
{
MS_ABORT("unknown network family: %d", static_cast<int>(addr->sa_family));
}
}
}

void IP::NormalizeIp(std::string& ip)
{
MS_TRACE();
Expand Down

0 comments on commit 8841ec4

Please sign in to comment.