Make sure we have libevent enabled for now, and add macro protection around the areas of the code that still depend on libevent.
This commit is contained in:
parent
2e2f93d0a4
commit
4a4de0f2ac
|
@ -9,10 +9,10 @@ MV := mv
|
|||
RANLIB := ranlib
|
||||
CFLAGS += -pipe -Wall
|
||||
USE_SSL ?= NO
|
||||
USE_LIBEVENT ?= YES
|
||||
USE_BIGENDIAN ?= AUTO
|
||||
BITS ?= AUTO
|
||||
SILENT ?= YES
|
||||
LDLIBS += -levent
|
||||
TERSE ?= NO
|
||||
STACK_PROTECT ?= NO
|
||||
|
||||
|
@ -116,10 +116,14 @@ CFLAGS += -DSSL_SUPPORT
|
|||
LDLIBS += -lssl
|
||||
endif
|
||||
|
||||
ifeq ($(USE_LIBEVENT),YES)
|
||||
CFLAGS += -DUSE_LIBEVENT
|
||||
LDLIBS += -levent
|
||||
ifneq ($(LIBEVENT_PATH),)
|
||||
CFLAGS += -I$(LIBEVENT_PATH)
|
||||
LDFLAGS += -L$(LIBEVENT_PATH)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(GIT_REVISION),YES)
|
||||
CFLAGS += -DGIT_REVISION=\"$(shell git show --abbrev-commit | head -n 1 | cut -f 2 -d " ")\"
|
||||
|
|
|
@ -53,6 +53,7 @@ static inline void net_con_flag_unset(struct net_connection* con, unsigned int f
|
|||
con->flags &= ~flag;
|
||||
}
|
||||
|
||||
#ifdef USE_LIBEVENT
|
||||
static inline int net_con_convert_to_libevent_mask(int ev)
|
||||
{
|
||||
int events = 0;
|
||||
|
@ -69,6 +70,7 @@ static inline int net_con_convert_from_libevent_mask(int ev)
|
|||
if (ev & EV_WRITE) events |= NET_EVENT_WRITE;
|
||||
return events;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void net_con_event(int fd, short ev, void *arg);
|
||||
|
||||
|
@ -92,10 +94,6 @@ void net_con_set(struct net_connection* con)
|
|||
net_con_flag_set(con, NET_INITIALIZED);
|
||||
}
|
||||
|
||||
#define CALLBACK(CON, EVENTS) \
|
||||
if (CON->callback) \
|
||||
CON->callback(con, EVENTS, CON->ptr);
|
||||
|
||||
static void net_con_after_close(struct net_connection* con)
|
||||
{
|
||||
if (net_con_flag_get(con, NET_INITIALIZED))
|
||||
|
@ -114,6 +112,10 @@ static void net_con_after_close(struct net_connection* con)
|
|||
hub_free(con);
|
||||
}
|
||||
|
||||
#define CALLBACK(CON, EVENTS) \
|
||||
if (CON->callback) \
|
||||
CON->callback(con, EVENTS, CON->ptr);
|
||||
|
||||
static void net_con_event(int fd, short ev, void *arg)
|
||||
{
|
||||
struct net_connection* con = (struct net_connection*) arg;
|
||||
|
@ -192,6 +194,7 @@ static void net_con_event(int fd, short ev, void *arg)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void net_con_initialize(struct net_connection* con, int sd, net_connection_cb callback, const void* ptr, int ev)
|
||||
{
|
||||
uhub_assert(con);
|
||||
|
|
|
@ -52,8 +52,12 @@ struct net_connection
|
|||
unsigned int flags; /** Connection flags */
|
||||
void* ptr; /** data pointer */
|
||||
net_connection_cb callback; /** Callback function */
|
||||
#ifdef USE_LIBEVENT
|
||||
struct event event; /** libevent struct for read/write events */
|
||||
struct event timeout; /** Used for internal timeout handling */
|
||||
#else
|
||||
#warning not implemented
|
||||
#endif
|
||||
time_t last_recv; /** Timestamp for last recv() */
|
||||
time_t last_send; /** Timestamp for last send() */
|
||||
#ifdef SSL_SUPPORT
|
||||
|
|
|
@ -102,7 +102,9 @@
|
|||
|
||||
#define uhub_assert assert
|
||||
|
||||
#ifdef USE_LIBEVENT
|
||||
#include <event.h>
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__sun__)
|
||||
#undef HAVE_STRNDUP
|
||||
|
|
Loading…
Reference in New Issue