> Here's my two new test cases to verify that open/close socket callback are
>> paired up properly - test 596 currently fails due to this mentioned bug.
>> I'm slowly working on a fix.
>>
>
> I've now pushed a series of 4 commits that fixed this problem together
> with the two new test cases that verify the socket open/close callbacks for
> FTP.
>
> Thanks for the report!
>

Thanks for the fixes. Merging and testing the fix today, I noticed a small
problem. When the connection is re-used, opensocket calls are not matching
closesocket calls because conn->sock_accepted[SECONDARYSOCKET] is never set
to FALSE after being set to TRUE in the first accept.

Below change seems to fix the problem. Any comment?

int Curl_closesocket(struct connectdata *conn,
                     curl_socket_t sock)
{
  if(conn && conn->fclosesocket) {
    if((sock != conn->sock[SECONDARYSOCKET]) ||
       !conn->sock_accepted[SECONDARYSOCKET])
       /* if this socket matches the second socket, and that was created
with
          accept, then we MUST NOT call the callback */
      return conn->fclosesocket(conn->closesocket_client, sock);

    if(conn->sock_accepted[SECONDARYSOCKET])
      conn->sock_accepted[SECONDARYSOCKET] = FALSE;
  }

  return sclose(sock);
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Reply via email to