Skip to content

Commit

Permalink
Revert "redis_connection: Add local_address()"
Browse files Browse the repository at this point in the history
This reverts commit 33ca44b.
  • Loading branch information
lhmouse committed May 13, 2024
1 parent 6d00bc2 commit b057aa3
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 35 deletions.
27 changes: 0 additions & 27 deletions poseidon/redis/redis_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,33 +129,6 @@ execute(const cow_string* cmds, size_t ncmds)
this->m_reply->str);
}

// Get the local address.
::sockaddr_storage ss;
::socklen_t sslen = sizeof(ss);
if(::getsockname(this->m_redis->fd, (::sockaddr*) &ss, &sslen) != 0)
POSEIDON_THROW((
"Could not get local address: ${errno:full}",
"[`getsockname()` failed]"));

switch(ss.ss_family)
{
case AF_INET:
// IPv4
::memcpy(this->m_local_addr.mut_data(), ipv4_unspecified.data(), 12);
::memcpy(this->m_local_addr.mut_data() + 12, &(((::sockaddr_in*) &ss)->sin_addr), 4);
this->m_local_addr.set_port(ROCKET_BETOH16(((::sockaddr_in*) &ss)->sin_port));
break;

case AF_INET6:
// IPv6
::memcpy(this->m_local_addr.mut_data(), &(((::sockaddr_in6*) &ss)->sin6_addr), 16);
this->m_local_addr.set_port(ROCKET_BETOH16(((::sockaddr_in6*) &ss)->sin6_port));
break;

default:
POSEIDON_THROW(("Socket address family `$1` not supported"), ss.ss_family);
}

this->m_password.clear();
this->m_password.shrink_to_fit();
this->m_connected = true;
Expand Down
8 changes: 0 additions & 8 deletions poseidon/redis/redis_connection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

#include "../fwd.hpp"
#include "enums.hpp"
#include "../socket/ipv6_address.hpp"
#include "../third/redis_fwd.hpp"
namespace poseidon {

Expand All @@ -22,7 +21,6 @@ class Redis_Connection
bool m_reset_clear;
char m_reserved_1;
char m_reserved_2;
IPv6_Address m_local_addr;
steady_time m_time_pooled;

uniptr_redisContext m_redis;
Expand All @@ -44,12 +42,6 @@ class Redis_Connection
service_uri() const noexcept
{ return this->m_service_uri; }

// Gets the local address if the connection has been established. If no
// query has been made, `ipv6_unspecified` is returned.
const IPv6_Address&
local_address() const noexcept
{ return this->m_local_addr; }

// Resets the connection so it can be reused by another thread. This is a
// blocking functions. DO NOT ATTEMPT TO REUSE THE CONNECTION IF THIS
// FUNCTION RETURNS `false`.
Expand Down

0 comments on commit b057aa3

Please sign in to comment.