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

Re: [Libevent-users] strange exit with hand-made socket and bufferevent



On Sun, Feb 21, 2010 at 10:08 AM, Mihai Draghicioiu
<mihai.draghicioiu@xxxxxxxxx> wrote:
> Thanks Nick!
>
> Yes, the last commit fixed the example. I was compiling it with g++
> and that's probably why it worked.
>
> As for my program, i fixed it by using
> bufferevent_socket_connect_hostname instead of evdns_* calls.
>
> Questions:
> 1. What happens if the dns resolver fails? Does it retry? Does it give
> up? How do I know what happened?

It gives up, I believe.  Check out the "timeout" option described at
http://www.wangafu.net/~nickm/libevent-book/Ref9_dns.html for more
info on how long it waits for an answer by default.

If you're doing the query via bufferevent_socket_connect_hostname()
and the name lookup fails for any reason, you should get an error
callback.  Right now there isn't a good way to extract the DNS error
from it, though I'd love to add one.

> 2. What happened to EVUTIL_CHECK_FMT? It was useful. What can I replace it with.

It got removed, since (as a non-network-related thing that Libevent
doesn't actually need for anything) it really doesn't belong exposed
from Libevent.  [We don't want to mission-creep till we're a glib or
an apr or anspr.]  Since it was only introduced in 2.0.1-alpha, we
could remove it without breaking backward compatibility with any
stable version.

If you want one, you can define one trivially as

#ifdef __GNUC__
#define MY_CHECK_FMT(a,b)  __attribute__((format(printf, a, b)))
#else
#define MY_CHECK_FMT(a,b)
#endif

You can find out about dozens more gcc attributes like this by reading
the language extensions part of your gcc manual.  IMO it's a
delightful way to spend an evening IMO.

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