Skip to content

Commit 79a8d99

Browse files
author
Tor Didriksen
committed
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. (cherry picked from commit 2bc129ab604c668a1256436b03c71781b10a0959) Change-Id: Ie4308c0cced3103fafbac47cb2bdd2019068b2e0
1 parent 13fa1c4 commit 79a8d99

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

cmake/libevent.cmake

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2011, 2018, 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
ADD_SUBDIRECTORY(libevent)
2223
GET_TARGET_PROPERTY(src libevent SOURCES)
@@ -60,15 +61,21 @@ MACRO (MYSQL_CHECK_LIBEVENT)
6061
set(LIBEVENT_LIB_PATHS /usr/local/lib /opt/local/lib)
6162
ENDIF()
6263

64+
## libevent.so is historical, use libevent_core.so if found.
65+
find_library(LIBEVENT_CORE event_core PATHS ${LIBEVENT_LIB_PATHS})
6366
find_library(LIBEVENT_LIB event PATHS ${LIBEVENT_LIB_PATHS})
6467

65-
if (NOT LIBEVENT_LIB)
68+
if (NOT LIBEVENT_LIB AND NOT LIBEVENT_CORE)
6669
MESSAGE(SEND_ERROR "Cannot find appropriate event lib in /usr/local/lib or /opt/local/lib. Use bundled libevent")
6770
endif()
6871

69-
IF (LIBEVENT_LIB AND LIBEVENT_INCLUDE_DIR)
72+
IF ((LIBEVENT_LIB OR LIBEVENT_CORE) AND LIBEVENT_INCLUDE_DIR)
7073
set(LIBEVENT_FOUND TRUE)
71-
set(LIBEVENT_LIBS ${LIBEVENT_LIB})
74+
IF (LIBEVENT_CORE)
75+
set(LIBEVENT_LIBS ${LIBEVENT_CORE})
76+
ELSE()
77+
set(LIBEVENT_LIBS ${LIBEVENT_LIB})
78+
ENDIF()
7279
ELSE()
7380
set(LIBEVENT_FOUND FALSE)
7481
ENDIF()
@@ -77,7 +84,12 @@ MACRO (MYSQL_CHECK_LIBEVENT)
7784
SET(LIBEVENT_SOURCES "")
7885
SET(LIBEVENT_LIBRARIES ${LIBEVENT_LIBS})
7986
SET(LIBEVENT_INCLUDE_DIRS ${LIBEVENT_INCLUDE_DIR})
80-
SET(LIBEVENT_DEFINES "-DHAVE_LIBEVENT")
87+
find_path(LIBEVENT2_INCLUDE_DIR event2 HINTS ${LIBEVENT_INCLUDE_PATH}/event)
88+
IF (LIBEVENT2_INCLUDE_DIR)
89+
ADD_DEFINITIONS("-DHAVE_LIBEVENT2")
90+
ELSE()
91+
ADD_DEFINITIONS("-DHAVE_LIBEVENT1")
92+
ENDIF()
8193
ELSE()
8294
IF(WITH_LIBEVENT STREQUAL "system")
8395
MESSAGE(SEND_ERROR "Cannot find appropriate system libraries for libevent. Use bundled libevent")

plugin/innodb_memcached/daemon_memcached/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
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

Lines changed: 9 additions & 0 deletions
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)