Skip to content

Commit

Permalink
Merge branch '3.1' into 3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
9EOR9 committed Jul 24, 2022
2 parents 6dbd953 + dfe3563 commit cb6d03f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions plugins/pvio/pvio_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,10 @@ static int pvio_socket_internal_connect(MARIADB_PVIO *pvio,
int rc= 0;
struct st_pvio_socket *csock= NULL;
int timeout;
#ifndef _WIN32
unsigned int wait_conn= 1;
time_t start_t= time(NULL);
#endif

if (!pvio || !pvio->data)
return 1;
Expand All @@ -640,6 +644,13 @@ static int pvio_socket_internal_connect(MARIADB_PVIO *pvio,
#ifndef _WIN32
do {
rc= connect(csock->socket, (struct sockaddr*) name, (int)namelen);

if (time(NULL) - start_t > (time_t)timeout/1000)
break;

usleep(wait_conn);
wait_conn= wait_conn >= 1000000 ? 1000000 : wait_conn * 2;

} while (rc == -1 && (errno == EINTR || errno == EAGAIN));
/* in case a timeout values was set we need to check error values
EINPROGRESS */
Expand Down Expand Up @@ -1126,3 +1137,4 @@ int pvio_socket_shutdown(MARIADB_PVIO *pvio)
}
return -1;
}

0 comments on commit cb6d03f

Please sign in to comment.