From 23ef5e4ba22386ccc43f99db1d0f4106dc603e80 Mon Sep 17 00:00:00 2001 From: Gokhan Sengun Date: Mon, 25 Jun 2012 01:46:01 +0300 Subject: ftp: active conn, allow application to set sockopt after accept() call For active FTP connections, applications may need setting the sockopt after accept() call returns successful. This fix gives a call to the callback registered with CURL_SOCKOPTFUNCTION option. Also a new sock type - CURLSOCKTYPE_ACCEPT - is added. This type is to be passed to application callbacks with - purpose - parameter. Applications may use this parameter to distinguish between socket types. --- lib/ftp.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'lib') diff --git a/lib/ftp.c b/lib/ftp.c index 438ccfc0f..923fc3dd4 100644 --- a/lib/ftp.c +++ b/lib/ftp.c @@ -348,6 +348,20 @@ static CURLcode AcceptServerConnect(struct connectdata *conn) } infof(data, "Connection accepted from server\n"); + if(data->set.fsockopt) { + int error = 0; + + /* activate callback for setting socket options */ + error = data->set.fsockopt(data->set.sockopt_client, + s, + CURLSOCKTYPE_ACCEPT); + + if(error) { + Curl_closesocket(conn, s); /* close the socket and bail out */ + return CURLE_ABORTED_BY_CALLBACK; + } + } + conn->sock[SECONDARYSOCKET] = s; curlx_nonblock(s, TRUE); /* enable non-blocking */ conn->sock_accepted[SECONDARYSOCKET] = TRUE; -- cgit v1.2.3