evcon->ai_family = family;
}
+int evhttp_connection_set_flags(struct evhttp_connection *evcon,
+ int flags)
+{
+ if (flags & ~(EVHTTP_CON_REUSE_CONNECTED_ADDR)) {
+ return 1;
+ }
+
+ evcon->flags &= ~(EVHTTP_CON_REUSE_CONNECTED_ADDR);
+
+ evcon->flags |= EVHTTP_CON_REUSE_CONNECTED_ADDR;
+
+ return 0;
+}
+
void
evhttp_connection_set_base(struct evhttp_connection *evcon,
struct event_base *base)
evcon->state = EVCON_CONNECTING;
- if (sa && (sa->sa_family == AF_INET || sa->sa_family == AF_INET6)) {
+ if (evcon->flags & EVHTTP_CON_REUSE_CONNECTED_ADDR &&
+ sa &&
+ (sa->sa_family == AF_INET || sa->sa_family == AF_INET6)) {
int socklen;
if (sa->sa_family == AF_INET) {
socklen = sizeof(struct sockaddr_in);
void evhttp_connection_set_family(struct evhttp_connection *evcon,
int family);
+#define EVHTTP_CON_REUSE_CONNECTED_ADDR 0x0008 /* reuse connection address on retry */
+/**
+ * Set connection flags.
+ *
+ * @see EVHTTP_CON_*
+ * @return 0 on success, otherwise non zero (for example if flag doesn't
+ * supported).
+ */
+EVENT2_EXPORT_SYMBOL
+int evhttp_connection_set_flags(struct evhttp_connection *evcon,
+ int flags);
+
/** Takes ownership of the request object
*
* Can be used in a request callback to keep onto the request until
evcon = evhttp_connection_base_new(data->base, dns_base, addr, port);
tt_assert(evcon);
+ if (dns_base)
+ tt_assert(!evhttp_connection_set_flags(evcon, EVHTTP_CON_REUSE_CONNECTED_ADDR));
evhttp_connection_set_timeout(evcon, 1);
/* also bind to local host */