diff --git a/http-internal.h b/http-internal.h index 90fd7928..ba6e49ef 100644 --- a/http-internal.h +++ b/http-internal.h @@ -71,10 +71,11 @@ struct evhttp_connection { ev_uint64_t max_body_size; int flags; -#define EVHTTP_CON_INCOMING 0x0001 /* only one request on it ever */ -#define EVHTTP_CON_OUTGOING 0x0002 /* multiple requests possible */ -#define EVHTTP_CON_CLOSEDETECT 0x0004 /* detecting if persistent close */ -#define EVHTTP_CON_AUTOFREE 0x0008 /* set when we want to auto free the connection */ +#define EVHTTP_CON_INCOMING 0x0001 /* only one request on it ever */ +#define EVHTTP_CON_OUTGOING 0x0002 /* multiple requests possible */ +#define EVHTTP_CON_CLOSEDETECT 0x0004 /* detecting if persistent close */ +/* set when we want to auto free the connection */ +#define EVHTTP_CON_AUTOFREE EVHTTP_CON_PUBLIC_FLAGS_END struct timeval timeout; /* timeout for events */ int retry_cnt; /* retry count */ diff --git a/http.c b/http.c index 909af5e1..fd7ce3cb 100644 --- a/http.c +++ b/http.c @@ -2342,13 +2342,14 @@ void evhttp_connection_set_family(struct evhttp_connection *evcon, int evhttp_connection_set_flags(struct evhttp_connection *evcon, int flags) { - if (flags & ~(EVHTTP_CON_REUSE_CONNECTED_ADDR)) { + int avail_flags = 0; + avail_flags |= EVHTTP_CON_REUSE_CONNECTED_ADDR; + + if (flags & ~avail_flags || flags > EVHTTP_CON_PUBLIC_FLAGS_END) return 1; - } + evcon->flags &= ~avail_flags; - evcon->flags &= ~(EVHTTP_CON_REUSE_CONNECTED_ADDR); - - evcon->flags |= EVHTTP_CON_REUSE_CONNECTED_ADDR; + evcon->flags |= flags; return 0; } diff --git a/include/event2/http.h b/include/event2/http.h index 09fd8e1c..e9978207 100644 --- a/include/event2/http.h +++ b/include/event2/http.h @@ -637,7 +637,10 @@ EVENT2_EXPORT_SYMBOL void evhttp_connection_set_family(struct evhttp_connection *evcon, int family); -#define EVHTTP_CON_REUSE_CONNECTED_ADDR 0x0008 /* reuse connection address on retry */ +/* reuse connection address on retry */ +#define EVHTTP_CON_REUSE_CONNECTED_ADDR 0x0008 +/* Padding for public flags, @see EVHTTP_CON_* in http-internal.h */ +#define EVHTTP_CON_PUBLIC_FLAGS_END 0x100000 /** * Set connection flags. *