curl-library
Re: curl exception with bad url
Date: Tue, 23 Aug 2011 09:44:30 -0400
On Tue, Aug 23, 2011 at 2:46 AM, Daniel Stenberg <daniel_at_haxx.se> wrote:
> On Mon, 22 Aug 2011, Robert Navarro wrote:
>
>
> Perhaps an exception was raised in one of the callbacks, since they can
> use C++ features. The source code for the callbacks wasn't shown, so
> it's hard to say.
>
>>>> Dan
Dan,
Here are the callbacks I use. Please note that these work fine from
another execution path, in that if the receiving system is down, I get
an actual timeout response. If the receiving system is up, I am able
to get the response data as well.
// for POST response callback
struct MemoryStruct {
char *memory;
size_t size;
};
// callback to receive POST response
static size_t WriteMemoryCallback(void *ptr, size_t size, size_t
nmemb, void *data)
{
size_t realsize = size * nmemb;
struct MemoryStruct *mem = (struct MemoryStruct *)data;
mem->memory = new char[mem->size + realsize + 1];
if (mem->memory == NULL) {
return -1;
}
memcpy(&(mem->memory[mem->size]), ptr, realsize);
mem->size += realsize;
mem->memory[mem->size] = 0;
return realsize;
}
> When people mix the words stop and crash to describe an error a little alarm
> bell goes off in my head. (Mostly because what a 'crash' constitutes to
> people seem to vary greatly and often mismatches with my own perception of
> what a crash is.)
>
> What exactly are you saying happens? If you add a printf() line below the
> call to curl_easy_perform() that outputs 'res', what does it show?
>
Daniel,
Sorry for the confusion! When I say stop, I mean the windows service
is suddenly in the stopped state. There is no entry in the Event
Viewer log to indicate something happened.
This tells me a crash occurred, at the execution of this line. There
is a logging line directly below and above the perform. The lines
below do not execute at all.
The really confusing part is when this crash occurs. There are two
separate execution paths which end up running this same code, and they
do not occur in the same way.
The first way, a socket is opened, the service receives data,
processes it, and then sends xml via POST to the specified URL. With
this execution path, given a bad URL or non-responsive receiver, I
actually get the timeout message, and no crash occurs. Everything
works as I would expect, except for a crash later on when trying to
close the initial socket. (Kind of a separate thread but I am
wondering if libcurl closes the existing socket when it times-out?)
The second execution path involves the service reading data from a
database, building an XML message, and sending that via POST using the
same code above. However, if the same URL used above is
non-responsive, the crash occurs, and I get no information past the
perform line.
So I guess the question is, why do I not get a timeout response with
the second path, when the same code gives it to me with the first?
Robert
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-08-23