File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -1401,6 +1401,10 @@ static int mariadb_dr_socket_cloexec(my_socket sock_os)
14011401 DWORD flags ;
14021402 int error ;
14031403
1404+ /* Ignore connections without valid socket handle */
1405+ if (sock_os == 0 )
1406+ return 0 ;
1407+
14041408 if (!GetHandleInformation (handle , & flags ))
14051409 {
14061410 error = GetLastError ();
@@ -2413,17 +2417,19 @@ static bool mariadb_dr_connect(
24132417 /*
24142418 Client library returns socket in my_socket type, which is C file
24152419 descriptor on Linux or Windows native socket type on Windows.
2420+ On Windows it can be zero in case connection type is not socket.
24162421 Perl requires sockets to always be in C file descriptor type,
24172422 so on Windows associate it with C file descriptor via Perl's
24182423 win32_open_osfhandle() function.
24192424 */
24202425#ifdef _WIN32
2421- imp_dbh -> sock_fd = win32_open_osfhandle (sock_os , O_RDWR |O_BINARY );
2426+ imp_dbh -> sock_fd = sock_os != 0 ? win32_open_osfhandle (sock_os , O_RDWR |O_BINARY ) : -1 ;
24222427#else
24232428 imp_dbh -> sock_fd = sock_os ;
24242429#endif
24252430
24262431#ifdef _WIN32
2432+ if (imp_dbh -> sock_fd >= 0 )
24272433 {
24282434 /*
24292435 * Winsock SO_UPDATE_CONNECT_CONTEXT option needs to be set on the socket,
You can’t perform that action at this time.
0 commit comments