Skip to content

Commit

Permalink
Rename parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
d-frey committed Dec 1, 2023
1 parent 2a71f80 commit cdbb45e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion include/tao/pq/internal/poll.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace tao::pq::internal
{
[[nodiscard]] auto poll( const int socket, const bool wait_for_write, const int timeout ) -> pq::poll::status;
[[nodiscard]] auto poll( const int socket, const bool wait_for_write, const int timeout_ms ) -> pq::poll::status;

} // namespace tao::pq::internal

Expand Down
2 changes: 1 addition & 1 deletion include/tao/pq/poll.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace tao::pq::poll
again
};

using callback = status( const int socket, const bool wait_for_write, const int timeout );
using callback = status( const int socket, const bool wait_for_write, const int timeout_ms );

} // namespace tao::pq::poll

Expand Down
10 changes: 5 additions & 5 deletions src/lib/pq/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,15 +220,15 @@ namespace tao::pq
void connection::wait( const bool wait_for_write, const std::chrono::steady_clock::time_point end )
{
while( true ) {
int timeout = -1;
int timeout_ms = -1;
if( m_timeout ) {
timeout = static_cast< int >( std::chrono::duration_cast< std::chrono::milliseconds >( end - std::chrono::steady_clock::now() ).count() );
if( timeout < 0 ) {
timeout = 0; // LCOV_EXCL_LINE
timeout_ms = static_cast< int >( std::chrono::duration_cast< std::chrono::milliseconds >( end - std::chrono::steady_clock::now() ).count() );
if( timeout_ms < 0 ) {
timeout_ms = 0; // LCOV_EXCL_LINE
}
}

switch( m_poll( socket(), wait_for_write, timeout ) ) {
switch( m_poll( socket(), wait_for_write, timeout_ms ) ) {
case poll::status::timeout:
m_pgconn.reset();
throw timeout_reached( "timeout reached" );
Expand Down
6 changes: 3 additions & 3 deletions src/lib/pq/internal/poll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ namespace tao::pq::internal

} // namespace

auto poll( const int socket, const bool wait_for_write, const int timeout ) -> pq::poll::status
auto poll( const int socket, const bool wait_for_write, const int timeout_ms ) -> pq::poll::status
{
#if defined( _WIN32 )

const short events = POLLIN | ( wait_for_write ? POLLOUT : 0 );
WSAPOLLFD pfd = { static_cast< SOCKET >( socket ), events, 0 };
const auto result = WSAPoll( &pfd, 1, timeout );
const auto result = WSAPoll( &pfd, 1, timeout_ms );
switch( result ) {
case 0:
return pq::poll::status::timeout;
Expand All @@ -85,7 +85,7 @@ namespace tao::pq::internal
const short events = POLLIN | ( wait_for_write ? POLLOUT : 0 );
pollfd pfd = { socket, events, 0 };
errno = 0;
const auto result = ::poll( &pfd, 1, timeout );
const auto result = ::poll( &pfd, 1, timeout_ms );
switch( result ) {
case 0:
return pq::poll::status::timeout;
Expand Down

0 comments on commit cdbb45e

Please sign in to comment.