New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented bufferevent_socket_connect_hostname_hints() #193
Implemented bufferevent_socket_connect_hostname_hints() #193
Conversation
jspada
commented
Dec 8, 2014
- Implemented bufferevent_socket_connect_hostname_hints so that ai_flags (such as AI_ADDRCONFIG) can be specified.
- Added a simple unit test
ai_flags (such as AI_ADDRCONFIG) can be specified.
@@ -467,13 +467,27 @@ int | |||
bufferevent_socket_connect_hostname(struct bufferevent *bev, | |||
struct evdns_base *evdns_base, int family, const char *hostname, int port) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing to do with your patch, but this has always bugged me. We do an unnecessary check to make sure it's not negative and is less than 65535.
connect_hostname(..., ..., ..., ...., uint16_t port); /* sanity */
One silly thing I don't like is having an extra jump for a widely used function. Maybe something a little less overhead, for example: #define bufferevent_socket_connect_hostname(bev, dnsev, family, host, port) \
({ int res; \
struct addrinfo hint; \
\
memset(&hint, 0, sizeof(hint)); \
\
hint.ai_family = family; \
hint.ai_protocol = IPPROTO_TCP; \
hint.ai_socktype = SOCK_STREAM; \
\
res = bufferevent_socket_connect_hostname_hints( \
bev, dnsev, &hint, host, port); \
\
res; }) Yes. yes, statement expressions aren't portable with compilers circa 1982, but the point is made. |
Hi @ellzey, I don't like the idea with defines (especially for exported API), maybe adding |
@azat inlines are in most cases never really inlined. And we already use statement expressions in a few places aready. |
@ellzey my main macro cons -- they are not debugging friendly. As for P.S. firstly I replied via email (but github didn't accept this), so can be dup2 |
While working on the cmake refactor, I was wondering why the attribute was never taken into account.. The more we use [inlines|statements|macros] we must consider the size of the resulting objects. They grow with each reference. I've used this in the past without any pre-configure. It can be expanded upon. #if (__GNUC__ == 4 && __GNUC_MINOR__ >= 3 && defined(__GNUC_STDC_INLINE__) && !defined(C99_INLINE)) || \
(__APPLE_CC__ > 5400 && !defined(C99_INLINE) && __STDC_VERSION__ >= 199901L)
# define C99_INLINE 1
#endif
#if C99_INLINE || __GNUC_GNU_INLINE__
# define INLINE inline
# define HAS_INLINE 1
#else
# define INLINE /* no inline */
#endif |
Applied, thanks! (conflicts solved, test had been rewritten to avoid copy-paste) |