On Wed, Aug 11, 2010 at 21:34:28 +0000, Adolfo Builes wrote:
> Tue Aug 10 16:55:22 COT 2010  builes.adolfo@googlemail.com
>   * Correct error code for curl operation timeout
Applied in an earlier run
> Wed Aug 11 16:21:21 COT 2010  builes.adolfo@googlemail.com
>   * Add environment variable DARCS_CONNECTION_TIMEOUT
I pushed this, but then I realised we could maybe do it in a
simpler way if you'd like to follow up.
Add environment variable DARCS_CONNECTION_TIMEOUT
-------------------------------------------------
> -    ce <- if not (null e)
> -          then do
> +    ce <- do
>             errorNum <- peek errorPointer
...
> -           case errorNum of
> -             6  -> return $ Just CouldNotResolveHost
> -             7  -> return $ Just CouldNotConnectToServer
> -             28 -> return $ Just OperationTimeout
> -             _  -> return Nothing
> -          else
> -           return Nothing
> +           if not (null e)
> +             then do
> +              case errorNum of
> +                6  -> return $ Just CouldNotResolveHost
> +                7  -> return $ Just CouldNotConnectToServer
> +                28 -> return $ Just OperationTimeout
> +                _  -> return Nothing
> +             else do
> +              when (errorNum == 90 ) $ debugMessage "The environment variable DARCS_CONNECTION_TIMEOUT doesn't represent a number"
> +              return Nothing
We've added a new check to for nonsense DARCS_CONNECTION_TIMEOUT
There's a tiny bit of rearranging needed because here we also need
to deal with a case where the curl_wait_url does not return an error
string.
>  
> hunk ./src/hscurl.c 279
>        CURL *easy = msg->easy_handle;
>        CURLcode result = msg->data.result;
>        struct UrlData *url_data;
> -      int error = curl_easy_getinfo(easy, CURLINFO_PRIVATE, (char **)&url_data);
> +
> +      int error = set_time_out(easy,errorCode);
> +      if (error != CURLE_OK ){
> +        *errorCode = error;
> +        return curl_easy_strerror(error);
> +      }
So my question here would be, how about extending the error array
and returning a pointer to that if error == 90?
That would allow you to have simpler code in the URL module.
Anyway, I suppose it's not a big deal and you're suggesting we could
ditch hscurl.c in favour of in Haskell using the FFI layer to talk to
curl itself.
> +int set_time_out(CURL *handle, int* errorCode)
> +{
> +  int error;
> +  long time_out = DEFAULT_CONNECTION_TIMEOUT;
> +  const char *stime_out;
> +
> +  stime_out = getenv("DARCS_CONNECTION_TIMEOUT");
> +  if (stime_out != NULL){
> +    long result = atol (stime_out);
> +    if ( result > 0 )
> +      time_out = result;
> +    else
> +      *errorCode = 90 ;
> +  }
> +
> +  error = curl_easy_setopt(handle, CURLOPT_TIMEOUT, time_out);
> +
> +  return error;
> +}
Helper function for the curl timeout setting.
-- 
Eric Kow <http://www.nltg.brighton.ac.uk/home/Eric.Kow>
For a faster response, please try +44 (0)1273 64 2905.
    
    |