[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [Libevent-users] evhttp client error handling



On 11/01/2012 09:13 PM, Patrick Pelletier wrote:
Anyway, the error stack does seem to be empty, because "ERR_print_errors_fp (stderr);" does not print anything. So, that means I should look at errno, which is ENOTCONN.

So, I figured out that I shouldn't be looking at the OpenSSL error stack, because libevent squirrels it away to be retrieved by bufferevent_get_openssl_error(). Although, in this case, it doesn't matter, because that error stack is empty, too.

I'm guessing here that there was some sort of error establishing the SSL connection, but we didn't notice or handle it, and forging ahead after the connection failed is what earned us ENOTCONN.

Assuming this hypothesis is correct, any thoughts on at what point libevent would have tried reporting that initial failure back to me, and what I would need to do to be notified of it?

So, I figured out that the initial error that's occurring is EAFNOSUPPORT. (Now, why that's happening is a separate mystery I need to figure out... it happens when I use "localhost" as the hostname, but not when I use "127.0.0.1".) However, the call to evhttp_connection_reset_ in evhttp_connection_fail_ is overwriting errno to be ENOTCONN, so that's the errno I see when my callback is called. I'm thinking that evhttp_connection_fail_ should save and restore errno, so that the callback can see what the original cause of the error is?

I'll probably submit a pull request for saving and restoring errno in evhttp_connection_fail_. (I know I've been submitting a bunch of tiny, one-or-two line pull requests to github lately. I don't know if that's what I ought to be doing, or not.)

Although there's still something going on I don't get, because after my callback returns, libevent still seems to forge ahead, and has some fatal indigestion:

[warn] Epoll MOD(4) on fd 7 failed. Old events were 6; read change was 2 (del); write change was 0 (none): Bad file descriptor [warn] Epoll MOD(1) on fd 7 failed. Old events were 6; read change was 0 (none); write change was 2 (del): Bad file descriptor
[err] http.c:688: Assertion req != NULL failed in evhttp_connection_fail_
Aborted

But I haven't yet worked out what's causing that, or how to prevent it. Is there something my callback should do, to tell libevent "stop trying to do stuff with this connection... it's dead?"

--Patrick

***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.