Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

libev3 comatibility

Change-Id: Ie141156e8f0f1705a4aa627be00e2b76db96c914
Reviewed-on: http://review.couchbase.org/21150
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
  • Loading branch information...
commit 0046ffc23edd1084492b24425a95f93de2f823f1 1 parent c116deb
@avsej avsej authored trondn committed
Showing with 39 additions and 9 deletions.
  1. +31 −8 configure.ac
  2. +8 −1 plugins/io/libev/plugin-libev.c
View
39 configure.ac
@@ -187,26 +187,49 @@ AC_CACHE_CHECK([for winsock2], [ac_cv_have_winsock2],
])
AM_CONDITIONAL(HAVE_WINSOCK2, [test "$ac_cv_have_winsock2" = "yes"])
-dnl Check that we've got a usable libev
-AC_CACHE_CHECK([for libev], [ac_cv_have_libev],
+dnl Check that we've got a usable libev3
+AC_CACHE_CHECK([for libev3], [ac_cv_have_libev3],
[ saved_libs="$LIBS"
LIBS=-lev
AC_TRY_LINK([
#include <sys/types.h>
#include <ev.h>
],[
- struct ev_loop *loop = ev_default_loop (0);
+ struct ev_loop *loop = ev_loop_new(EVFLAG_AUTO|EVFLAG_NOENV);
+ ev_loop(loop, 0);
+ ],[
+ ac_cv_have_libev3="yes"
+ ], [
+ ac_cv_have_libev3="no"
+ ])
+ LIBS="$saved_libs"
+ ])
+AM_CONDITIONAL(HAVE_LIBEV3, [test "x${ac_cv_have_libev3}" = "xyes" ])
+AS_IF([test "x${ac_cv_have_libev3}" = "xyes"],
+ [AC_DEFINE([HAVE_LIBEV3], [1], [We have libev3])])
+
+dnl Check that we've got a usable libev4
+AC_CACHE_CHECK([for libev4], [ac_cv_have_libev4],
+ [ saved_libs="$LIBS"
+ LIBS=-lev
+ AC_TRY_LINK([
+ #include <sys/types.h>
+ #include <ev.h>
+ ],[
+ struct ev_loop *loop = ev_loop_new(EVFLAG_AUTO|EVFLAG_NOENV);
ev_run(loop, 0);
],[
- ac_cv_have_libev="yes"
+ ac_cv_have_libev4="yes"
], [
- ac_cv_have_libev="no"
+ ac_cv_have_libev4="no"
])
LIBS="$saved_libs"
])
-AM_CONDITIONAL(HAVE_LIBEV, [test "x${ac_cv_have_libev}" = "xyes"])
-AS_IF([test "x${ac_cv_have_libev}" = "xyes"],
- [AC_DEFINE([HAVE_LIBEV], [1], [We have libev])])
+AM_CONDITIONAL(HAVE_LIBEV4, [test "x${ac_cv_have_libev4}" = "xyes" ])
+AS_IF([test "x${ac_cv_have_libev4}" = "xyes"],
+ [AC_DEFINE([HAVE_LIBEV4], [1], [We have libev4])])
+
+AM_CONDITIONAL(HAVE_LIBEV, [test "x${ac_cv_have_libev3}" = "xyes" -o "x${ac_cv_have_libev4}" = "xyes" ])
dnl Check that we've got a usable libevent
AC_CACHE_CHECK([for libevent >= 1.4], [ac_cv_have_libevent],
View
9 plugins/io/libev/plugin-libev.c
@@ -34,7 +34,6 @@ struct libev_cookie {
int allocated;
};
-
static lcb_ssize_t lcb_io_recv(struct lcb_io_opt_st *iops,
lcb_socket_t sock,
void *buffer,
@@ -306,13 +305,21 @@ static void lcb_io_destroy_timer(struct lcb_io_opt_st *iops,
static void lcb_io_stop_event_loop(struct lcb_io_opt_st *iops)
{
struct libev_cookie *io_cookie = iops->cookie;
+#ifdef HAVE_LIBEV4
ev_break(io_cookie->loop, EVBREAK_ONE);
+#else
+ ev_unloop(io_cookie->loop, EVUNLOOP_ONE);
+#endif
}
static void lcb_io_run_event_loop(struct lcb_io_opt_st *iops)
{
struct libev_cookie *io_cookie = iops->cookie;
+#ifdef HAVE_LIBEV4
ev_run(io_cookie->loop, 0);
+#else
+ ev_loop(io_cookie->loop, 0);
+#endif
}
static void lcb_destroy_io_opts(struct lcb_io_opt_st *iops)
Please sign in to comment.
Something went wrong with that request. Please try again.