On 11/5/2016 10:32 AM, Ison wrote:
/    /* Upload file *///
//        if(CURLE_OK != (ret_val = curl_easy_perform(curl)))//
//        {//
//            //printf("Curl Perform Upload Failed...\n");//
// printf("Curl Perform Upload Failed...%d...%s\n", ret_val, curl_easy_strerror(ret_val));//
//*sleep(20);*//
//        }//
//        else//
//        {//
//            printf("Curl Perform Upload Success...\n");//
//            ret_val = g_SUCCESS_c;//
//        }//
//
//        fclose(p_file);//
//    }
}

/Now, if I disconnect my ethernet cable after the file upload has started, i.e, I am able to see the following prints in console

/UP: 0 of 0  DOWN: 0 of 0//
//UP: 0 of 0  DOWN: 0 of 0//
//UP: 0 of 0  DOWN: 0 of 0//
//UP: 0 of 0  DOWN: 0 of 0//
//UP: 0 of 0  DOWN: 0 of 0//
//UP: 0 of 0  DOWN: 0 of 0/

*Disconnect ethernet cable here*

/Curl Perform Upload Failed...28...Timeout was reached//

/I am able to continue with the rest of the operations after this/
/
But if I disconnect the cable before this prints starts, i.e when the library is trying to resolve the host name, I get the following output on console and a seg fault after some time

/Curl Perform Upload Failed...6...Couldn't resolve host name//
/
My application is simply waits at this print for 20 seconds. In this case I observe a segmentation fault occurring after around 10seconds every time.

The only difference between the two case is the time at which the ethernet cable was pulled out which gave two different errors. Do we have to do any other settings to handle an ethernet cable disconnection when host name resolving does not happen?

Try disabling signals, CURLOPT_NOSIGNAL [1]. Read thread safety [2] if you are using threads. Make a debug build using --enable-debug and give us the stacktrace from a crash, the curl_version() and what resolver libcurl is using [3].

Also check that p_file != NULL, it doesn't look like you're checking fopen return. IIRC it's not required by any C standard that fclose(NULL) be acceptable. It should be
if(p_file)
 fclose(p_file)
or better check it earlier and do not continue if NULL


[1]: https://curl.haxx.se/libcurl/c/CURLOPT_NOSIGNAL.html
[2]: https://curl.haxx.se/libcurl/c/threadsafe.html
[3]: https://gist.github.com/jay/d3323a81345e75462b70

-------------------------------------------------------------------
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:  https://curl.haxx.se/mail/etiquette.html

Reply via email to