Skip to content

Commit

Permalink
fix: gettimeofday() expects two arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Kruse committed Feb 18, 2014
1 parent 10ca803 commit f080792
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions dbutils.c
Expand Up @@ -19,6 +19,7 @@

#include <unistd.h>
#include <time.h>
#include <sys/time.h>

#include "repmgr.h"
#include "strutil.h"
Expand Down Expand Up @@ -433,6 +434,7 @@ wait_connection_availability(PGconn *conn, unsigned long timeout)
fd_set read_set;
int sock = PQsocket(conn);
struct timeval tmout, before, after;
struct timezone tz;

/* recalc to microseconds */
timeout *= 1000000;
Expand Down Expand Up @@ -463,15 +465,15 @@ wait_connection_availability(PGconn *conn, unsigned long timeout)
FD_ZERO(&read_set);
FD_SET(sock, &read_set);

gettimeofday(&before);
gettimeofday(&before, &tz);
if (select(sock, &read_set, NULL, NULL, &tmout) == -1)
{
log_warning(
_("wait_connection_availability: select() returned with error: %s"),
strerror(errno));
return -1;
}
gettimeofday(&after);
gettimeofday(&after, &tz);

timeout -= (after.tv_sec * 1000000 + after.tv_usec) -
(before.tv_sec * 1000000 + before.tv_usec);
Expand Down

0 comments on commit f080792

Please sign in to comment.