summaryrefslogtreecommitdiffstats
path: root/plugin/feedback/feedback.h
blob: 04fe1ab6aa19d58645f83892ea056792d033d851 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/* Copyright (C) 2010 Sergei Golubchik and Monty Program Ab

   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
   the Free Software Foundation; version 2 of the License.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */

#define MYSQL_SERVER 1
#include <my_global.h>
#include <sql_class.h>

namespace feedback {

int fill_feedback(THD *thd, TABLE_LIST *tables, COND *cond);
int fill_plugin_version(THD *thd, TABLE_LIST *tables);
int fill_misc_data(THD *thd, TABLE_LIST *tables);
int fill_linux_info(THD *thd, TABLE_LIST *tables);
int fill_collation_statistics(THD *thd, TABLE_LIST *tables);

static const int SERVER_UID_SIZE= 29;
extern char server_uid_buf[SERVER_UID_SIZE+1], *user_info;
int calculate_server_uid(char *);
int prepare_linux_info();

extern ST_SCHEMA_TABLE *i_s_feedback;

extern ulong send_timeout, send_retry_wait;

pthread_handler_t background_thread(void *arg);

/**
  The class for storing urls to send report data to.

  Constructors are private, the object should be created with create() method.
  send() method does the actual sending.
*/
class Url {
  protected:
  Url(LEX_STRING &url_arg) : full_url(url_arg) {}
  const LEX_STRING full_url;

  public:
  virtual ~Url() { my_free(full_url.str); }

  const char *url()   { return full_url.str; }
  size_t url_length() { return full_url.length; }
  virtual int send(const char* data, size_t data_length) =  0;
  virtual int set_proxy(const char *proxy, size_t proxy_len)
  {
    return 0;
  }

  static Url* create(const char *url, size_t url_length);
  static int parse_proxy_server(const char *proxy_server, size_t proxy_length,
                                LEX_STRING *host, LEX_STRING *port);
};

extern Url **urls;
extern uint url_count;

extern ulong startup_interval;
extern ulong first_interval;
extern ulong interval;

/* these are used to communicate with the background thread */
extern mysql_mutex_t sleep_mutex;
extern mysql_cond_t sleep_condition;
extern volatile bool shutdown_plugin;

} // namespace feedback