1/* Copyright (C) 2010 Sergei Golubchik and Monty Program Ab
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; version 2 of the License.
6
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
11
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software
14 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */
15
16#define MYSQL_SERVER 1
17#include <my_global.h>
18#include <sql_class.h>
19
20namespace feedback {
21
22int fill_feedback(THD *thd, TABLE_LIST *tables, COND *cond);
23int fill_plugin_version(THD *thd, TABLE_LIST *tables);
24int fill_misc_data(THD *thd, TABLE_LIST *tables);
25int fill_linux_info(THD *thd, TABLE_LIST *tables);
26int fill_collation_statistics(THD *thd, TABLE_LIST *tables);
27
28static const int SERVER_UID_SIZE= 29;
29extern char server_uid_buf[SERVER_UID_SIZE+1], *user_info;
30int calculate_server_uid(char *);
31int prepare_linux_info();
32
33extern ST_SCHEMA_TABLE *i_s_feedback;
34
35extern ulong send_timeout, send_retry_wait;
36
37pthread_handler_t background_thread(void *arg);
38
39/**
40 The class for storing urls to send report data to.
41
42 Constructors are private, the object should be created with create() method.
43 send() method does the actual sending.
44*/
45class Url {
46 protected:
47 Url(LEX_STRING &url_arg) : full_url(url_arg) {}
48 const LEX_STRING full_url;
49
50 public:
51 virtual ~Url() { my_free(full_url.str); }
52
53 const char *url() { return full_url.str; }
54 size_t url_length() { return full_url.length; }
55 virtual int send(const char* data, size_t data_length) = 0;
56 virtual int set_proxy(const char *proxy, size_t proxy_len)
57 {
58 return 0;
59 }
60
61 static Url* create(const char *url, size_t url_length);
62 static int parse_proxy_server(const char *proxy_server, size_t proxy_length,
63 LEX_STRING *host, LEX_STRING *port);
64};
65
66extern Url **urls;
67extern uint url_count;
68
69extern ulong startup_interval;
70extern ulong first_interval;
71extern ulong interval;
72
73/* these are used to communicate with the background thread */
74extern mysql_mutex_t sleep_mutex;
75extern mysql_cond_t sleep_condition;
76extern volatile bool shutdown_plugin;
77
78} // namespace feedback
79
80