fix for static plugins in mariadb.
send "startup" message 5 minutes after startup, not immediately Makefile.am: mariadb uses .la libraries for static plugins. mysql - .a libraries plug.in: mariadb uses .la libraries for static plugins. mysql - .a libraries sender_thread.cc: send "startup" message 5 minutes after startup, not immediately url_http.cc: avoid "unused variable https" warning
This commit is contained in:
parent
9401ae9425
commit
c0e11db793
@ -2,16 +2,15 @@ pkgplugindir = $(pkglibdir)/plugin
|
||||
INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include \
|
||||
-I$(top_srcdir)/regex -I$(top_srcdir)/sql
|
||||
|
||||
EXTRA_LTLIBRARIES = feedback.la
|
||||
EXTRA_LTLIBRARIES = feedback.la libfeedback.la
|
||||
pkgplugin_LTLIBRARIES = @plugin_feedback_shared_target@
|
||||
feedback_la_LDFLAGS = -module -rpath $(pkgplugindir)
|
||||
feedback_la_CXXFLAGS = -shared -DMYSQL_DYNAMIC_PLUGIN
|
||||
feedback_la_SOURCES = feedback.cc utils.cc url_base.cc url_http.cc \
|
||||
sender_thread.cc
|
||||
|
||||
EXTRA_LIBRARIES = libfeedback.a
|
||||
noinst_LIBRARIES = @plugin_feedback_static_target@
|
||||
libfeedback_a_SOURCES= feedback.cc utils.cc url_base.cc url_http.cc \
|
||||
noinst_LTLIBRARIES = @plugin_feedback_static_target@
|
||||
libfeedback_la_SOURCES= feedback.cc utils.cc url_base.cc url_http.cc \
|
||||
sender_thread.cc
|
||||
|
||||
noinst_HEADERS = feedback.h
|
||||
|
8
plug.in
8
plug.in
@ -11,7 +11,13 @@ dnl Unfortunately, feedback cannot be built dynamically on Windows, because it
|
||||
dnl needs to access server internals that aren't designed for plugin use and
|
||||
dnl aren't marked with MYSQL_PLUGIN_IMPORT.
|
||||
MYSQL_PLUGIN_DYNAMIC([feedback], [feedback.la])
|
||||
MYSQL_PLUGIN_STATIC(feedback, [libfeedback.a])
|
||||
ifelse(index(AC_PACKAGE_NAME, [MariaDB]), -1, [], [
|
||||
|
||||
dnl MariaDB and MySQL define static plugins differently.
|
||||
dnl I only support MariaDB here, for now.
|
||||
MYSQL_PLUGIN_STATIC(feedback, [libfeedback.la])
|
||||
|
||||
])
|
||||
|
||||
MYSQL_PLUGIN_ACTIONS(feedback, [
|
||||
AC_CHECK_HEADERS([netdb.h sys/utsname.h])
|
||||
|
@ -23,8 +23,9 @@ static my_thread_id thd_thread_id; ///< its thread_id
|
||||
|
||||
static size_t needed_size= 20480;
|
||||
|
||||
static const time_t next_interval= 60*60*24*7; ///< in seconds (one week)
|
||||
static const time_t startup_interval= 60*5; ///< in seconds (5 minutes)
|
||||
static const time_t first_interval= 60*60*24; ///< in seconds (one day)
|
||||
static const time_t interval= 60*60*24*7; ///< in seconds (one week)
|
||||
|
||||
/**
|
||||
reads the rows from a table and puts them, concatenated, in a String
|
||||
@ -141,7 +142,7 @@ static bool going_down()
|
||||
/**
|
||||
just like sleep, but waits on a condition and checks "plugin shutdown" status
|
||||
*/
|
||||
static int delay(time_t sec)
|
||||
static int slept_ok(time_t sec)
|
||||
{
|
||||
struct timespec abstime;
|
||||
int ret= 0;
|
||||
@ -153,7 +154,7 @@ static int delay(time_t sec)
|
||||
ret= pthread_cond_timedwait(&sleep_condition, &sleep_mutex, &abstime);
|
||||
pthread_mutex_unlock(&sleep_mutex);
|
||||
|
||||
return going_down();
|
||||
return !going_down();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -241,7 +242,7 @@ static void send_report(const char *when)
|
||||
}
|
||||
if (last_todo < 0)
|
||||
break;
|
||||
} while (delay(send_retry_wait) == 0); // wait a little bit before retrying
|
||||
} while (slept_ok(send_retry_wait)); // wait a little bit before retrying
|
||||
|
||||
ret:
|
||||
if (thd)
|
||||
@ -269,8 +270,6 @@ ret:
|
||||
*/
|
||||
pthread_handler_t background_thread(void *arg __attribute__((unused)))
|
||||
{
|
||||
time_t interval;
|
||||
|
||||
if (my_thread_init())
|
||||
return 0;
|
||||
|
||||
@ -278,12 +277,20 @@ pthread_handler_t background_thread(void *arg __attribute__((unused)))
|
||||
thd_thread_id= thread_id++;
|
||||
pthread_mutex_unlock(&LOCK_thread_count);
|
||||
|
||||
send_report("startup");
|
||||
if (slept_ok(startup_interval))
|
||||
{
|
||||
send_report("startup");
|
||||
|
||||
for (interval= first_interval; delay(interval) == 0; interval= next_interval)
|
||||
send_report(NULL);
|
||||
if (slept_ok(first_interval))
|
||||
{
|
||||
send_report(NULL);
|
||||
|
||||
send_report("shutdown");
|
||||
while(slept_ok(interval))
|
||||
send_report(NULL);
|
||||
}
|
||||
|
||||
send_report("shutdown");
|
||||
}
|
||||
|
||||
my_thread_end();
|
||||
pthread_exit(0);
|
||||
|
13
url_http.cc
13
url_http.cc
@ -28,11 +28,6 @@
|
||||
|
||||
namespace feedback {
|
||||
|
||||
static const char *http= "http://";
|
||||
static const size_t http_len= 7;
|
||||
static const char *https= "https://";
|
||||
static const size_t https_len= 8;
|
||||
|
||||
static const uint FOR_READING= 0;
|
||||
static const uint FOR_WRITING= 1;
|
||||
|
||||
@ -88,13 +83,13 @@ Url* http_create(const char *url, size_t url_length)
|
||||
LEX_STRING host, port, path;
|
||||
bool ssl= false;
|
||||
|
||||
if (is_prefix(url, http))
|
||||
s= url + http_len;
|
||||
if (is_prefix(url, "http://"))
|
||||
s= url + 7;
|
||||
#ifdef HAVE_OPENSSL
|
||||
else if (is_prefix(url, https))
|
||||
else if (is_prefix(url, "https://"))
|
||||
{
|
||||
ssl= true;
|
||||
s= url + https_len;
|
||||
s= url + 8;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user