Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Windows] libcurl 7.88.0 - Immediate connect fail for x.x.x.x: Socket is already connected #10626

Closed
sjadhavar opened this issue Feb 27, 2023 · 2 comments

Comments

@sjadhavar
Copy link
Contributor

sjadhavar commented Feb 27, 2023

I downloaded libcurl version 7.88.0 and used it in my application on Windows box. But I am seeing failure in my application and curl log shows below error.

curl_debug_logger(): == Info: Added my_host_name:1555:x.x.x.x to DNS cache
curl_debug_logger(): == Info: Hostname my_host_name was found in DNS cache
curl_debug_logger(): == Info: Trying x.x.x.x:1555...
curl_debug_logger(): == Info: Immediate connect fail for x.x.x.x: Socket is already connected
curl_debug_logger(): == Info: Failed to connect to my_host_name port 1555 after 0 ms: Couldn't connect to server
curl_debug_logger(): == Info: Closing connection 0

I tried with curl version 7.88.1 too, but same issue. Also issue is seen on Windows platform only, on RHEL it works fine.
If I use curl version 7.87.0 then it works properly.

curl/libcurl version

7.88.0

operating system

Windows

@bagder
Copy link
Member

bagder commented Feb 27, 2023

You need to give us more details. How can we reproduce this?

@sjadhavar
Copy link
Contributor Author

sjadhavar commented Mar 1, 2023

This issue happens only when we use CURLOPT_OPENSOCKETFUNCTION and CURLOPT_SOCKOPTFUNCTION socket options to use the application created sockets by curl library.

In curl 7.87.0 version it was working fine but below commit (available in 7.88.0) broke this functionality.
71b7e01#diff-96ac2b9e301765fa5e816e0c41282610e9c0193a5852cc9bb0ed053b1fc4ef7f

In 7.87.0, if callback method for CURLOPT_SOCKOPTFUNCTION returns CURL_SOCKOPT_ALREADY_CONNECTED then curl library used to return CURLE_OK.

In 7.88.0, now even if callback returns CURL_SOCKOPT_ALREADY_CONNECTED, curl library still tries to connect to socket by invoking method [in file cf-socket.c/ function cf_tcp_connect() ]

/* Connect TCP socket */
rc = do_connect(cf, data, cf->conn->bits.tcp_fastopen);

And then it fails with WSAEISCONN error i.e. ("Socket is already connected").

sjadhavar added a commit to sjadhavar/curl that referenced this issue Mar 1, 2023
This will fix the issue mentioned at curl#10626

In 7.87.0, if callback method for CURLOPT_SOCKOPTFUNCTION returns CURL_SOCKOPT_ALREADY_CONNECTED then curl library used to return CURLE_OK.
n 7.88.0, now even if callback returns CURL_SOCKOPT_ALREADY_CONNECTED, curl library still tries to connect to socket by invoking method do_connect().

This is regression caused by commit 
curl@71b7e01#diff-96ac2b9e301765fa5e816e0c41282610e9c0193a5852cc9bb0ed053b1fc4ef7f

Fix: Check if we are already connected and return CURLE_OK.
@bagder bagder closed this as completed in 233810b Mar 1, 2023
@sjadhavar sjadhavar changed the title [Windows] libcurl 7.88.0 - Immediate connect fail for: Socket is already connected [Windows] libcurl 7.88.0 - Immediate connect fail for x.x.x.x: Socket is already connected Mar 8, 2023
bch pushed a commit to bch/curl that referenced this issue Jul 19, 2023
In 7.87.0, if callback method for CURLOPT_SOCKOPTFUNCTION returns
CURL_SOCKOPT_ALREADY_CONNECTED then curl library used to return
CURLE_OK.  n 7.88.0, now even if callback returns
CURL_SOCKOPT_ALREADY_CONNECTED, curl library still tries to connect to
socket by invoking method do_connect().

This is regression caused by commit
curl@71b7e0161032927cdfb

Fix: Check if we are already connected and return CURLE_OK.

Fixes curl#10626
Closes curl#10648
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants