summaryrefslogtreecommitdiff
path: root/plugin/daemon_example
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2015-12-09 10:00:49 +0100
committerSergei Golubchik <serg@mariadb.org>2015-12-09 10:00:49 +0100
commitabf9d35213ba482a3927651ddb98baa47aeb34fd (patch)
tree567bee47df18c21d5fbc09bbb4fee4e8f26df4d9 /plugin/daemon_example
parent50a796dcba2abe5f25c1e4cd8a69d7ea43343a8d (diff)
parent40ae1b9b618fbbc3b494a896a9d074b74e414337 (diff)
downloadmariadb-git-abf9d35213ba482a3927651ddb98baa47aeb34fd.tar.gz
Merge branch 'mysql/5.5' into 5.5
Diffstat (limited to 'plugin/daemon_example')
-rw-r--r--plugin/daemon_example/daemon_example.cc12
1 files changed, 9 insertions, 3 deletions
diff --git a/plugin/daemon_example/daemon_example.cc b/plugin/daemon_example/daemon_example.cc
index 09b81caeaf4..35376a8ec32 100644
--- a/plugin/daemon_example/daemon_example.cc
+++ b/plugin/daemon_example/daemon_example.cc
@@ -1,4 +1,5 @@
-/* Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights
+ reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -46,7 +47,6 @@ pthread_handler_t mysql_heartbeat(void *p)
DBUG_ENTER("mysql_heartbeat");
struct mysql_heartbeat_context *con= (struct mysql_heartbeat_context *)p;
char buffer[HEART_STRING_BUFFER];
- unsigned int x= 0;
time_t result;
struct tm tm_tmp;
@@ -65,7 +65,6 @@ pthread_handler_t mysql_heartbeat(void *p)
tm_tmp.tm_min,
tm_tmp.tm_sec);
my_write(con->heartbeat_file, (uchar*) buffer, strlen(buffer), MYF(0));
- x++;
}
DBUG_RETURN(0);
@@ -174,6 +173,13 @@ static int daemon_example_plugin_deinit(void *p __attribute__ ((unused)))
tm_tmp.tm_min,
tm_tmp.tm_sec);
my_write(con->heartbeat_file, (uchar*) buffer, strlen(buffer), MYF(0));
+
+ /*
+ Need to wait for the hearbeat thread to terminate before closing
+ the file it writes to and freeing the memory it uses.
+ */
+ pthread_join(con->heartbeat_thread, NULL);
+
my_close(con->heartbeat_file, MYF(0));
my_free(con);