You've already forked mariadb-connector-c
mirror of
https://github.com/mariadb-corporation/mariadb-connector-c.git
synced 2025-08-08 14:02:17 +03:00
When an attempt to open a unix sucket failed, the socket was not properly closed.
This commit is contained in:
@@ -772,10 +772,12 @@ my_bool pvio_socket_connect(MARIADB_PVIO *pvio, MA_PVIO_CINFO *cinfo)
|
|||||||
{
|
{
|
||||||
PVIO_SET_ERROR(cinfo->mysql, CR_CONNECTION_ERROR, SQLSTATE_UNKNOWN,
|
PVIO_SET_ERROR(cinfo->mysql, CR_CONNECTION_ERROR, SQLSTATE_UNKNOWN,
|
||||||
ER(CR_CONNECTION_ERROR), cinfo->unix_socket, socket_errno);
|
ER(CR_CONNECTION_ERROR), cinfo->unix_socket, socket_errno);
|
||||||
|
closesocket(csock->socket);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (pvio_socket_blocking(pvio, 1, 0) == SOCKET_ERROR)
|
if (pvio_socket_blocking(pvio, 1, 0) == SOCKET_ERROR)
|
||||||
{
|
{
|
||||||
|
closesocket(csock->socket);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@@ -978,7 +978,36 @@ static int test_sess_track_db(MYSQL *mysql)
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int test_unix_socket_close(MYSQL *unused __attribute__((unused)))
|
||||||
|
{
|
||||||
|
MYSQL *mysql= mysql_init(NULL);
|
||||||
|
FILE *fp;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (!(fp= fopen("./dummy_sock", "w")))
|
||||||
|
{
|
||||||
|
diag("couldn't create dummy socket");
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
|
for (i=0; i < 10000; i++)
|
||||||
|
{
|
||||||
|
mysql_real_connect(mysql, "localhost", "user", "passwd", NULL, 0, "./dummy_sock", 0);
|
||||||
|
/* check if we run out of sockets */
|
||||||
|
if (mysql_errno(mysql) == 2001)
|
||||||
|
{
|
||||||
|
diag("out of sockets after %d attempts", i);
|
||||||
|
mysql_close(mysql);
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mysql_close(mysql);
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
struct my_tests_st my_tests[] = {
|
struct my_tests_st my_tests[] = {
|
||||||
|
{"test_unix_socket_close", test_unix_socket_close, TEST_CONNECTION_NONE, 0, NULL, NULL},
|
||||||
{"test_sess_track_db", test_sess_track_db, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
{"test_sess_track_db", test_sess_track_db, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||||
{"test_get_options", test_get_options, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
{"test_get_options", test_get_options, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||||
{"test_wrong_bind_address", test_wrong_bind_address, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
{"test_wrong_bind_address", test_wrong_bind_address, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||||
|
Reference in New Issue
Block a user