MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pfs_host.h
Go to the documentation of this file.
1 /* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
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 02110-1301, USA */
15 
16 #ifndef PFS_HOST_H
17 #define PFS_HOST_H
18 
24 #include "pfs_lock.h"
25 #include "lf.h"
26 #include "pfs_con_slice.h"
27 
28 struct PFS_global_param;
29 struct PFS_thread;
30 
37 {
43  char m_hash_key[HOSTNAME_LENGTH + 1];
44  uint m_key_length;
45 };
46 
47 struct PFS_ALIGNED PFS_host : PFS_connection_slice
48 {
49 public:
50  inline void init_refcount(void)
51  {
52  PFS_atomic::store_32(& m_refcount, 1);
53  }
54 
55  inline int get_refcount(void)
56  {
57  return PFS_atomic::load_32(& m_refcount);
58  }
59 
60  inline void inc_refcount(void)
61  {
62  PFS_atomic::add_32(& m_refcount, 1);
63  }
64 
65  inline void dec_refcount(void)
66  {
67  PFS_atomic::add_32(& m_refcount, -1);
68  }
69 
70  void aggregate(void);
71  void aggregate_waits(void);
72  void aggregate_stages(void);
73  void aggregate_statements(void);
74  void aggregate_stats(void);
75  void release(void);
76 
77  /* Internal lock. */
78  pfs_lock m_lock;
79  PFS_host_key m_key;
80  const char *m_hostname;
81  uint m_hostname_length;
82 
83  ulonglong m_disconnected_count;
84 
85 private:
86  int m_refcount;
87 };
88 
89 int init_host(const PFS_global_param *param);
90 void cleanup_host(void);
91 int init_host_hash(void);
92 void cleanup_host_hash(void);
93 
94 PFS_host *find_or_create_host(PFS_thread *thread,
95  const char *hostname, uint hostname_length);
96 
97 PFS_host *sanitize_host(PFS_host *unsafe);
98 void purge_all_host(void);
99 
100 /* For iterators and show status. */
101 
102 extern ulong host_max;
103 extern ulong host_lost;
104 
105 /* Exposing the data directly, for iterators. */
106 
107 extern PFS_host *host_array;
108 
109 extern LF_HASH host_hash;
110 
112 #endif
113