mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-09 20:41:27 -04: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 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 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 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:
|
Changes in 2.0.2-alpha:
|
||||||
|
@ -165,12 +165,12 @@ struct bufferevent *
|
|||||||
bufferevent_filter_new(struct bufferevent *underlying,
|
bufferevent_filter_new(struct bufferevent *underlying,
|
||||||
bufferevent_filter_cb input_filter,
|
bufferevent_filter_cb input_filter,
|
||||||
bufferevent_filter_cb output_filter,
|
bufferevent_filter_cb output_filter,
|
||||||
enum bufferevent_options options,
|
int options,
|
||||||
void (*free_context)(void *),
|
void (*free_context)(void *),
|
||||||
void *ctx)
|
void *ctx)
|
||||||
{
|
{
|
||||||
struct bufferevent_filtered *bufev_f;
|
struct bufferevent_filtered *bufev_f;
|
||||||
enum bufferevent_options tmp_options = options & ~BEV_OPT_THREADSAFE;
|
int tmp_options = options & ~BEV_OPT_THREADSAFE;
|
||||||
|
|
||||||
if (!input_filter)
|
if (!input_filter)
|
||||||
input_filter = be_null_filter;
|
input_filter = be_null_filter;
|
||||||
|
@ -1047,11 +1047,11 @@ bufferevent_openssl_new_impl(struct event_base *base,
|
|||||||
evutil_socket_t fd,
|
evutil_socket_t fd,
|
||||||
SSL *ssl,
|
SSL *ssl,
|
||||||
enum bufferevent_ssl_state state,
|
enum bufferevent_ssl_state state,
|
||||||
enum bufferevent_options options)
|
int options)
|
||||||
{
|
{
|
||||||
struct bufferevent_openssl *bev_ssl = NULL;
|
struct bufferevent_openssl *bev_ssl = NULL;
|
||||||
struct bufferevent_private *bev_p = 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)
|
if (underlying != NULL && fd >= 0)
|
||||||
return NULL; /* Only one can be set. */
|
return NULL; /* Only one can be set. */
|
||||||
@ -1123,7 +1123,7 @@ bufferevent_openssl_filter_new(struct event_base *base,
|
|||||||
struct bufferevent *underlying,
|
struct bufferevent *underlying,
|
||||||
SSL *ssl,
|
SSL *ssl,
|
||||||
enum bufferevent_ssl_state state,
|
enum bufferevent_ssl_state state,
|
||||||
enum bufferevent_options options)
|
int options)
|
||||||
{
|
{
|
||||||
int close_flag = options & BEV_OPT_CLOSE_ON_FREE;
|
int close_flag = options & BEV_OPT_CLOSE_ON_FREE;
|
||||||
BIO *bio;
|
BIO *bio;
|
||||||
@ -1143,7 +1143,7 @@ bufferevent_openssl_socket_new(struct event_base *base,
|
|||||||
evutil_socket_t fd,
|
evutil_socket_t fd,
|
||||||
SSL *ssl,
|
SSL *ssl,
|
||||||
enum bufferevent_ssl_state state,
|
enum bufferevent_ssl_state state,
|
||||||
enum bufferevent_options options)
|
int options)
|
||||||
{
|
{
|
||||||
/* Does the SSL already have an fd? */
|
/* Does the SSL already have an fd? */
|
||||||
BIO *bio = SSL_get_wbio(ssl);
|
BIO *bio = SSL_get_wbio(ssl);
|
||||||
|
@ -92,7 +92,7 @@ static void be_pair_outbuf_cb(struct evbuffer *,
|
|||||||
|
|
||||||
static struct bufferevent_pair *
|
static struct bufferevent_pair *
|
||||||
bufferevent_pair_elt_new(struct event_base *base,
|
bufferevent_pair_elt_new(struct event_base *base,
|
||||||
enum bufferevent_options options)
|
int options)
|
||||||
{
|
{
|
||||||
struct bufferevent_pair *bufev;
|
struct bufferevent_pair *bufev;
|
||||||
if (! (bufev = mm_calloc(1, sizeof(struct bufferevent_pair))))
|
if (! (bufev = mm_calloc(1, sizeof(struct bufferevent_pair))))
|
||||||
@ -113,11 +113,11 @@ bufferevent_pair_elt_new(struct event_base *base,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
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[2])
|
||||||
{
|
{
|
||||||
struct bufferevent_pair *bufev1 = NULL, *bufev2 = NULL;
|
struct bufferevent_pair *bufev1 = NULL, *bufev2 = NULL;
|
||||||
enum bufferevent_options tmp_options;
|
int tmp_options;
|
||||||
|
|
||||||
options |= BEV_OPT_DEFER_CALLBACKS;
|
options |= BEV_OPT_DEFER_CALLBACKS;
|
||||||
tmp_options = options & ~BEV_OPT_THREADSAFE;
|
tmp_options = options & ~BEV_OPT_THREADSAFE;
|
||||||
|
@ -261,7 +261,7 @@ bufferevent_writecb(evutil_socket_t fd, short event, void *arg)
|
|||||||
|
|
||||||
struct bufferevent *
|
struct bufferevent *
|
||||||
bufferevent_socket_new(struct event_base *base, evutil_socket_t fd,
|
bufferevent_socket_new(struct event_base *base, evutil_socket_t fd,
|
||||||
enum bufferevent_options options)
|
int options)
|
||||||
{
|
{
|
||||||
struct bufferevent_private *bufev_p;
|
struct bufferevent_private *bufev_p;
|
||||||
struct bufferevent *bufev;
|
struct bufferevent *bufev;
|
||||||
|
7
event.c
7
event.c
@ -230,7 +230,7 @@ event_is_method_disabled(const char *name)
|
|||||||
return (getenv(environment) != NULL);
|
return (getenv(environment) != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum event_method_feature
|
int
|
||||||
event_base_get_features(struct event_base *base)
|
event_base_get_features(struct event_base *base)
|
||||||
{
|
{
|
||||||
return base->evsel->features;
|
return base->evsel->features;
|
||||||
@ -533,8 +533,7 @@ event_config_free(struct event_config *cfg)
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
event_config_set_flag(struct event_config *cfg,
|
event_config_set_flag(struct event_config *cfg, int flag)
|
||||||
enum event_base_config_flag flag)
|
|
||||||
{
|
{
|
||||||
if (!cfg)
|
if (!cfg)
|
||||||
return -1;
|
return -1;
|
||||||
@ -561,7 +560,7 @@ event_config_avoid_method(struct event_config *cfg, const char *method)
|
|||||||
|
|
||||||
int
|
int
|
||||||
event_config_require_features(struct event_config *cfg,
|
event_config_require_features(struct event_config *cfg,
|
||||||
enum event_method_feature features)
|
int features)
|
||||||
{
|
{
|
||||||
if (!cfg)
|
if (!cfg)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
@ -141,7 +141,7 @@ enum bufferevent_options {
|
|||||||
error occurred
|
error occurred
|
||||||
@see bufferevent_free()
|
@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,
|
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_new(struct bufferevent *underlying,
|
||||||
bufferevent_filter_cb input_filter,
|
bufferevent_filter_cb input_filter,
|
||||||
bufferevent_filter_cb output_filter,
|
bufferevent_filter_cb output_filter,
|
||||||
enum bufferevent_options options,
|
int options,
|
||||||
void (*free_context)(void *),
|
void (*free_context)(void *),
|
||||||
void *ctx);
|
void *ctx);
|
||||||
|
|
||||||
@ -466,7 +466,7 @@ bufferevent_filter_new(struct bufferevent *underlying,
|
|||||||
@return 0 on success, -1 on failure.
|
@return 0 on success, -1 on failure.
|
||||||
*/
|
*/
|
||||||
int
|
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[2]);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -53,14 +53,14 @@ bufferevent_openssl_filter_new(struct event_base *base,
|
|||||||
struct bufferevent *underlying,
|
struct bufferevent *underlying,
|
||||||
struct ssl_st *ssl,
|
struct ssl_st *ssl,
|
||||||
enum bufferevent_ssl_state state,
|
enum bufferevent_ssl_state state,
|
||||||
enum bufferevent_options options);
|
int options);
|
||||||
|
|
||||||
struct bufferevent *
|
struct bufferevent *
|
||||||
bufferevent_openssl_socket_new(struct event_base *base,
|
bufferevent_openssl_socket_new(struct event_base *base,
|
||||||
evutil_socket_t fd,
|
evutil_socket_t fd,
|
||||||
struct ssl_st *ssl,
|
struct ssl_st *ssl,
|
||||||
enum bufferevent_ssl_state state,
|
enum bufferevent_ssl_state state,
|
||||||
enum bufferevent_options options);
|
int options);
|
||||||
|
|
||||||
struct ssl_st *
|
struct ssl_st *
|
||||||
bufferevent_openssl_get_ssl(struct bufferevent *bufev);
|
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.
|
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.
|
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.
|
Replaces values from previous calls to this function.
|
||||||
@return 0 on success, -1 on failure.
|
@return 0 on success, -1 on failure.
|
||||||
*/
|
*/
|
||||||
int event_config_require_features(struct event_config *cfg,
|
int event_config_require_features(struct event_config *cfg, int feature);
|
||||||
enum event_method_feature feature);
|
|
||||||
|
|
||||||
/** Sets a flag to configure what parts of the eventual event_base will
|
/** Sets a flag to configure what parts of the eventual event_base will
|
||||||
* be initialized, and how they'll work. */
|
* be initialized, and how they'll work. */
|
||||||
int event_config_set_flag(struct event_config *cfg,
|
int event_config_set_flag(struct event_config *cfg, int flag);
|
||||||
enum event_base_config_flag flag);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Initialize the event API.
|
Initialize the event API.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user