vincentchu-handlersocket 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. data/ext/HandlerSocket-Plugin-for-MySQL/AUTHORS +22 -0
  2. data/ext/HandlerSocket-Plugin-for-MySQL/COPYING +30 -0
  3. data/ext/HandlerSocket-Plugin-for-MySQL/ChangeLog +12 -0
  4. data/ext/HandlerSocket-Plugin-for-MySQL/Makefile.am +87 -0
  5. data/ext/HandlerSocket-Plugin-for-MySQL/README +78 -0
  6. data/ext/HandlerSocket-Plugin-for-MySQL/autogen.sh +117 -0
  7. data/ext/HandlerSocket-Plugin-for-MySQL/client/Makefile.am +24 -0
  8. data/ext/HandlerSocket-Plugin-for-MySQL/client/hsclient.cpp +88 -0
  9. data/ext/HandlerSocket-Plugin-for-MySQL/client/hslongrun.cpp +1041 -0
  10. data/ext/HandlerSocket-Plugin-for-MySQL/client/hspool_test.pl +224 -0
  11. data/ext/HandlerSocket-Plugin-for-MySQL/client/hstest.cpp +1532 -0
  12. data/ext/HandlerSocket-Plugin-for-MySQL/client/hstest.pl +228 -0
  13. data/ext/HandlerSocket-Plugin-for-MySQL/client/hstest_hs.sh +4 -0
  14. data/ext/HandlerSocket-Plugin-for-MySQL/client/hstest_hs_more50.sh +4 -0
  15. data/ext/HandlerSocket-Plugin-for-MySQL/client/hstest_md.sh +7 -0
  16. data/ext/HandlerSocket-Plugin-for-MySQL/client/hstest_my.sh +3 -0
  17. data/ext/HandlerSocket-Plugin-for-MySQL/client/hstest_my_more50.sh +3 -0
  18. data/ext/HandlerSocket-Plugin-for-MySQL/configure.ac +144 -0
  19. data/ext/HandlerSocket-Plugin-for-MySQL/docs-en/about-handlersocket.en.txt +72 -0
  20. data/ext/HandlerSocket-Plugin-for-MySQL/docs-en/configuration-options.en.txt +99 -0
  21. data/ext/HandlerSocket-Plugin-for-MySQL/docs-en/installation.en.txt +92 -0
  22. data/ext/HandlerSocket-Plugin-for-MySQL/docs-en/perl-client.en.txt +135 -0
  23. data/ext/HandlerSocket-Plugin-for-MySQL/docs-en/protocol.en.txt +205 -0
  24. data/ext/HandlerSocket-Plugin-for-MySQL/docs-ja/about-handlersocket.ja.txt +51 -0
  25. data/ext/HandlerSocket-Plugin-for-MySQL/docs-ja/installation.ja.txt +88 -0
  26. data/ext/HandlerSocket-Plugin-for-MySQL/docs-ja/perl-client.ja.txt +127 -0
  27. data/ext/HandlerSocket-Plugin-for-MySQL/docs-ja/protocol.ja.txt +180 -0
  28. data/ext/HandlerSocket-Plugin-for-MySQL/handlersocket/COPYRIGHT.txt +27 -0
  29. data/ext/HandlerSocket-Plugin-for-MySQL/handlersocket/Makefile.am +10 -0
  30. data/ext/HandlerSocket-Plugin-for-MySQL/handlersocket/Makefile.plain.template +31 -0
  31. data/ext/HandlerSocket-Plugin-for-MySQL/handlersocket/database.cpp +1190 -0
  32. data/ext/HandlerSocket-Plugin-for-MySQL/handlersocket/database.hpp +142 -0
  33. data/ext/HandlerSocket-Plugin-for-MySQL/handlersocket/handlersocket.cpp +222 -0
  34. data/ext/HandlerSocket-Plugin-for-MySQL/handlersocket/handlersocket.spec.template +29 -0
  35. data/ext/HandlerSocket-Plugin-for-MySQL/handlersocket/hstcpsvr.cpp +149 -0
  36. data/ext/HandlerSocket-Plugin-for-MySQL/handlersocket/hstcpsvr.hpp +58 -0
  37. data/ext/HandlerSocket-Plugin-for-MySQL/handlersocket/hstcpsvr_worker.cpp +951 -0
  38. data/ext/HandlerSocket-Plugin-for-MySQL/handlersocket/hstcpsvr_worker.hpp +35 -0
  39. data/ext/HandlerSocket-Plugin-for-MySQL/handlersocket/mysql_incl.hpp +50 -0
  40. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/COPYRIGHT.txt +27 -0
  41. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/Makefile.am +12 -0
  42. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/Makefile.plain +27 -0
  43. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/allocator.hpp +64 -0
  44. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/auto_addrinfo.hpp +49 -0
  45. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/auto_file.hpp +64 -0
  46. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/auto_ptrcontainer.hpp +67 -0
  47. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/config.cpp +67 -0
  48. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/config.hpp +32 -0
  49. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/escape.cpp +127 -0
  50. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/escape.hpp +66 -0
  51. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/fatal.cpp +36 -0
  52. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/fatal.hpp +22 -0
  53. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/hstcpcli.cpp +441 -0
  54. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/hstcpcli.hpp +62 -0
  55. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/libhsclient.spec.template +39 -0
  56. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/mutex.hpp +51 -0
  57. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/socket.cpp +186 -0
  58. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/socket.hpp +51 -0
  59. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/string_buffer.hpp +118 -0
  60. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/string_ref.hpp +63 -0
  61. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/string_util.cpp +182 -0
  62. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/string_util.hpp +53 -0
  63. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/thread.hpp +84 -0
  64. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/util.hpp +25 -0
  65. data/ext/HandlerSocket-Plugin-for-MySQL/misc/microbench-hs.log +130 -0
  66. data/ext/HandlerSocket-Plugin-for-MySQL/misc/microbench-my.log +125 -0
  67. data/ext/HandlerSocket-Plugin-for-MySQL/perl-Net-HandlerSocket/COPYRIGHT.txt +27 -0
  68. data/ext/HandlerSocket-Plugin-for-MySQL/perl-Net-HandlerSocket/Changes +6 -0
  69. data/ext/HandlerSocket-Plugin-for-MySQL/perl-Net-HandlerSocket/HandlerSocket.xs +632 -0
  70. data/ext/HandlerSocket-Plugin-for-MySQL/perl-Net-HandlerSocket/MANIFEST +8 -0
  71. data/ext/HandlerSocket-Plugin-for-MySQL/perl-Net-HandlerSocket/Makefile.PL +18 -0
  72. data/ext/HandlerSocket-Plugin-for-MySQL/perl-Net-HandlerSocket/Makefile.PL.installed +20 -0
  73. data/ext/HandlerSocket-Plugin-for-MySQL/perl-Net-HandlerSocket/README +30 -0
  74. data/ext/HandlerSocket-Plugin-for-MySQL/perl-Net-HandlerSocket/lib/Net/HandlerSocket.pm +68 -0
  75. data/ext/HandlerSocket-Plugin-for-MySQL/perl-Net-HandlerSocket/lib/Net/HandlerSocket/Pool.pm +362 -0
  76. data/ext/HandlerSocket-Plugin-for-MySQL/perl-Net-HandlerSocket/perl-Net-HandlerSocket.spec.template +127 -0
  77. data/ext/HandlerSocket-Plugin-for-MySQL/perl-Net-HandlerSocket/ppport.h +6375 -0
  78. data/ext/HandlerSocket-Plugin-for-MySQL/perl-Net-HandlerSocket/t/Net-HandlerSocket.t +15 -0
  79. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/Makefile +79 -0
  80. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/common/binary_my.cnf +4 -0
  81. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/common/compat.sh +29 -0
  82. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/common/hstest.pm +66 -0
  83. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/Makefile +4 -0
  84. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/run.sh +27 -0
  85. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test01.expected +100 -0
  86. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test01.pl +38 -0
  87. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test02.expected +100 -0
  88. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test02.pl +49 -0
  89. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test03.expected +771 -0
  90. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test03.pl +61 -0
  91. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test04.expected +0 -0
  92. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test04.pl +63 -0
  93. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test05.expected +771 -0
  94. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test05.pl +59 -0
  95. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test06.expected +644 -0
  96. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test06.pl +90 -0
  97. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test07.expected +304 -0
  98. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test07.pl +98 -0
  99. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test08.expected +2 -0
  100. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test08.pl +48 -0
  101. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test09.expected +12 -0
  102. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test09.pl +67 -0
  103. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test10.expected +771 -0
  104. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test10.pl +93 -0
  105. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test11.expected +37 -0
  106. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test11.pl +112 -0
  107. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test12.expected +273 -0
  108. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test12.pl +134 -0
  109. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test13.expected +92 -0
  110. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test13.pl +92 -0
  111. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test14.expected +144 -0
  112. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test14.pl +80 -0
  113. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test15.expected +764 -0
  114. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test15.pl +114 -0
  115. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test16.expected +66 -0
  116. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test16.pl +88 -0
  117. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test17.expected +0 -0
  118. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test17.pl +125 -0
  119. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test18.expected +22 -0
  120. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test18.pl +63 -0
  121. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test19.expected +14894 -0
  122. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test19.pl +190 -0
  123. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test20.expected +2 -0
  124. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test20.pl +33 -0
  125. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test21.expected +11 -0
  126. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test21.pl +58 -0
  127. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test22.expected +9 -0
  128. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test22.pl +61 -0
  129. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test23.expected +101 -0
  130. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test23.pl +53 -0
  131. data/ext/winebarrel-ruby-handlersocket-c19841e47ea2/README +33 -0
  132. data/ext/winebarrel-ruby-handlersocket-c19841e47ea2/extconf.rb +27 -0
  133. data/ext/winebarrel-ruby-handlersocket-c19841e47ea2/handlersocket.cpp +437 -0
  134. data/ext/winebarrel-ruby-handlersocket-c19841e47ea2/handlersocket.h +32 -0
  135. metadata +200 -0
@@ -0,0 +1,63 @@
1
+
2
+ // vim:sw=2:ai
3
+
4
+ /*
5
+ * Copyright (C) 2010 DeNA Co.,Ltd.. All rights reserved.
6
+ * See COPYRIGHT.txt for details.
7
+ */
8
+
9
+ #ifndef DENA_STRING_REF_HPP
10
+ #define DENA_STRING_REF_HPP
11
+
12
+ #include <vector>
13
+ #include <string.h>
14
+
15
+ namespace dena {
16
+
17
+ struct string_wref {
18
+ typedef char value_type;
19
+ char *begin() const { return start; }
20
+ char *end() const { return start + length; }
21
+ size_t size() const { return length; }
22
+ private:
23
+ char *start;
24
+ size_t length;
25
+ public:
26
+ string_wref(char *s = 0, size_t len = 0) : start(s), length(len) { }
27
+ };
28
+
29
+ struct string_ref {
30
+ typedef const char value_type;
31
+ const char *begin() const { return start; }
32
+ const char *end() const { return start + length; }
33
+ size_t size() const { return length; }
34
+ private:
35
+ const char *start;
36
+ size_t length;
37
+ public:
38
+ string_ref(const char *s = 0, size_t len = 0) : start(s), length(len) { }
39
+ string_ref(const char *s, const char *f) : start(s), length(f - s) { }
40
+ string_ref(const string_wref& w) : start(w.begin()), length(w.size()) { }
41
+ };
42
+
43
+ template <size_t N> inline bool
44
+ operator ==(const string_ref& x, const char (& y)[N]) {
45
+ return (x.size() == N - 1) && (::memcmp(x.begin(), y, N - 1) == 0);
46
+ }
47
+
48
+ inline bool
49
+ operator ==(const string_ref& x, const string_ref& y) {
50
+ return (x.size() == y.size()) &&
51
+ (::memcmp(x.begin(), y.begin(), x.size()) == 0);
52
+ }
53
+
54
+ inline bool
55
+ operator !=(const string_ref& x, const string_ref& y) {
56
+ return (x.size() != y.size()) ||
57
+ (::memcmp(x.begin(), y.begin(), x.size()) != 0);
58
+ }
59
+
60
+ };
61
+
62
+ #endif
63
+
@@ -0,0 +1,182 @@
1
+
2
+ // vim:sw=2:ai
3
+
4
+ /*
5
+ * Copyright (C) 2010 DeNA Co.,Ltd.. All rights reserved.
6
+ * See COPYRIGHT.txt for details.
7
+ */
8
+
9
+ #include <errno.h>
10
+ #include <stdio.h>
11
+
12
+ #include "string_util.hpp"
13
+
14
+ namespace dena {
15
+
16
+ string_wref
17
+ get_token(char *& wp, char *wp_end, char delim)
18
+ {
19
+ char *const wp_begin = wp;
20
+ char *const p = memchr_char(wp_begin, delim, wp_end - wp_begin);
21
+ if (p == 0) {
22
+ wp = wp_end;
23
+ return string_wref(wp_begin, wp_end - wp_begin);
24
+ }
25
+ wp = p + 1;
26
+ return string_wref(wp_begin, p - wp_begin);
27
+ }
28
+
29
+ template <typename T> T
30
+ atoi_tmpl_nocheck(const char *start, const char *finish)
31
+ {
32
+ T v = 0;
33
+ for (; start != finish; ++start) {
34
+ const char c = *start;
35
+ if (c < '0' || c > '9') {
36
+ break;
37
+ }
38
+ v *= 10;
39
+ v += static_cast<T>(c - '0');
40
+ }
41
+ return v;
42
+ }
43
+
44
+ template <typename T> T
45
+ atoi_signed_tmpl_nocheck(const char *start, const char *finish)
46
+ {
47
+ T v = 0;
48
+ bool negative = false;
49
+ if (start != finish) {
50
+ if (start[0] == '-') {
51
+ ++start;
52
+ negative = true;
53
+ } else if (start[0] == '+') {
54
+ ++start;
55
+ }
56
+ }
57
+ for (; start != finish; ++start) {
58
+ const char c = *start;
59
+ if (c < '0' || c > '9') {
60
+ break;
61
+ }
62
+ v *= 10;
63
+ if (negative) {
64
+ v -= static_cast<T>(c - '0');
65
+ } else {
66
+ v += static_cast<T>(c - '0');
67
+ }
68
+ }
69
+ return v;
70
+ }
71
+
72
+ uint32_t
73
+ atoi_uint32_nocheck(const char *start, const char *finish)
74
+ {
75
+ return atoi_tmpl_nocheck<uint32_t>(start, finish);
76
+ }
77
+
78
+ long long
79
+ atoll_nocheck(const char *start, const char *finish)
80
+ {
81
+ return atoi_signed_tmpl_nocheck<long long>(start, finish);
82
+ }
83
+
84
+ void
85
+ append_uint32(string_buffer& buf, uint32_t v)
86
+ {
87
+ char *const wp = buf.make_space(64);
88
+ const int len = snprintf(wp, 64, "%lu", static_cast<unsigned long>(v));
89
+ if (len > 0) {
90
+ buf.space_wrote(len);
91
+ }
92
+ }
93
+
94
+ std::string
95
+ to_stdstring(uint32_t v)
96
+ {
97
+ char buf[64];
98
+ snprintf(buf, sizeof(buf), "%lu", static_cast<unsigned long>(v));
99
+ return std::string(buf);
100
+ }
101
+
102
+ int
103
+ errno_string(const char *s, int en, std::string& err_r)
104
+ {
105
+ char buf[64];
106
+ snprintf(buf, sizeof(buf), "%s: %d", s, en);
107
+ err_r = std::string(buf);
108
+ return en;
109
+ }
110
+
111
+ template <typename T> size_t
112
+ split_tmpl_arr(char delim, const T& buf, T *parts, size_t parts_len)
113
+ {
114
+ typedef typename T::value_type value_type;
115
+ size_t i = 0;
116
+ value_type *start = buf.begin();
117
+ value_type *const finish = buf.end();
118
+ for (i = 0; i < parts_len; ++i) {
119
+ value_type *const p = memchr_char(start, delim, finish - start);
120
+ if (p == 0) {
121
+ parts[i] = T(start, finish - start);
122
+ ++i;
123
+ break;
124
+ }
125
+ parts[i] = T(start, p - start);
126
+ start = p + 1;
127
+ }
128
+ const size_t r = i;
129
+ for (; i < parts_len; ++i) {
130
+ parts[i] = T();
131
+ }
132
+ return r;
133
+ }
134
+
135
+ size_t
136
+ split(char delim, const string_ref& buf, string_ref *parts,
137
+ size_t parts_len)
138
+ {
139
+ return split_tmpl_arr(delim, buf, parts, parts_len);
140
+ }
141
+
142
+ size_t
143
+ split(char delim, const string_wref& buf, string_wref *parts,
144
+ size_t parts_len)
145
+ {
146
+ return split_tmpl_arr(delim, buf, parts, parts_len);
147
+ }
148
+
149
+ template <typename T, typename V> size_t
150
+ split_tmpl_vec(char delim, const T& buf, V& parts)
151
+ {
152
+ typedef typename T::value_type value_type;
153
+ size_t i = 0;
154
+ value_type *start = buf.begin();
155
+ value_type *const finish = buf.end();
156
+ while (true) {
157
+ value_type *const p = memchr_char(start, delim, finish - start);
158
+ if (p == 0) {
159
+ parts.push_back(T(start, finish - start));
160
+ break;
161
+ }
162
+ parts.push_back(T(start, p - start));
163
+ start = p + 1;
164
+ }
165
+ const size_t r = i;
166
+ return r;
167
+ }
168
+
169
+ size_t
170
+ split(char delim, const string_ref& buf, std::vector<string_ref>& parts_r)
171
+ {
172
+ return split_tmpl_vec(delim, buf, parts_r);
173
+ }
174
+
175
+ size_t
176
+ split(char delim, const string_wref& buf, std::vector<string_wref>& parts_r)
177
+ {
178
+ return split_tmpl_vec(delim, buf, parts_r);
179
+ }
180
+
181
+ };
182
+
@@ -0,0 +1,53 @@
1
+
2
+ // vim:sw=2:ai
3
+
4
+ /*
5
+ * Copyright (C) 2010 DeNA Co.,Ltd.. All rights reserved.
6
+ * See COPYRIGHT.txt for details.
7
+ */
8
+
9
+ #ifndef DENA_STRING_UTIL_HPP
10
+ #define DENA_STRING_UTIL_HPP
11
+
12
+ #include <string>
13
+ #include <string.h>
14
+ #include <stdint.h>
15
+
16
+ #include "string_buffer.hpp"
17
+ #include "string_ref.hpp"
18
+
19
+ namespace dena {
20
+
21
+ inline const char *
22
+ memchr_char(const char *s, int c, size_t n)
23
+ {
24
+ return static_cast<const char *>(memchr(s, c, n));
25
+ }
26
+
27
+ inline char *
28
+ memchr_char(char *s, int c, size_t n)
29
+ {
30
+ return static_cast<char *>(memchr(s, c, n));
31
+ }
32
+
33
+ string_wref get_token(char *& wp, char *wp_end, char delim);
34
+ uint32_t atoi_uint32_nocheck(const char *start, const char *finish);
35
+ std::string to_stdstring(uint32_t v);
36
+ void append_uint32(string_buffer& buf, uint32_t v);
37
+ long long atoll_nocheck(const char *start, const char *finish);
38
+
39
+ int errno_string(const char *s, int en, std::string& err_r);
40
+
41
+ size_t split(char delim, const string_ref& buf, string_ref *parts,
42
+ size_t parts_len);
43
+ size_t split(char delim, const string_wref& buf, string_wref *parts,
44
+ size_t parts_len);
45
+ size_t split(char delim, const string_ref& buf,
46
+ std::vector<string_ref>& parts_r);
47
+ size_t split(char delim, const string_wref& buf,
48
+ std::vector<string_wref>& parts_r);
49
+
50
+ };
51
+
52
+ #endif
53
+
@@ -0,0 +1,84 @@
1
+
2
+ // vim:sw=2:ai
3
+
4
+ /*
5
+ * Copyright (C) 2010 DeNA Co.,Ltd.. All rights reserved.
6
+ * See COPYRIGHT.txt for details.
7
+ */
8
+
9
+ #ifndef DENA_THREAD_HPP
10
+ #define DENA_THREAD_HPP
11
+
12
+ #include <stdexcept>
13
+ #include <pthread.h>
14
+
15
+ #include "fatal.hpp"
16
+
17
+ namespace dena {
18
+
19
+ template <typename T>
20
+ struct thread : private noncopyable {
21
+ template <typename Ta> thread(const Ta& arg, size_t stack_sz = 256 * 1024)
22
+ : obj(arg), thr(0), need_join(false), stack_size(stack_sz) { }
23
+ template <typename Ta0, typename Ta1> thread(const Ta0& a0,
24
+ volatile Ta1& a1, size_t stack_sz = 256 * 1024)
25
+ : obj(a0, a1), thr(0), need_join(false), stack_size(stack_sz) { }
26
+ ~thread() {
27
+ join();
28
+ }
29
+ void start() {
30
+ if (!start_nothrow()) {
31
+ fatal_abort("thread::start");
32
+ }
33
+ }
34
+ bool start_nothrow() {
35
+ if (need_join) {
36
+ return need_join; /* true */
37
+ }
38
+ void *const arg = this;
39
+ pthread_attr_t attr;
40
+ if (pthread_attr_init(&attr) != 0) {
41
+ fatal_abort("pthread_attr_init");
42
+ }
43
+ if (pthread_attr_setstacksize(&attr, stack_size) != 0) {
44
+ fatal_abort("pthread_attr_setstacksize");
45
+ }
46
+ const int r = pthread_create(&thr, &attr, thread_main, arg);
47
+ if (pthread_attr_destroy(&attr) != 0) {
48
+ fatal_abort("pthread_attr_destroy");
49
+ }
50
+ if (r != 0) {
51
+ return need_join; /* false */
52
+ }
53
+ need_join = true;
54
+ return need_join; /* true */
55
+ }
56
+ void join() {
57
+ if (!need_join) {
58
+ return;
59
+ }
60
+ int e = 0;
61
+ if ((e = pthread_join(thr, 0)) != 0) {
62
+ fatal_abort("pthread_join");
63
+ }
64
+ need_join = false;
65
+ }
66
+ T& operator *() { return obj; }
67
+ T *operator ->() { return &obj; }
68
+ private:
69
+ static void *thread_main(void *arg) {
70
+ thread *p = static_cast<thread *>(arg);
71
+ p->obj();
72
+ return 0;
73
+ }
74
+ private:
75
+ T obj;
76
+ pthread_t thr;
77
+ bool need_join;
78
+ size_t stack_size;
79
+ };
80
+
81
+ };
82
+
83
+ #endif
84
+
@@ -0,0 +1,25 @@
1
+
2
+ // vim:sw=2:ai
3
+
4
+ /*
5
+ * Copyright (C) 2010 DeNA Co.,Ltd.. All rights reserved.
6
+ * See COPYRIGHT.txt for details.
7
+ */
8
+
9
+ #ifndef DENA_UTIL_HPP
10
+ #define DENA_UTIL_HPP
11
+
12
+ namespace dena {
13
+
14
+ /* boost::noncopyable */
15
+ struct noncopyable {
16
+ noncopyable() { }
17
+ private:
18
+ noncopyable(const noncopyable&);
19
+ noncopyable& operator =(const noncopyable&);
20
+ };
21
+
22
+ };
23
+
24
+ #endif
25
+
@@ -0,0 +1,130 @@
1
+ [a@c54hdd libhsclient]$ ./hstest_hs.sh host=192.168.100.104 key_mask=1000000 num_threads=100 num=10000000 timelimit=10 dbname=hstest
2
+ now: 1274127653 cntdiff: 265538 tdiff: 1.000996 rps: 265273.757409
3
+ now: 1274127654 cntdiff: 265762 tdiff: 1.000995 rps: 265497.850684
4
+ now: 1274127655 cntdiff: 265435 tdiff: 1.001010 rps: 265167.196749
5
+ now: 1274127656 cntdiff: 265144 tdiff: 1.000994 rps: 264880.654203
6
+ now: 1274127657 cntdiff: 265593 tdiff: 1.000995 rps: 265329.018659
7
+ now: 1274127658 cntdiff: 264863 tdiff: 1.000996 rps: 264599.492138
8
+ now: 1274127659 cntdiff: 265688 tdiff: 1.001008 rps: 265420.447231
9
+ now: 1274127660 cntdiff: 265727 tdiff: 1.000999 rps: 265461.810594
10
+ now: 1274127661 cntdiff: 265848 tdiff: 1.001010 rps: 265579.716809
11
+ now: 1274127662 cntdiff: 265430 tdiff: 1.000992 rps: 265167.001723
12
+ now: 1274127663 cntdiff: 266379 tdiff: 1.001008 rps: 266110.751381
13
+ now: 1274127664 cntdiff: 266244 tdiff: 1.001003 rps: 265977.217679
14
+ now: 1274127665 cntdiff: 265737 tdiff: 1.000996 rps: 265472.559379
15
+ now: 1274127666 cntdiff: 265878 tdiff: 1.001003 rps: 265611.647683
16
+ (1274127656.104648: 1328292, 1274127666.114649: 3985679), 265473.20173 qps
17
+
18
+
19
+ *************************** 1. row ***************************
20
+ Type: InnoDB
21
+ Name:
22
+ Status:
23
+ =====================================
24
+ 100518 5:18:13 INNODB MONITOR OUTPUT
25
+ =====================================
26
+ Per second averages calculated from the last 5 seconds
27
+ ----------
28
+ BACKGROUND THREAD
29
+ ----------
30
+ srv_master_thread loops: 191 1_second, 190 sleeps, 18 10_second, 5 background, 5 flush
31
+ srv_master_thread log flush and writes: 190
32
+ ----------
33
+ SEMAPHORES
34
+ ----------
35
+ OS WAIT ARRAY INFO: reservation count 53519, signal count 29547
36
+ Mutex spin waits 3083488, rounds 5159906, OS waits 50700
37
+ RW-shared spins 21, OS waits 16; RW-excl spins 1, OS waits 4
38
+ Spin rounds per wait: 1.67 mutex, 30.00 RW-shared, 151.00 RW-excl
39
+ ------------
40
+ TRANSACTIONS
41
+ ------------
42
+ Trx id counter EDA36085
43
+ Purge done for trx's n:o < EC1F94A7 undo n:o < 0
44
+ History list length 20
45
+ LIST OF TRANSACTIONS FOR EACH SESSION:
46
+ ---TRANSACTION 0, not started, process no 4533, OS thread id 1079281984
47
+ MySQL thread id 11, query id 16 localhost root
48
+ show engine innodb status
49
+ ---TRANSACTION ED9D5959, not started, process no 4533, OS thread id 1089849664
50
+ MySQL thread id 7, query id 0 handlersocket: mode=rd, 0 conns, 0 active
51
+ ---TRANSACTION ED9D5956, not started, process no 4533, OS thread id 1238796608
52
+ MySQL thread id 1, query id 0 handlersocket: mode=rd, 0 conns, 0 active
53
+ ---TRANSACTION EDA36084, not started, process no 4533, OS thread id 1255582016
54
+ mysql tables in use 1, locked 1
55
+ MySQL thread id 3, query id 0 handlersocket: mode=rd, 12 conns, 7 active
56
+ ---TRANSACTION EDA36080, not started, process no 4533, OS thread id 1247189312
57
+ mysql tables in use 1, locked 1
58
+ MySQL thread id 2, query id 0 handlersocket: mode=rd, 36 conns, 18 active
59
+ ---TRANSACTION EDA36082, ACTIVE 0 sec, process no 4533, OS thread id 1263974720 committing
60
+ MySQL thread id 4, query id 0 handlersocket: mode=rd, 37 conns, 20 active
61
+ Trx read view will not see trx with id >= EDA36083, sees < EDA3607D
62
+ ---TRANSACTION EDA3607D, ACTIVE 0 sec, process no 4533, OS thread id 1272367424, thread declared inside InnoDB 500
63
+ mysql tables in use 1, locked 1
64
+ MySQL thread id 5, query id 0 handlersocket: mode=rd, 15 conns, 9 active
65
+ Trx read view will not see trx with id >= EDA3607E, sees < EDA36079
66
+ --------
67
+ FILE I/O
68
+ --------
69
+ I/O thread 0 state: waiting for i/o request (insert buffer thread)
70
+ I/O thread 1 state: waiting for i/o request (log thread)
71
+ I/O thread 2 state: waiting for i/o request (read thread)
72
+ I/O thread 3 state: waiting for i/o request (read thread)
73
+ I/O thread 4 state: waiting for i/o request (read thread)
74
+ I/O thread 5 state: waiting for i/o request (read thread)
75
+ I/O thread 6 state: waiting for i/o request (write thread)
76
+ I/O thread 7 state: waiting for i/o request (write thread)
77
+ I/O thread 8 state: waiting for i/o request (write thread)
78
+ I/O thread 9 state: waiting for i/o request (write thread)
79
+ Pending normal aio reads: 0, aio writes: 0,
80
+ ibuf aio reads: 0, log i/o's: 0, sync i/o's: 0
81
+ Pending flushes (fsync) log: 0; buffer pool: 0
82
+ 71 OS file reads, 235 OS file writes, 235 OS fsyncs
83
+ 0.00 reads/s, 0 avg bytes/read, 1.00 writes/s, 1.00 fsyncs/s
84
+ -------------------------------------
85
+ INSERT BUFFER AND ADAPTIVE HASH INDEX
86
+ -------------------------------------
87
+ Ibuf: size 1, free list len 0, seg size 2,
88
+ 0 inserts, 0 merged recs, 0 merges
89
+ Hash table size 12750011, node heap has 2 buffer(s)
90
+ 267203.76 hash searches/s, 0.00 non-hash searches/s
91
+ ---
92
+ LOG
93
+ ---
94
+ Log sequence number 147179727377
95
+ Log flushed up to 147179726685
96
+ Last checkpoint at 147179716475
97
+ 0 pending log writes, 0 pending chkp writes
98
+ 194 log i/o's done, 1.00 log i/o's/second
99
+ ----------------------
100
+ BUFFER POOL AND MEMORY
101
+ ----------------------
102
+ Total memory allocated 6587154432; in additional pool allocated 0
103
+ Dictionary memory allocated 33640
104
+ Buffer pool size 393216
105
+ Free buffers 393154
106
+ Database pages 60
107
+ Old database pages 0
108
+ Modified db pages 1
109
+ Pending reads 0
110
+ Pending writes: LRU 0, flush list 0, single page 0
111
+ Pages made young 0, not young 0
112
+ 0.00 youngs/s, 0.00 non-youngs/s
113
+ Pages read 60, created 0, written 23
114
+ 0.00 reads/s, 0.00 creates/s, 0.00 writes/s
115
+ Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
116
+ Pages read ahead 0.00/s, evicted without access 0.00/s
117
+ LRU len: 60, unzip_LRU len: 0
118
+ I/O sum[0]:cur[0], unzip sum[0]:cur[0]
119
+ --------------
120
+ ROW OPERATIONS
121
+ --------------
122
+ 2 queries inside InnoDB, 0 queries in queue
123
+ 3 read views open inside InnoDB
124
+ Main thread process no. 4533, id 1230403904, state: sleeping
125
+ Number of rows inserted 0, updated 0, deleted 0, read 37653556
126
+ 0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 266608.28 reads/s
127
+ ----------------------------
128
+ END OF INNODB MONITOR OUTPUT
129
+ ============================
130
+