Skip to content

Commit 4cb24c6

Browse files
Tor Didriksenjhauglid
Tor Didriksen
authored andcommitted
Bug#23567441: BACKPORT MEMCACHED FIXES TO 5.7
Backport from mysql-trunk to mysql-5.7 of: Bug#22573379 MEMCACHED PLUGIN DOES NOT LOAD WITH SYSTEM LIBEVENT 2.0 Fix -DWITH_LIBEVENT=system - look for libevent_core.so, use it if available - link libevent_core.so into libmemcached - record a couple of .result files (new copyright) Bug#22646919 INNODB MEMCACHED: CONN_CLOSE: ASSERTION `C->SFD == -1' FAILED Make memcached compile and run with libevent 2.0.
1 parent 376dda0 commit 4cb24c6

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

cmake/libevent.cmake

+17-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License as published by
@@ -17,6 +17,7 @@ MACRO (MYSQL_USE_BUNDLED_LIBEVENT)
1717
SET(LIBEVENT_LIBRARY event)
1818
SET(LIBEVENT_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/libevent)
1919
SET(LIBEVENT_FOUND TRUE)
20+
ADD_DEFINITIONS("-DHAVE_LIBEVENT1")
2021
SET(WITH_LIBEVENT "bundled" CACHE STRING "Use bundled libevent")
2122
# Use EXCLUDE_FROM_ALL to build only if another component
2223
# which dependens on libevent is built
@@ -62,15 +63,21 @@ MACRO (MYSQL_CHECK_LIBEVENT)
6263
set(LIBEVENT_LIB_PATHS /usr/local/lib /opt/local/lib)
6364
ENDIF()
6465

66+
## libevent.so is historical, use libevent_core.so if found.
67+
find_library(LIBEVENT_CORE event_core PATHS ${LIBEVENT_LIB_PATHS})
6568
find_library(LIBEVENT_LIB event PATHS ${LIBEVENT_LIB_PATHS})
6669

67-
if (NOT LIBEVENT_LIB)
70+
if (NOT LIBEVENT_LIB AND NOT LIBEVENT_CORE)
6871
MESSAGE(SEND_ERROR "Cannot find appropriate event lib in /usr/local/lib or /opt/local/lib. Use bundled libevent")
6972
endif()
7073

71-
IF (LIBEVENT_LIB AND LIBEVENT_INCLUDE_DIR)
74+
IF ((LIBEVENT_LIB OR LIBEVENT_CORE) AND LIBEVENT_INCLUDE_DIR)
7275
set(LIBEVENT_FOUND TRUE)
73-
set(LIBEVENT_LIBS ${LIBEVENT_LIB})
76+
IF (LIBEVENT_CORE)
77+
set(LIBEVENT_LIBS ${LIBEVENT_CORE})
78+
ELSE()
79+
set(LIBEVENT_LIBS ${LIBEVENT_LIB})
80+
ENDIF()
7481
ELSE()
7582
set(LIBEVENT_FOUND FALSE)
7683
ENDIF()
@@ -79,7 +86,12 @@ MACRO (MYSQL_CHECK_LIBEVENT)
7986
SET(LIBEVENT_SOURCES "")
8087
SET(LIBEVENT_LIBRARIES ${LIBEVENT_LIBS})
8188
SET(LIBEVENT_INCLUDE_DIRS ${LIBEVENT_INCLUDE_DIR})
82-
SET(LIBEVENT_DEFINES "-DHAVE_LIBEVENT")
89+
find_path(LIBEVENT2_INCLUDE_DIR event2 HINTS ${LIBEVENT_INCLUDE_PATH}/event)
90+
IF (LIBEVENT2_INCLUDE_DIR)
91+
ADD_DEFINITIONS("-DHAVE_LIBEVENT2")
92+
ELSE()
93+
ADD_DEFINITIONS("-DHAVE_LIBEVENT1")
94+
ENDIF()
8395
ELSE()
8496
IF(WITH_LIBEVENT STREQUAL "system")
8597
MESSAGE(SEND_ERROR "Cannot find appropriate system libraries for libevent. Use bundled libevent")

plugin/innodb_memcached/daemon_memcached/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License as published by
@@ -78,7 +78,7 @@ SET(MEMCACHED_SOURCES
7878
MYSQL_ADD_PLUGIN(libmemcached ${MEMCACHED_SOURCES}
7979
MODULE_ONLY MODULE_OUTPUT_NAME "libmemcached")
8080

81-
TARGET_LINK_LIBRARIES(libmemcached ${LIBEVENT_LIBRARY})
81+
TARGET_LINK_LIBRARIES(libmemcached ${LIBEVENT_LIBRARY} ${LIBEVENT_LIBRARIES})
8282
TARGET_LINK_LIBRARIES(libmemcached memcached_utilities)
8383

8484
IF(ENABLE_MEMCACHED_SASL)

plugin/innodb_memcached/daemon_memcached/daemon/memcached.h

+9
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,16 @@
66
* The main memcached header holding commonly used data
77
* structures and function prototypes.
88
*/
9+
#ifdef HAVE_LIBEVENT2
10+
#include <event2/event.h>
11+
#include <event2/event_struct.h>
12+
#include <event2/event_compat.h>
13+
#elif HAVE_LIBEVENT1
914
#include <event.h>
15+
#else
16+
#error "No libevent library found"
17+
#endif /* HAVE_LIBEVENT2 */
18+
1019
#include <pthread.h>
1120
#include <config_static.h>
1221

0 commit comments

Comments
 (0)