mirror of
https://github.com/libevent/libevent.git
synced 2025-01-31 09:12:55 +08:00
Treat the bitwise OR of two enum values as an int.
This makes our interfaces usable from C++, which doesn't believe you can say "bufferevent_socket_nase(base, -1, BEV_OPT_CLOSE_ON_FREE|BEV_OPT_DEFER_CALLBACKS)" but which instead would demand "static_cast<bufferevent_options>(BEV_OPT_CLOSE_ON_FREE| BEV_OPT_DEFER_CALLBACKS))" for the last argument. Diagnosis and patch from Chris Davis. svn:r1456
This commit is contained in:
parent
4fbac2a5ae
commit
b73ad7bc45
@ -31,6 +31,7 @@ Changes in 2.0.3-alpha:
|
||||
o Make the event_base_loop() family of functions respect thread-safety better. This should clear up a few hard-to-debug race conditions.
|
||||
o Fix a bug when using a specialized memory allocator on win32.
|
||||
o Have the win32 select() backend label TCP-socket-connected events as EV_WRITE, not EV_READ. This should bring it in line with the other backends, and improve portability. Patch from Christopher Davis.
|
||||
o Stop using enums as arguments or return values when what we mean is a bitfield of enum values. C++ doesn't believe that you can OR two enum values together and get another enum, and C++ takes its typing seriously. Patch from Christopher Davis.
|
||||
|
||||
|
||||
Changes in 2.0.2-alpha:
|
||||
|
@ -165,12 +165,12 @@ struct bufferevent *
|
||||
bufferevent_filter_new(struct bufferevent *underlying,
|
||||
bufferevent_filter_cb input_filter,
|
||||
bufferevent_filter_cb output_filter,
|
||||
enum bufferevent_options options,
|
||||
int options,
|
||||
void (*free_context)(void *),
|
||||
void *ctx)
|
||||
{
|
||||
struct bufferevent_filtered *bufev_f;
|
||||
enum bufferevent_options tmp_options = options & ~BEV_OPT_THREADSAFE;
|
||||
int tmp_options = options & ~BEV_OPT_THREADSAFE;
|
||||
|
||||
if (!input_filter)
|
||||
input_filter = be_null_filter;
|
||||
|
@ -1047,11 +1047,11 @@ bufferevent_openssl_new_impl(struct event_base *base,
|
||||
evutil_socket_t fd,
|
||||
SSL *ssl,
|
||||
enum bufferevent_ssl_state state,
|
||||
enum bufferevent_options options)
|
||||
int options)
|
||||
{
|
||||
struct bufferevent_openssl *bev_ssl = NULL;
|
||||
struct bufferevent_private *bev_p = NULL;
|
||||
enum bufferevent_options tmp_options = options & ~BEV_OPT_THREADSAFE;
|
||||
int tmp_options = options & ~BEV_OPT_THREADSAFE;
|
||||
|
||||
if (underlying != NULL && fd >= 0)
|
||||
return NULL; /* Only one can be set. */
|
||||
@ -1123,7 +1123,7 @@ bufferevent_openssl_filter_new(struct event_base *base,
|
||||
struct bufferevent *underlying,
|
||||
SSL *ssl,
|
||||
enum bufferevent_ssl_state state,
|
||||
enum bufferevent_options options)
|
||||
int options)
|
||||
{
|
||||
int close_flag = options & BEV_OPT_CLOSE_ON_FREE;
|
||||
BIO *bio;
|
||||
@ -1143,7 +1143,7 @@ bufferevent_openssl_socket_new(struct event_base *base,
|
||||
evutil_socket_t fd,
|
||||
SSL *ssl,
|
||||
enum bufferevent_ssl_state state,
|
||||
enum bufferevent_options options)
|
||||
int options)
|
||||
{
|
||||
/* Does the SSL already have an fd? */
|
||||
BIO *bio = SSL_get_wbio(ssl);
|
||||
|
@ -92,7 +92,7 @@ static void be_pair_outbuf_cb(struct evbuffer *,
|
||||
|
||||
static struct bufferevent_pair *
|
||||
bufferevent_pair_elt_new(struct event_base *base,
|
||||
enum bufferevent_options options)
|
||||
int options)
|
||||
{
|
||||
struct bufferevent_pair *bufev;
|
||||
if (! (bufev = mm_calloc(1, sizeof(struct bufferevent_pair))))
|
||||
@ -113,11 +113,11 @@ bufferevent_pair_elt_new(struct event_base *base,
|
||||
}
|
||||
|
||||
int
|
||||
bufferevent_pair_new(struct event_base *base, enum bufferevent_options options,
|
||||
bufferevent_pair_new(struct event_base *base, int options,
|
||||
struct bufferevent *pair[2])
|
||||
{
|
||||
struct bufferevent_pair *bufev1 = NULL, *bufev2 = NULL;
|
||||
enum bufferevent_options tmp_options;
|
||||
int tmp_options;
|
||||
|
||||
options |= BEV_OPT_DEFER_CALLBACKS;
|
||||
tmp_options = options & ~BEV_OPT_THREADSAFE;
|
||||
|
@ -261,7 +261,7 @@ bufferevent_writecb(evutil_socket_t fd, short event, void *arg)
|
||||
|
||||
struct bufferevent *
|
||||
bufferevent_socket_new(struct event_base *base, evutil_socket_t fd,
|
||||
enum bufferevent_options options)
|
||||
int options)
|
||||
{
|
||||
struct bufferevent_private *bufev_p;
|
||||
struct bufferevent *bufev;
|
||||
|
7
event.c
7
event.c
@ -230,7 +230,7 @@ event_is_method_disabled(const char *name)
|
||||
return (getenv(environment) != NULL);
|
||||
}
|
||||
|
||||
enum event_method_feature
|
||||
int
|
||||
event_base_get_features(struct event_base *base)
|
||||
{
|
||||
return base->evsel->features;
|
||||
@ -533,8 +533,7 @@ event_config_free(struct event_config *cfg)
|
||||
|
||||
|
||||
int
|
||||
event_config_set_flag(struct event_config *cfg,
|
||||
enum event_base_config_flag flag)
|
||||
event_config_set_flag(struct event_config *cfg, int flag)
|
||||
{
|
||||
if (!cfg)
|
||||
return -1;
|
||||
@ -561,7 +560,7 @@ event_config_avoid_method(struct event_config *cfg, const char *method)
|
||||
|
||||
int
|
||||
event_config_require_features(struct event_config *cfg,
|
||||
enum event_method_feature features)
|
||||
int features)
|
||||
{
|
||||
if (!cfg)
|
||||
return (-1);
|
||||
|
@ -141,7 +141,7 @@ enum bufferevent_options {
|
||||
error occurred
|
||||
@see bufferevent_free()
|
||||
*/
|
||||
struct bufferevent *bufferevent_socket_new(struct event_base *base, evutil_socket_t fd, enum bufferevent_options options);
|
||||
struct bufferevent *bufferevent_socket_new(struct event_base *base, evutil_socket_t fd, int options);
|
||||
|
||||
/**
|
||||
Launch a connect() attempt with a socket. When the connect succeeds,
|
||||
@ -451,7 +451,7 @@ struct bufferevent *
|
||||
bufferevent_filter_new(struct bufferevent *underlying,
|
||||
bufferevent_filter_cb input_filter,
|
||||
bufferevent_filter_cb output_filter,
|
||||
enum bufferevent_options options,
|
||||
int options,
|
||||
void (*free_context)(void *),
|
||||
void *ctx);
|
||||
|
||||
@ -466,7 +466,7 @@ bufferevent_filter_new(struct bufferevent *underlying,
|
||||
@return 0 on success, -1 on failure.
|
||||
*/
|
||||
int
|
||||
bufferevent_pair_new(struct event_base *base, enum bufferevent_options options,
|
||||
bufferevent_pair_new(struct event_base *base, int options,
|
||||
struct bufferevent *pair[2]);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -53,14 +53,14 @@ bufferevent_openssl_filter_new(struct event_base *base,
|
||||
struct bufferevent *underlying,
|
||||
struct ssl_st *ssl,
|
||||
enum bufferevent_ssl_state state,
|
||||
enum bufferevent_options options);
|
||||
int options);
|
||||
|
||||
struct bufferevent *
|
||||
bufferevent_openssl_socket_new(struct event_base *base,
|
||||
evutil_socket_t fd,
|
||||
struct ssl_st *ssl,
|
||||
enum bufferevent_ssl_state state,
|
||||
enum bufferevent_options options);
|
||||
int options);
|
||||
|
||||
struct ssl_st *
|
||||
bufferevent_openssl_get_ssl(struct bufferevent *bufev);
|
||||
|
@ -171,7 +171,7 @@ enum event_base_config_flag {
|
||||
/**
|
||||
Return a bitmask of the features implemented by an event base.
|
||||
*/
|
||||
enum event_method_feature event_base_get_features(struct event_base *base);
|
||||
int event_base_get_features(struct event_base *base);
|
||||
|
||||
/**
|
||||
Enters a required event method feature that the application demands.
|
||||
@ -194,13 +194,11 @@ enum event_method_feature event_base_get_features(struct event_base *base);
|
||||
Replaces values from previous calls to this function.
|
||||
@return 0 on success, -1 on failure.
|
||||
*/
|
||||
int event_config_require_features(struct event_config *cfg,
|
||||
enum event_method_feature feature);
|
||||
int event_config_require_features(struct event_config *cfg, int feature);
|
||||
|
||||
/** Sets a flag to configure what parts of the eventual event_base will
|
||||
* be initialized, and how they'll work. */
|
||||
int event_config_set_flag(struct event_config *cfg,
|
||||
enum event_base_config_flag flag);
|
||||
int event_config_set_flag(struct event_config *cfg, int flag);
|
||||
|
||||
/**
|
||||
Initialize the event API.
|
||||
|
Loading…
x
Reference in New Issue
Block a user