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:
Sergei Golubchik 2011-10-04 15:48:39 +02:00
parent 9401ae9425
commit c0e11db793
4 changed files with 31 additions and 24 deletions

View File

@ -2,16 +2,15 @@ pkgplugindir = $(pkglibdir)/plugin
INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include \ INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include \
-I$(top_srcdir)/regex -I$(top_srcdir)/sql -I$(top_srcdir)/regex -I$(top_srcdir)/sql
EXTRA_LTLIBRARIES = feedback.la EXTRA_LTLIBRARIES = feedback.la libfeedback.la
pkgplugin_LTLIBRARIES = @plugin_feedback_shared_target@ pkgplugin_LTLIBRARIES = @plugin_feedback_shared_target@
feedback_la_LDFLAGS = -module -rpath $(pkgplugindir) feedback_la_LDFLAGS = -module -rpath $(pkgplugindir)
feedback_la_CXXFLAGS = -shared -DMYSQL_DYNAMIC_PLUGIN feedback_la_CXXFLAGS = -shared -DMYSQL_DYNAMIC_PLUGIN
feedback_la_SOURCES = feedback.cc utils.cc url_base.cc url_http.cc \ feedback_la_SOURCES = feedback.cc utils.cc url_base.cc url_http.cc \
sender_thread.cc sender_thread.cc
EXTRA_LIBRARIES = libfeedback.a noinst_LTLIBRARIES = @plugin_feedback_static_target@
noinst_LIBRARIES = @plugin_feedback_static_target@ libfeedback_la_SOURCES= feedback.cc utils.cc url_base.cc url_http.cc \
libfeedback_a_SOURCES= feedback.cc utils.cc url_base.cc url_http.cc \
sender_thread.cc sender_thread.cc
noinst_HEADERS = feedback.h noinst_HEADERS = feedback.h

View File

@ -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 needs to access server internals that aren't designed for plugin use and
dnl aren't marked with MYSQL_PLUGIN_IMPORT. dnl aren't marked with MYSQL_PLUGIN_IMPORT.
MYSQL_PLUGIN_DYNAMIC([feedback], [feedback.la]) 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, [ MYSQL_PLUGIN_ACTIONS(feedback, [
AC_CHECK_HEADERS([netdb.h sys/utsname.h]) AC_CHECK_HEADERS([netdb.h sys/utsname.h])

View File

@ -23,8 +23,9 @@ static my_thread_id thd_thread_id; ///< its thread_id
static size_t needed_size= 20480; 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 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 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 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; struct timespec abstime;
int ret= 0; int ret= 0;
@ -153,7 +154,7 @@ static int delay(time_t sec)
ret= pthread_cond_timedwait(&sleep_condition, &sleep_mutex, &abstime); ret= pthread_cond_timedwait(&sleep_condition, &sleep_mutex, &abstime);
pthread_mutex_unlock(&sleep_mutex); 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) if (last_todo < 0)
break; 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: ret:
if (thd) if (thd)
@ -269,8 +270,6 @@ ret:
*/ */
pthread_handler_t background_thread(void *arg __attribute__((unused))) pthread_handler_t background_thread(void *arg __attribute__((unused)))
{ {
time_t interval;
if (my_thread_init()) if (my_thread_init())
return 0; return 0;
@ -278,12 +277,20 @@ pthread_handler_t background_thread(void *arg __attribute__((unused)))
thd_thread_id= thread_id++; thd_thread_id= thread_id++;
pthread_mutex_unlock(&LOCK_thread_count); pthread_mutex_unlock(&LOCK_thread_count);
if (slept_ok(startup_interval))
{
send_report("startup"); send_report("startup");
for (interval= first_interval; delay(interval) == 0; interval= next_interval) if (slept_ok(first_interval))
{
send_report(NULL); send_report(NULL);
while(slept_ok(interval))
send_report(NULL);
}
send_report("shutdown"); send_report("shutdown");
}
my_thread_end(); my_thread_end();
pthread_exit(0); pthread_exit(0);

View File

@ -28,11 +28,6 @@
namespace feedback { 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_READING= 0;
static const uint FOR_WRITING= 1; 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; LEX_STRING host, port, path;
bool ssl= false; bool ssl= false;
if (is_prefix(url, http)) if (is_prefix(url, "http://"))
s= url + http_len; s= url + 7;
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
else if (is_prefix(url, https)) else if (is_prefix(url, "https://"))
{ {
ssl= true; ssl= true;
s= url + https_len; s= url + 8;
} }
#endif #endif
else else