couchbase-memcached 1.2.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (539) hide show
  1. data.tar.gz.sig +2 -0
  2. data/BENCHMARKS +134 -0
  3. data/CHANGELOG +127 -0
  4. data/LICENSE +184 -0
  5. data/Manifest +535 -0
  6. data/README +118 -0
  7. data/Rakefile +83 -0
  8. data/TODO +4 -0
  9. data/couchbase-memcached.gemspec +33 -0
  10. data/ext/extconf-make.rb +25 -0
  11. data/ext/extconf.rb +91 -0
  12. data/ext/libmemcached-0.50/AUTHORS +11 -0
  13. data/ext/libmemcached-0.50/COPYING +33 -0
  14. data/ext/libmemcached-0.50/ChangeLog +392 -0
  15. data/ext/libmemcached-0.50/Makefile.am +114 -0
  16. data/ext/libmemcached-0.50/Makefile.in +4232 -0
  17. data/ext/libmemcached-0.50/NEWS +1 -0
  18. data/ext/libmemcached-0.50/README +43 -0
  19. data/ext/libmemcached-0.50/README.FIRST +31 -0
  20. data/ext/libmemcached-0.50/README.win32 +25 -0
  21. data/ext/libmemcached-0.50/THANKS +14 -0
  22. data/ext/libmemcached-0.50/TODO +11 -0
  23. data/ext/libmemcached-0.50/aclocal.m4 +1077 -0
  24. data/ext/libmemcached-0.50/clients/client_options.h +45 -0
  25. data/ext/libmemcached-0.50/clients/execute.cc +131 -0
  26. data/ext/libmemcached-0.50/clients/execute.h +30 -0
  27. data/ext/libmemcached-0.50/clients/generator.cc +96 -0
  28. data/ext/libmemcached-0.50/clients/generator.h +36 -0
  29. data/ext/libmemcached-0.50/clients/include.am +116 -0
  30. data/ext/libmemcached-0.50/clients/memaslap.c +908 -0
  31. data/ext/libmemcached-0.50/clients/memcapable.cc +2094 -0
  32. data/ext/libmemcached-0.50/clients/memcat.cc +242 -0
  33. data/ext/libmemcached-0.50/clients/memcp.cc +317 -0
  34. data/ext/libmemcached-0.50/clients/memdump.cc +183 -0
  35. data/ext/libmemcached-0.50/clients/memerror.cc +102 -0
  36. data/ext/libmemcached-0.50/clients/memflush.cc +154 -0
  37. data/ext/libmemcached-0.50/clients/memparse.cc +68 -0
  38. data/ext/libmemcached-0.50/clients/memrm.cc +177 -0
  39. data/ext/libmemcached-0.50/clients/memslap.cc +495 -0
  40. data/ext/libmemcached-0.50/clients/memstat.cc +349 -0
  41. data/ext/libmemcached-0.50/clients/ms_atomic.h +69 -0
  42. data/ext/libmemcached-0.50/clients/ms_conn.c +3413 -0
  43. data/ext/libmemcached-0.50/clients/ms_conn.h +241 -0
  44. data/ext/libmemcached-0.50/clients/ms_memslap.h +132 -0
  45. data/ext/libmemcached-0.50/clients/ms_setting.c +1068 -0
  46. data/ext/libmemcached-0.50/clients/ms_setting.h +181 -0
  47. data/ext/libmemcached-0.50/clients/ms_sigsegv.c +126 -0
  48. data/ext/libmemcached-0.50/clients/ms_sigsegv.h +34 -0
  49. data/ext/libmemcached-0.50/clients/ms_stats.c +307 -0
  50. data/ext/libmemcached-0.50/clients/ms_stats.h +69 -0
  51. data/ext/libmemcached-0.50/clients/ms_task.c +1114 -0
  52. data/ext/libmemcached-0.50/clients/ms_task.h +94 -0
  53. data/ext/libmemcached-0.50/clients/ms_thread.c +351 -0
  54. data/ext/libmemcached-0.50/clients/ms_thread.h +78 -0
  55. data/ext/libmemcached-0.50/clients/utilities.cc +231 -0
  56. data/ext/libmemcached-0.50/clients/utilities.h +64 -0
  57. data/ext/libmemcached-0.50/config.h.in +647 -0
  58. data/ext/libmemcached-0.50/config/autorun.sh +126 -0
  59. data/ext/libmemcached-0.50/config/compile +143 -0
  60. data/ext/libmemcached-0.50/config/config.guess +1517 -0
  61. data/ext/libmemcached-0.50/config/config.rpath +666 -0
  62. data/ext/libmemcached-0.50/config/config.sub +1760 -0
  63. data/ext/libmemcached-0.50/config/depcomp +630 -0
  64. data/ext/libmemcached-0.50/config/install-sh +520 -0
  65. data/ext/libmemcached-0.50/config/ltmain.sh +9642 -0
  66. data/ext/libmemcached-0.50/config/missing +376 -0
  67. data/ext/libmemcached-0.50/config/pandora-plugin +752 -0
  68. data/ext/libmemcached-0.50/config/uncrustify.cfg +1112 -0
  69. data/ext/libmemcached-0.50/configure +27103 -0
  70. data/ext/libmemcached-0.50/configure.ac +186 -0
  71. data/ext/libmemcached-0.50/docs/conf.py.in +354 -0
  72. data/ext/libmemcached-0.50/docs/include.am +240 -0
  73. data/ext/libmemcached-0.50/docs/man/hashkit_clone.3 +88 -0
  74. data/ext/libmemcached-0.50/docs/man/hashkit_crc32.3 +105 -0
  75. data/ext/libmemcached-0.50/docs/man/hashkit_create.3 +88 -0
  76. data/ext/libmemcached-0.50/docs/man/hashkit_fnv1_32.3 +105 -0
  77. data/ext/libmemcached-0.50/docs/man/hashkit_fnv1_64.3 +105 -0
  78. data/ext/libmemcached-0.50/docs/man/hashkit_fnv1a_32.3 +105 -0
  79. data/ext/libmemcached-0.50/docs/man/hashkit_fnv1a_64.3 +105 -0
  80. data/ext/libmemcached-0.50/docs/man/hashkit_free.3 +88 -0
  81. data/ext/libmemcached-0.50/docs/man/hashkit_functions.3 +105 -0
  82. data/ext/libmemcached-0.50/docs/man/hashkit_hsieh.3 +105 -0
  83. data/ext/libmemcached-0.50/docs/man/hashkit_is_allocated.3 +88 -0
  84. data/ext/libmemcached-0.50/docs/man/hashkit_jenkins.3 +105 -0
  85. data/ext/libmemcached-0.50/docs/man/hashkit_md5.3 +105 -0
  86. data/ext/libmemcached-0.50/docs/man/hashkit_murmur.3 +105 -0
  87. data/ext/libmemcached-0.50/docs/man/hashkit_value.3 +66 -0
  88. data/ext/libmemcached-0.50/docs/man/libhashkit.3 +57 -0
  89. data/ext/libmemcached-0.50/docs/man/libmemcached.3 +208 -0
  90. data/ext/libmemcached-0.50/docs/man/libmemcached_check_configuration.3 +293 -0
  91. data/ext/libmemcached-0.50/docs/man/libmemcached_configuration.3 +293 -0
  92. data/ext/libmemcached-0.50/docs/man/libmemcached_examples.3 +144 -0
  93. data/ext/libmemcached-0.50/docs/man/libmemcachedutil.3 +68 -0
  94. data/ext/libmemcached-0.50/docs/man/memaslap.1 +1222 -0
  95. data/ext/libmemcached-0.50/docs/man/memcached.3 +293 -0
  96. data/ext/libmemcached-0.50/docs/man/memcached_add.3 +132 -0
  97. data/ext/libmemcached-0.50/docs/man/memcached_add_by_key.3 +132 -0
  98. data/ext/libmemcached-0.50/docs/man/memcached_analyze.3 +77 -0
  99. data/ext/libmemcached-0.50/docs/man/memcached_append.3 +111 -0
  100. data/ext/libmemcached-0.50/docs/man/memcached_append_by_key.3 +111 -0
  101. data/ext/libmemcached-0.50/docs/man/memcached_behavior_get.3 +333 -0
  102. data/ext/libmemcached-0.50/docs/man/memcached_behavior_set.3 +333 -0
  103. data/ext/libmemcached-0.50/docs/man/memcached_callback_get.3 +159 -0
  104. data/ext/libmemcached-0.50/docs/man/memcached_callback_set.3 +159 -0
  105. data/ext/libmemcached-0.50/docs/man/memcached_cas.3 +91 -0
  106. data/ext/libmemcached-0.50/docs/man/memcached_cas_by_key.3 +91 -0
  107. data/ext/libmemcached-0.50/docs/man/memcached_clone.3 +99 -0
  108. data/ext/libmemcached-0.50/docs/man/memcached_create.3 +99 -0
  109. data/ext/libmemcached-0.50/docs/man/memcached_decrement.3 +124 -0
  110. data/ext/libmemcached-0.50/docs/man/memcached_decrement_with_initial.3 +124 -0
  111. data/ext/libmemcached-0.50/docs/man/memcached_delete.3 +83 -0
  112. data/ext/libmemcached-0.50/docs/man/memcached_delete_by_key.3 +83 -0
  113. data/ext/libmemcached-0.50/docs/man/memcached_destroy_sasl_auth_data.3 +95 -0
  114. data/ext/libmemcached-0.50/docs/man/memcached_dump.3 +77 -0
  115. data/ext/libmemcached-0.50/docs/man/memcached_fetch.3 +174 -0
  116. data/ext/libmemcached-0.50/docs/man/memcached_fetch_execute.3 +174 -0
  117. data/ext/libmemcached-0.50/docs/man/memcached_fetch_result.3 +174 -0
  118. data/ext/libmemcached-0.50/docs/man/memcached_flush_buffers.3 +72 -0
  119. data/ext/libmemcached-0.50/docs/man/memcached_free.3 +99 -0
  120. data/ext/libmemcached-0.50/docs/man/memcached_generate_hash.3 +85 -0
  121. data/ext/libmemcached-0.50/docs/man/memcached_generate_hash_value.3 +85 -0
  122. data/ext/libmemcached-0.50/docs/man/memcached_get.3 +174 -0
  123. data/ext/libmemcached-0.50/docs/man/memcached_get_by_key.3 +174 -0
  124. data/ext/libmemcached-0.50/docs/man/memcached_get_memory_allocators.3 +111 -0
  125. data/ext/libmemcached-0.50/docs/man/memcached_get_sasl_callbacks.3 +95 -0
  126. data/ext/libmemcached-0.50/docs/man/memcached_get_user_data.3 +79 -0
  127. data/ext/libmemcached-0.50/docs/man/memcached_increment.3 +124 -0
  128. data/ext/libmemcached-0.50/docs/man/memcached_increment_with_initial.3 +124 -0
  129. data/ext/libmemcached-0.50/docs/man/memcached_lib_version.3 +76 -0
  130. data/ext/libmemcached-0.50/docs/man/memcached_mget.3 +174 -0
  131. data/ext/libmemcached-0.50/docs/man/memcached_mget_by_key.3 +174 -0
  132. data/ext/libmemcached-0.50/docs/man/memcached_mget_execute.3 +174 -0
  133. data/ext/libmemcached-0.50/docs/man/memcached_mget_execute_by_key.3 +174 -0
  134. data/ext/libmemcached-0.50/docs/man/memcached_pool_behavior_get.3 +139 -0
  135. data/ext/libmemcached-0.50/docs/man/memcached_pool_behavior_set.3 +139 -0
  136. data/ext/libmemcached-0.50/docs/man/memcached_pool_create.3 +139 -0
  137. data/ext/libmemcached-0.50/docs/man/memcached_pool_destroy.3 +139 -0
  138. data/ext/libmemcached-0.50/docs/man/memcached_pool_pop.3 +139 -0
  139. data/ext/libmemcached-0.50/docs/man/memcached_pool_push.3 +139 -0
  140. data/ext/libmemcached-0.50/docs/man/memcached_pool_st.3 +139 -0
  141. data/ext/libmemcached-0.50/docs/man/memcached_prepend.3 +111 -0
  142. data/ext/libmemcached-0.50/docs/man/memcached_prepend_by_key.3 +111 -0
  143. data/ext/libmemcached-0.50/docs/man/memcached_quit.3 +74 -0
  144. data/ext/libmemcached-0.50/docs/man/memcached_replace.3 +132 -0
  145. data/ext/libmemcached-0.50/docs/man/memcached_replace_by_key.3 +132 -0
  146. data/ext/libmemcached-0.50/docs/man/memcached_sasl_set_auth_data.3 +95 -0
  147. data/ext/libmemcached-0.50/docs/man/memcached_server_add.3 +141 -0
  148. data/ext/libmemcached-0.50/docs/man/memcached_server_count.3 +141 -0
  149. data/ext/libmemcached-0.50/docs/man/memcached_server_cursor.3 +141 -0
  150. data/ext/libmemcached-0.50/docs/man/memcached_server_list.3 +141 -0
  151. data/ext/libmemcached-0.50/docs/man/memcached_server_list_append.3 +111 -0
  152. data/ext/libmemcached-0.50/docs/man/memcached_server_list_count.3 +111 -0
  153. data/ext/libmemcached-0.50/docs/man/memcached_server_list_free.3 +111 -0
  154. data/ext/libmemcached-0.50/docs/man/memcached_server_push.3 +141 -0
  155. data/ext/libmemcached-0.50/docs/man/memcached_servers_parse.3 +111 -0
  156. data/ext/libmemcached-0.50/docs/man/memcached_set.3 +132 -0
  157. data/ext/libmemcached-0.50/docs/man/memcached_set_by_key.3 +132 -0
  158. data/ext/libmemcached-0.50/docs/man/memcached_set_memory_allocators.3 +111 -0
  159. data/ext/libmemcached-0.50/docs/man/memcached_set_sasl_callbacks.3 +95 -0
  160. data/ext/libmemcached-0.50/docs/man/memcached_set_user_data.3 +79 -0
  161. data/ext/libmemcached-0.50/docs/man/memcached_stat.3 +116 -0
  162. data/ext/libmemcached-0.50/docs/man/memcached_stat_execute.3 +116 -0
  163. data/ext/libmemcached-0.50/docs/man/memcached_stat_get_keys.3 +116 -0
  164. data/ext/libmemcached-0.50/docs/man/memcached_stat_get_value.3 +116 -0
  165. data/ext/libmemcached-0.50/docs/man/memcached_stat_servername.3 +116 -0
  166. data/ext/libmemcached-0.50/docs/man/memcached_strerror.3 +69 -0
  167. data/ext/libmemcached-0.50/docs/man/memcached_verbosity.3 +66 -0
  168. data/ext/libmemcached-0.50/docs/man/memcached_version.3 +76 -0
  169. data/ext/libmemcached-0.50/docs/man/memcapable.1 +92 -0
  170. data/ext/libmemcached-0.50/docs/man/memcat.1 +71 -0
  171. data/ext/libmemcached-0.50/docs/man/memcp.1 +77 -0
  172. data/ext/libmemcached-0.50/docs/man/memdump.1 +66 -0
  173. data/ext/libmemcached-0.50/docs/man/memerror.1 +65 -0
  174. data/ext/libmemcached-0.50/docs/man/memflush.1 +73 -0
  175. data/ext/libmemcached-0.50/docs/man/memrm.1 +72 -0
  176. data/ext/libmemcached-0.50/docs/man/memslap.1 +59 -0
  177. data/ext/libmemcached-0.50/docs/man/memstat.1 +70 -0
  178. data/ext/libmemcached-0.50/example/include.am +24 -0
  179. data/ext/libmemcached-0.50/example/interface_v0.c +594 -0
  180. data/ext/libmemcached-0.50/example/interface_v1.c +411 -0
  181. data/ext/libmemcached-0.50/example/memcached_light.c +474 -0
  182. data/ext/libmemcached-0.50/example/memcached_light.h +7 -0
  183. data/ext/libmemcached-0.50/example/storage.c +172 -0
  184. data/ext/libmemcached-0.50/example/storage.h +27 -0
  185. data/ext/libmemcached-0.50/example/storage_innodb.c +535 -0
  186. data/ext/libmemcached-0.50/libhashkit/algorithm.cc +69 -0
  187. data/ext/libmemcached-0.50/libhashkit/algorithm.h +96 -0
  188. data/ext/libmemcached-0.50/libhashkit/behavior.cc +9 -0
  189. data/ext/libmemcached-0.50/libhashkit/behavior.h +26 -0
  190. data/ext/libmemcached-0.50/libhashkit/common.h +33 -0
  191. data/ext/libmemcached-0.50/libhashkit/configure.h.in +19 -0
  192. data/ext/libmemcached-0.50/libhashkit/crc32.cc +86 -0
  193. data/ext/libmemcached-0.50/libhashkit/digest.cc +62 -0
  194. data/ext/libmemcached-0.50/libhashkit/digest.h +30 -0
  195. data/ext/libmemcached-0.50/libhashkit/fnv.cc +75 -0
  196. data/ext/libmemcached-0.50/libhashkit/function.cc +156 -0
  197. data/ext/libmemcached-0.50/libhashkit/function.h +44 -0
  198. data/ext/libmemcached-0.50/libhashkit/hashkit.cc +100 -0
  199. data/ext/libmemcached-0.50/libhashkit/hashkit.h +95 -0
  200. data/ext/libmemcached-0.50/libhashkit/hashkit.hpp +97 -0
  201. data/ext/libmemcached-0.50/libhashkit/hsieh.cc +70 -0
  202. data/ext/libmemcached-0.50/libhashkit/include.am +69 -0
  203. data/ext/libmemcached-0.50/libhashkit/jenkins.cc +214 -0
  204. data/ext/libmemcached-0.50/libhashkit/ketama.cc +164 -0
  205. data/ext/libmemcached-0.50/libhashkit/md5.cc +367 -0
  206. data/ext/libmemcached-0.50/libhashkit/murmur.cc +77 -0
  207. data/ext/libmemcached-0.50/libhashkit/one_at_a_time.cc +34 -0
  208. data/ext/libmemcached-0.50/libhashkit/str_algorithm.cc +58 -0
  209. data/ext/libmemcached-0.50/libhashkit/str_algorithm.h +48 -0
  210. data/ext/libmemcached-0.50/libhashkit/strerror.cc +25 -0
  211. data/ext/libmemcached-0.50/libhashkit/strerror.h +23 -0
  212. data/ext/libmemcached-0.50/libhashkit/types.h +90 -0
  213. data/ext/libmemcached-0.50/libhashkit/visibility.h +48 -0
  214. data/ext/libmemcached-0.50/libmemcached/allocators.cc +119 -0
  215. data/ext/libmemcached-0.50/libmemcached/allocators.h +87 -0
  216. data/ext/libmemcached-0.50/libmemcached/analyze.cc +110 -0
  217. data/ext/libmemcached-0.50/libmemcached/analyze.h +66 -0
  218. data/ext/libmemcached-0.50/libmemcached/array.c +128 -0
  219. data/ext/libmemcached-0.50/libmemcached/array.h +75 -0
  220. data/ext/libmemcached-0.50/libmemcached/auto.cc +383 -0
  221. data/ext/libmemcached-0.50/libmemcached/auto.h +111 -0
  222. data/ext/libmemcached-0.50/libmemcached/basic_string.h +55 -0
  223. data/ext/libmemcached-0.50/libmemcached/behavior.cc +590 -0
  224. data/ext/libmemcached-0.50/libmemcached/behavior.h +86 -0
  225. data/ext/libmemcached-0.50/libmemcached/byteorder.cc +90 -0
  226. data/ext/libmemcached-0.50/libmemcached/byteorder.h +52 -0
  227. data/ext/libmemcached-0.50/libmemcached/callback.cc +160 -0
  228. data/ext/libmemcached-0.50/libmemcached/callback.h +61 -0
  229. data/ext/libmemcached-0.50/libmemcached/common.h +182 -0
  230. data/ext/libmemcached-0.50/libmemcached/configure.h.in +52 -0
  231. data/ext/libmemcached-0.50/libmemcached/connect.cc +626 -0
  232. data/ext/libmemcached-0.50/libmemcached/constants.h +167 -0
  233. data/ext/libmemcached-0.50/libmemcached/delete.cc +266 -0
  234. data/ext/libmemcached-0.50/libmemcached/delete.h +57 -0
  235. data/ext/libmemcached-0.50/libmemcached/do.cc +100 -0
  236. data/ext/libmemcached-0.50/libmemcached/do.hpp +49 -0
  237. data/ext/libmemcached-0.50/libmemcached/dump.cc +107 -0
  238. data/ext/libmemcached-0.50/libmemcached/dump.h +51 -0
  239. data/ext/libmemcached-0.50/libmemcached/error.cc +419 -0
  240. data/ext/libmemcached-0.50/libmemcached/error.h +61 -0
  241. data/ext/libmemcached-0.50/libmemcached/error.hpp +87 -0
  242. data/ext/libmemcached-0.50/libmemcached/exception.hpp +63 -0
  243. data/ext/libmemcached-0.50/libmemcached/fetch.cc +267 -0
  244. data/ext/libmemcached-0.50/libmemcached/fetch.h +53 -0
  245. data/ext/libmemcached-0.50/libmemcached/flush.cc +149 -0
  246. data/ext/libmemcached-0.50/libmemcached/flush.h +49 -0
  247. data/ext/libmemcached-0.50/libmemcached/flush_buffers.cc +66 -0
  248. data/ext/libmemcached-0.50/libmemcached/flush_buffers.h +49 -0
  249. data/ext/libmemcached-0.50/libmemcached/get.cc +842 -0
  250. data/ext/libmemcached-0.50/libmemcached/get.h +135 -0
  251. data/ext/libmemcached-0.50/libmemcached/hash.cc +178 -0
  252. data/ext/libmemcached-0.50/libmemcached/hash.h +68 -0
  253. data/ext/libmemcached-0.50/libmemcached/hosts.cc +516 -0
  254. data/ext/libmemcached-0.50/libmemcached/include.am +183 -0
  255. data/ext/libmemcached-0.50/libmemcached/initialize_query.cc +70 -0
  256. data/ext/libmemcached-0.50/libmemcached/initialize_query.h +51 -0
  257. data/ext/libmemcached-0.50/libmemcached/internal.h +46 -0
  258. data/ext/libmemcached-0.50/libmemcached/io.cc +920 -0
  259. data/ext/libmemcached-0.50/libmemcached/io.h +119 -0
  260. data/ext/libmemcached-0.50/libmemcached/is.h +48 -0
  261. data/ext/libmemcached-0.50/libmemcached/key.cc +23 -0
  262. data/ext/libmemcached-0.50/libmemcached/libmemcached_probes.d +30 -0
  263. data/ext/libmemcached-0.50/libmemcached/libmemcached_probes.h +118 -0
  264. data/ext/libmemcached-0.50/libmemcached/memcached.cc +437 -0
  265. data/ext/libmemcached-0.50/libmemcached/memcached.h +214 -0
  266. data/ext/libmemcached-0.50/libmemcached/memcached.hpp +799 -0
  267. data/ext/libmemcached-0.50/libmemcached/memcached/README.txt +7 -0
  268. data/ext/libmemcached-0.50/libmemcached/memcached/protocol_binary.h +726 -0
  269. data/ext/libmemcached-0.50/libmemcached/memcached/vbucket.h +26 -0
  270. data/ext/libmemcached-0.50/libmemcached/memcached_util.h +44 -0
  271. data/ext/libmemcached-0.50/libmemcached/memory.h +79 -0
  272. data/ext/libmemcached-0.50/libmemcached/options.cc +178 -0
  273. data/ext/libmemcached-0.50/libmemcached/options.h +49 -0
  274. data/ext/libmemcached-0.50/libmemcached/options.hpp +56 -0
  275. data/ext/libmemcached-0.50/libmemcached/options/context.h +151 -0
  276. data/ext/libmemcached-0.50/libmemcached/options/include.am +19 -0
  277. data/ext/libmemcached-0.50/libmemcached/options/parser.am +0 -0
  278. data/ext/libmemcached-0.50/libmemcached/options/parser.cc +2324 -0
  279. data/ext/libmemcached-0.50/libmemcached/options/parser.h +122 -0
  280. data/ext/libmemcached-0.50/libmemcached/options/scanner.cc +3203 -0
  281. data/ext/libmemcached-0.50/libmemcached/options/scanner.h +479 -0
  282. data/ext/libmemcached-0.50/libmemcached/options/server.h +60 -0
  283. data/ext/libmemcached-0.50/libmemcached/options/symbol.h +57 -0
  284. data/ext/libmemcached-0.50/libmemcached/parse.cc +110 -0
  285. data/ext/libmemcached-0.50/libmemcached/parse.h +23 -0
  286. data/ext/libmemcached-0.50/libmemcached/platform.h +56 -0
  287. data/ext/libmemcached-0.50/libmemcached/prefix_key.cc +65 -0
  288. data/ext/libmemcached-0.50/libmemcached/prefix_key.h +49 -0
  289. data/ext/libmemcached-0.50/libmemcached/protocol/ascii_handler.c +963 -0
  290. data/ext/libmemcached-0.50/libmemcached/protocol/ascii_handler.h +40 -0
  291. data/ext/libmemcached-0.50/libmemcached/protocol/binary_handler.c +1121 -0
  292. data/ext/libmemcached-0.50/libmemcached/protocol/binary_handler.h +47 -0
  293. data/ext/libmemcached-0.50/libmemcached/protocol/cache.c +149 -0
  294. data/ext/libmemcached-0.50/libmemcached/protocol/cache.h +116 -0
  295. data/ext/libmemcached-0.50/libmemcached/protocol/callback.h +418 -0
  296. data/ext/libmemcached-0.50/libmemcached/protocol/common.h +163 -0
  297. data/ext/libmemcached-0.50/libmemcached/protocol/include.am +26 -0
  298. data/ext/libmemcached-0.50/libmemcached/protocol/pedantic.c +202 -0
  299. data/ext/libmemcached-0.50/libmemcached/protocol/protocol_handler.c +365 -0
  300. data/ext/libmemcached-0.50/libmemcached/protocol_handler.h +215 -0
  301. data/ext/libmemcached-0.50/libmemcached/purge.cc +90 -0
  302. data/ext/libmemcached-0.50/libmemcached/quit.cc +139 -0
  303. data/ext/libmemcached-0.50/libmemcached/quit.h +55 -0
  304. data/ext/libmemcached-0.50/libmemcached/response.cc +619 -0
  305. data/ext/libmemcached-0.50/libmemcached/response.h +57 -0
  306. data/ext/libmemcached-0.50/libmemcached/result.cc +173 -0
  307. data/ext/libmemcached-0.50/libmemcached/result.h +100 -0
  308. data/ext/libmemcached-0.50/libmemcached/return.h +98 -0
  309. data/ext/libmemcached-0.50/libmemcached/sasl.c +408 -0
  310. data/ext/libmemcached-0.50/libmemcached/sasl.h +86 -0
  311. data/ext/libmemcached-0.50/libmemcached/server.cc +351 -0
  312. data/ext/libmemcached-0.50/libmemcached/server.h +169 -0
  313. data/ext/libmemcached-0.50/libmemcached/server_list.cc +88 -0
  314. data/ext/libmemcached-0.50/libmemcached/server_list.h +77 -0
  315. data/ext/libmemcached-0.50/libmemcached/stats.cc +623 -0
  316. data/ext/libmemcached-0.50/libmemcached/stats.h +96 -0
  317. data/ext/libmemcached-0.50/libmemcached/storage.cc +567 -0
  318. data/ext/libmemcached-0.50/libmemcached/storage.h +133 -0
  319. data/ext/libmemcached-0.50/libmemcached/strerror.cc +189 -0
  320. data/ext/libmemcached-0.50/libmemcached/strerror.h +50 -0
  321. data/ext/libmemcached-0.50/libmemcached/string.cc +253 -0
  322. data/ext/libmemcached-0.50/libmemcached/string.h +121 -0
  323. data/ext/libmemcached-0.50/libmemcached/touch.cc +106 -0
  324. data/ext/libmemcached-0.50/libmemcached/touch.h +59 -0
  325. data/ext/libmemcached-0.50/libmemcached/types.h +117 -0
  326. data/ext/libmemcached-0.50/libmemcached/util.h +40 -0
  327. data/ext/libmemcached-0.50/libmemcached/util/flush.cc +61 -0
  328. data/ext/libmemcached-0.50/libmemcached/util/flush.h +50 -0
  329. data/ext/libmemcached-0.50/libmemcached/util/include.am +34 -0
  330. data/ext/libmemcached-0.50/libmemcached/util/ping.cc +62 -0
  331. data/ext/libmemcached-0.50/libmemcached/util/ping.h +49 -0
  332. data/ext/libmemcached-0.50/libmemcached/util/pool.cc +392 -0
  333. data/ext/libmemcached-0.50/libmemcached/util/pool.h +78 -0
  334. data/ext/libmemcached-0.50/libmemcached/util/version.cc +87 -0
  335. data/ext/libmemcached-0.50/libmemcached/util/version.h +53 -0
  336. data/ext/libmemcached-0.50/libmemcached/verbosity.cc +97 -0
  337. data/ext/libmemcached-0.50/libmemcached/verbosity.h +50 -0
  338. data/ext/libmemcached-0.50/libmemcached/version.cc +214 -0
  339. data/ext/libmemcached-0.50/libmemcached/version.h +52 -0
  340. data/ext/libmemcached-0.50/libmemcached/virtual_bucket.c +118 -0
  341. data/ext/libmemcached-0.50/libmemcached/virtual_bucket.h +59 -0
  342. data/ext/libmemcached-0.50/libmemcached/visibility.h +51 -0
  343. data/ext/libmemcached-0.50/libmemcached/watchpoint.h +110 -0
  344. data/ext/libmemcached-0.50/libtest/callbacks.h +21 -0
  345. data/ext/libmemcached-0.50/libtest/collection.h +19 -0
  346. data/ext/libmemcached-0.50/libtest/common.h +50 -0
  347. data/ext/libmemcached-0.50/libtest/core.h +11 -0
  348. data/ext/libmemcached-0.50/libtest/error.h +18 -0
  349. data/ext/libmemcached-0.50/libtest/failed.h +52 -0
  350. data/ext/libmemcached-0.50/libtest/framework.cc +57 -0
  351. data/ext/libmemcached-0.50/libtest/framework.h +137 -0
  352. data/ext/libmemcached-0.50/libtest/get.h +22 -0
  353. data/ext/libmemcached-0.50/libtest/include.am +52 -0
  354. data/ext/libmemcached-0.50/libtest/runner.h +19 -0
  355. data/ext/libmemcached-0.50/libtest/server.c +355 -0
  356. data/ext/libmemcached-0.50/libtest/server.h +43 -0
  357. data/ext/libmemcached-0.50/libtest/stats.h +30 -0
  358. data/ext/libmemcached-0.50/libtest/strerror.h +14 -0
  359. data/ext/libmemcached-0.50/libtest/test.cc +319 -0
  360. data/ext/libmemcached-0.50/libtest/test.h +162 -0
  361. data/ext/libmemcached-0.50/libtest/test.hpp +46 -0
  362. data/ext/libmemcached-0.50/libtest/visibility.h +69 -0
  363. data/ext/libmemcached-0.50/m4/ac_cxx_header_stdcxx_98.m4 +83 -0
  364. data/ext/libmemcached-0.50/m4/acx_pthread.m4 +271 -0
  365. data/ext/libmemcached-0.50/m4/byteorder.m4 +19 -0
  366. data/ext/libmemcached-0.50/m4/deprecated.m4 +17 -0
  367. data/ext/libmemcached-0.50/m4/eagain.m4 +28 -0
  368. data/ext/libmemcached-0.50/m4/enable_utillib.m4 +16 -0
  369. data/ext/libmemcached-0.50/m4/gettext.m4 +379 -0
  370. data/ext/libmemcached-0.50/m4/hsieh.m4 +18 -0
  371. data/ext/libmemcached-0.50/m4/iconv.m4 +214 -0
  372. data/ext/libmemcached-0.50/m4/lib-ld.m4 +110 -0
  373. data/ext/libmemcached-0.50/m4/lib-link.m4 +767 -0
  374. data/ext/libmemcached-0.50/m4/lib-prefix.m4 +221 -0
  375. data/ext/libmemcached-0.50/m4/libtool.m4 +7851 -0
  376. data/ext/libmemcached-0.50/m4/ltoptions.m4 +369 -0
  377. data/ext/libmemcached-0.50/m4/ltsugar.m4 +123 -0
  378. data/ext/libmemcached-0.50/m4/ltversion.m4 +23 -0
  379. data/ext/libmemcached-0.50/m4/lt~obsolete.m4 +98 -0
  380. data/ext/libmemcached-0.50/m4/memaslap.m4 +9 -0
  381. data/ext/libmemcached-0.50/m4/memcached.m4 +31 -0
  382. data/ext/libmemcached-0.50/m4/murmur.m4 +18 -0
  383. data/ext/libmemcached-0.50/m4/pandora_64bit.m4 +60 -0
  384. data/ext/libmemcached-0.50/m4/pandora_bison.m4 +33 -0
  385. data/ext/libmemcached-0.50/m4/pandora_canonical.m4 +418 -0
  386. data/ext/libmemcached-0.50/m4/pandora_check_compiler_version.m4 +37 -0
  387. data/ext/libmemcached-0.50/m4/pandora_check_cxx_standard.m4 +23 -0
  388. data/ext/libmemcached-0.50/m4/pandora_cinttypes.m4 +39 -0
  389. data/ext/libmemcached-0.50/m4/pandora_clock_gettime.m4 +15 -0
  390. data/ext/libmemcached-0.50/m4/pandora_compile_stdcxx_0x.m4 +103 -0
  391. data/ext/libmemcached-0.50/m4/pandora_cstdint.m4 +38 -0
  392. data/ext/libmemcached-0.50/m4/pandora_cxx_demangle.m4 +27 -0
  393. data/ext/libmemcached-0.50/m4/pandora_enable_dtrace.m4 +60 -0
  394. data/ext/libmemcached-0.50/m4/pandora_ensure_gcc_version.m4 +62 -0
  395. data/ext/libmemcached-0.50/m4/pandora_extensions.m4 +16 -0
  396. data/ext/libmemcached-0.50/m4/pandora_fdatasync.m4 +25 -0
  397. data/ext/libmemcached-0.50/m4/pandora_flex.m4 +33 -0
  398. data/ext/libmemcached-0.50/m4/pandora_have_better_malloc.m4 +66 -0
  399. data/ext/libmemcached-0.50/m4/pandora_have_boost.m4 +93 -0
  400. data/ext/libmemcached-0.50/m4/pandora_have_gcc_atomics.m4 +37 -0
  401. data/ext/libmemcached-0.50/m4/pandora_have_innodb.m4 +41 -0
  402. data/ext/libmemcached-0.50/m4/pandora_have_libaio.m4 +56 -0
  403. data/ext/libmemcached-0.50/m4/pandora_have_libavahi.m4 +41 -0
  404. data/ext/libmemcached-0.50/m4/pandora_have_libbdb.m4 +40 -0
  405. data/ext/libmemcached-0.50/m4/pandora_have_libboost_date_time.m4 +46 -0
  406. data/ext/libmemcached-0.50/m4/pandora_have_libboost_filesystem.m4 +47 -0
  407. data/ext/libmemcached-0.50/m4/pandora_have_libboost_iostreams.m4 +49 -0
  408. data/ext/libmemcached-0.50/m4/pandora_have_libboost_options.m4 +47 -0
  409. data/ext/libmemcached-0.50/m4/pandora_have_libboost_regex.m4 +54 -0
  410. data/ext/libmemcached-0.50/m4/pandora_have_libboost_test.m4 +45 -0
  411. data/ext/libmemcached-0.50/m4/pandora_have_libboost_thread.m4 +54 -0
  412. data/ext/libmemcached-0.50/m4/pandora_have_libcassandra.m4 +44 -0
  413. data/ext/libmemcached-0.50/m4/pandora_have_libcurl.m4 +62 -0
  414. data/ext/libmemcached-0.50/m4/pandora_have_libdl.m4 +51 -0
  415. data/ext/libmemcached-0.50/m4/pandora_have_libdrizzle.m4 +61 -0
  416. data/ext/libmemcached-0.50/m4/pandora_have_libevent.m4 +66 -0
  417. data/ext/libmemcached-0.50/m4/pandora_have_libgearman.m4 +41 -0
  418. data/ext/libmemcached-0.50/m4/pandora_have_libgtest.m4 +47 -0
  419. data/ext/libmemcached-0.50/m4/pandora_have_libhaildb.m4 +43 -0
  420. data/ext/libmemcached-0.50/m4/pandora_have_libhashkit.m4 +42 -0
  421. data/ext/libmemcached-0.50/m4/pandora_have_libinnodb.m4 +64 -0
  422. data/ext/libmemcached-0.50/m4/pandora_have_libldap.m4 +73 -0
  423. data/ext/libmemcached-0.50/m4/pandora_have_libmemcached.m4 +106 -0
  424. data/ext/libmemcached-0.50/m4/pandora_have_libmysqlclient.m4 +146 -0
  425. data/ext/libmemcached-0.50/m4/pandora_have_libndbclient.m4 +80 -0
  426. data/ext/libmemcached-0.50/m4/pandora_have_libpcre.m4 +73 -0
  427. data/ext/libmemcached-0.50/m4/pandora_have_libpq.m4 +46 -0
  428. data/ext/libmemcached-0.50/m4/pandora_have_libpqxx.m4 +44 -0
  429. data/ext/libmemcached-0.50/m4/pandora_have_libsqlite3.m4 +42 -0
  430. data/ext/libmemcached-0.50/m4/pandora_have_libtokyocabinet.m4 +54 -0
  431. data/ext/libmemcached-0.50/m4/pandora_have_libuuid.m4 +55 -0
  432. data/ext/libmemcached-0.50/m4/pandora_have_libvbucket.m4 +40 -0
  433. data/ext/libmemcached-0.50/m4/pandora_have_libxml2.m4 +52 -0
  434. data/ext/libmemcached-0.50/m4/pandora_have_libz.m4 +51 -0
  435. data/ext/libmemcached-0.50/m4/pandora_have_protobuf.m4 +82 -0
  436. data/ext/libmemcached-0.50/m4/pandora_have_sasl.m4 +133 -0
  437. data/ext/libmemcached-0.50/m4/pandora_have_thrift.m4 +45 -0
  438. data/ext/libmemcached-0.50/m4/pandora_header_assert.m4 +23 -0
  439. data/ext/libmemcached-0.50/m4/pandora_header_stdcxx_98.m4 +83 -0
  440. data/ext/libmemcached-0.50/m4/pandora_intltool.m4 +225 -0
  441. data/ext/libmemcached-0.50/m4/pandora_libtool.m4 +25 -0
  442. data/ext/libmemcached-0.50/m4/pandora_optimize.m4 +75 -0
  443. data/ext/libmemcached-0.50/m4/pandora_platform.m4 +117 -0
  444. data/ext/libmemcached-0.50/m4/pandora_plugins.m4 +62 -0
  445. data/ext/libmemcached-0.50/m4/pandora_print_callstack.m4 +61 -0
  446. data/ext/libmemcached-0.50/m4/pandora_pthread.m4 +258 -0
  447. data/ext/libmemcached-0.50/m4/pandora_python3_devel.m4 +236 -0
  448. data/ext/libmemcached-0.50/m4/pandora_run_cpplint.m4 +8 -0
  449. data/ext/libmemcached-0.50/m4/pandora_sasl.m4 +133 -0
  450. data/ext/libmemcached-0.50/m4/pandora_shared_ptr.m4 +59 -0
  451. data/ext/libmemcached-0.50/m4/pandora_stack_direction.m4 +39 -0
  452. data/ext/libmemcached-0.50/m4/pandora_stl_hash.m4 +94 -0
  453. data/ext/libmemcached-0.50/m4/pandora_swig.m4 +39 -0
  454. data/ext/libmemcached-0.50/m4/pandora_use_pipe.m4 +36 -0
  455. data/ext/libmemcached-0.50/m4/pandora_vc_build.m4 +168 -0
  456. data/ext/libmemcached-0.50/m4/pandora_version.m4 +11 -0
  457. data/ext/libmemcached-0.50/m4/pandora_visibility.m4 +75 -0
  458. data/ext/libmemcached-0.50/m4/pandora_warnings.m4 +447 -0
  459. data/ext/libmemcached-0.50/m4/pandora_with_gettext.m4 +44 -0
  460. data/ext/libmemcached-0.50/m4/pandora_with_lua.m4 +55 -0
  461. data/ext/libmemcached-0.50/m4/pandora_with_memcached.m4 +41 -0
  462. data/ext/libmemcached-0.50/m4/pandora_with_perl.m4 +81 -0
  463. data/ext/libmemcached-0.50/m4/pandora_with_php.m4 +56 -0
  464. data/ext/libmemcached-0.50/m4/pandora_with_python.m4 +37 -0
  465. data/ext/libmemcached-0.50/m4/pandora_with_python3.m4 +44 -0
  466. data/ext/libmemcached-0.50/m4/pandora_with_r.m4 +33 -0
  467. data/ext/libmemcached-0.50/m4/pandora_with_ruby.m4 +79 -0
  468. data/ext/libmemcached-0.50/m4/pandora_with_valgrind.m4 +17 -0
  469. data/ext/libmemcached-0.50/m4/pkg.m4 +157 -0
  470. data/ext/libmemcached-0.50/m4/po.m4 +449 -0
  471. data/ext/libmemcached-0.50/m4/progtest.m4 +92 -0
  472. data/ext/libmemcached-0.50/m4/protocol_binary.m4 +36 -0
  473. data/ext/libmemcached-0.50/m4/setsockopt.m4 +73 -0
  474. data/ext/libmemcached-0.50/m4/socket_send_flags.m4 +66 -0
  475. data/ext/libmemcached-0.50/poll/include.am +8 -0
  476. data/ext/libmemcached-0.50/poll/poll.c +77 -0
  477. data/ext/libmemcached-0.50/poll/poll.h +45 -0
  478. data/ext/libmemcached-0.50/support/include.am +11 -0
  479. data/ext/libmemcached-0.50/support/libmemcached-fc.spec.in +105 -0
  480. data/ext/libmemcached-0.50/support/libmemcached.pc.in +10 -0
  481. data/ext/libmemcached-0.50/support/libmemcached.spec.in +281 -0
  482. data/ext/libmemcached-0.50/support/set_benchmark.sh +5 -0
  483. data/ext/libmemcached-0.50/tests/atomsmasher.cc +295 -0
  484. data/ext/libmemcached-0.50/tests/basic.cc +134 -0
  485. data/ext/libmemcached-0.50/tests/basic.h +66 -0
  486. data/ext/libmemcached-0.50/tests/cpp_example.cc +195 -0
  487. data/ext/libmemcached-0.50/tests/deprecated.cc +72 -0
  488. data/ext/libmemcached-0.50/tests/deprecated.h +49 -0
  489. data/ext/libmemcached-0.50/tests/error_conditions.cc +63 -0
  490. data/ext/libmemcached-0.50/tests/error_conditions.h +48 -0
  491. data/ext/libmemcached-0.50/tests/hash_plus.cc +225 -0
  492. data/ext/libmemcached-0.50/tests/hash_results.h +127 -0
  493. data/ext/libmemcached-0.50/tests/hashkit_functions.cc +619 -0
  494. data/ext/libmemcached-0.50/tests/include.am +342 -0
  495. data/ext/libmemcached-0.50/tests/ketama_test_cases.h +121 -0
  496. data/ext/libmemcached-0.50/tests/ketama_test_cases_spy.h +118 -0
  497. data/ext/libmemcached-0.50/tests/libmemcached_world.h +205 -0
  498. data/ext/libmemcached-0.50/tests/mem_functions.cc +6648 -0
  499. data/ext/libmemcached-0.50/tests/mem_udp.cc +510 -0
  500. data/ext/libmemcached-0.50/tests/output_plus.res +5 -0
  501. data/ext/libmemcached-0.50/tests/parser.cc +599 -0
  502. data/ext/libmemcached-0.50/tests/parser.h +109 -0
  503. data/ext/libmemcached-0.50/tests/plus.cpp +240 -0
  504. data/ext/libmemcached-0.50/tests/pool.cc +78 -0
  505. data/ext/libmemcached-0.50/tests/pool.h +49 -0
  506. data/ext/libmemcached-0.50/tests/print.cc +58 -0
  507. data/ext/libmemcached-0.50/tests/print.h +51 -0
  508. data/ext/libmemcached-0.50/tests/replication.cc +333 -0
  509. data/ext/libmemcached-0.50/tests/replication.h +64 -0
  510. data/ext/libmemcached-0.50/tests/start.cc +29 -0
  511. data/ext/libmemcached-0.50/tests/string.cc +174 -0
  512. data/ext/libmemcached-0.50/tests/string.h +67 -0
  513. data/ext/libmemcached-0.50/tests/virtual_buckets.cc +143 -0
  514. data/ext/libmemcached-0.50/tests/virtual_buckets.h +51 -0
  515. data/ext/libmemcached-0.50/win32/include.am +11 -0
  516. data/ext/libmemcached-0.50/win32/wrappers.h +55 -0
  517. data/ext/rlibmemcached.i +263 -0
  518. data/ext/rlibmemcached_wrap.c +16732 -0
  519. data/lib/memcached.rb +32 -0
  520. data/lib/memcached/auth.rb +16 -0
  521. data/lib/memcached/behaviors.rb +77 -0
  522. data/lib/memcached/exceptions.rb +84 -0
  523. data/lib/memcached/experimental.rb +48 -0
  524. data/lib/memcached/memcached.rb +660 -0
  525. data/lib/memcached/rails.rb +133 -0
  526. data/test/profile/benchmark.rb +245 -0
  527. data/test/profile/c_profiler.rb +14 -0
  528. data/test/profile/exercise.rb +185 -0
  529. data/test/profile/rb_profiler.rb +21 -0
  530. data/test/profile/valgrind.rb +10 -0
  531. data/test/setup.rb +30 -0
  532. data/test/teardown.rb +0 -0
  533. data/test/test_helper.rb +19 -0
  534. data/test/unit/binding_test.rb +8 -0
  535. data/test/unit/memcached_experimental_test.rb +274 -0
  536. data/test/unit/memcached_test.rb +1293 -0
  537. data/test/unit/rails_test.rb +122 -0
  538. metadata +650 -0
  539. metadata.gz.sig +0 -0
@@ -0,0 +1,241 @@
1
+ /*
2
+ * File: ms_conn.h
3
+ * Author: Mingqiang Zhuang
4
+ *
5
+ * Created on February 10, 2009
6
+ *
7
+ * (c) Copyright 2009, Schooner Information Technology, Inc.
8
+ * http://www.schoonerinfotech.com/
9
+ *
10
+ */
11
+ #ifndef MS_CONN_H
12
+ #define MS_CONN_H
13
+
14
+ #include <sys/socket.h>
15
+ #include <netinet/in.h>
16
+ #include <event.h>
17
+ #include <netdb.h>
18
+
19
+ #include "ms_task.h"
20
+ #include <libmemcached/memcached/protocol_binary.h>
21
+
22
+ #ifdef __cplusplus
23
+ extern "C" {
24
+ #endif
25
+
26
+ #define DATA_BUFFER_SIZE (1024 * 1024 + 2048) /* read buffer, 1M + 2k, enough for the max value(1M) */
27
+ #define WRITE_BUFFER_SIZE (32 * 1024) /* write buffer, 32k */
28
+ #define UDP_DATA_BUFFER_SIZE (1 * 1024 * 1024) /* read buffer for UDP, 1M */
29
+ #define UDP_MAX_PAYLOAD_SIZE 1400 /* server limit UDP payload size */
30
+ #define UDP_MAX_SEND_PAYLOAD_SIZE 1400 /* mtu size is 1500 */
31
+ #define UDP_HEADER_SIZE 8 /* UDP header size */
32
+ #define MAX_SENDBUF_SIZE (256 * 1024 * 1024) /* Maximum socket buffer size */
33
+ #define SOCK_WAIT_TIMEOUT 30 /* maximum waiting time of UDP, 30s */
34
+ #define MAX_UDP_PACKET (1 << 16) /* maximum UDP packets, 65536 */
35
+
36
+ /* Initial size of the sendmsg() scatter/gather array. */
37
+ #define IOV_LIST_INITIAL 400
38
+
39
+ /* Initial number of sendmsg() argument structures to allocate. */
40
+ #define MSG_LIST_INITIAL 10
41
+
42
+ /* High water marks for buffer shrinking */
43
+ #define READ_BUFFER_HIGHWAT (2 * DATA_BUFFER_SIZE)
44
+ #define UDP_DATA_BUFFER_HIGHWAT (4 * UDP_DATA_BUFFER_SIZE)
45
+ #define IOV_LIST_HIGHWAT 600
46
+ #define MSG_LIST_HIGHWAT 100
47
+
48
+ /* parse udp header */
49
+ #define HEADER_TO_REQID(ptr) ((uint16_t)*ptr * 256 \
50
+ + (uint16_t)*(ptr + 1))
51
+ #define HEADER_TO_SEQNUM(ptr) ((uint16_t)*(ptr \
52
+ + 2) * 256 \
53
+ + (uint16_t)*(ptr + 3))
54
+ #define HEADER_TO_PACKETS(ptr) ((uint16_t)*(ptr \
55
+ + 4) * 256 \
56
+ + (uint16_t)*(ptr + 5))
57
+
58
+ /* states of connection */
59
+ enum conn_states
60
+ {
61
+ conn_read, /* reading in a command line */
62
+ conn_write, /* writing out a simple response */
63
+ conn_closing /* closing this connection */
64
+ };
65
+
66
+ /* returned states of memcached command */
67
+ enum mcd_ret
68
+ {
69
+ MCD_SUCCESS, /* command success */
70
+ MCD_FAILURE, /* command failure */
71
+ MCD_UNKNOWN_READ_FAILURE, /* unknown read failure */
72
+ MCD_PROTOCOL_ERROR, /* protocol error */
73
+ MCD_CLIENT_ERROR, /* client error, wrong command */
74
+ MCD_SERVER_ERROR, /* server error, server run command failed */
75
+ MCD_DATA_EXISTS, /* object is existent in server */
76
+ MCD_NOTSTORED, /* server doesn't set the object successfully */
77
+ MCD_STORED, /* server set the object successfully */
78
+ MCD_NOTFOUND, /* server not find the object */
79
+ MCD_END, /* end of the response of get command */
80
+ MCD_DELETED, /* server delete the object successfully */
81
+ MCD_STAT /* response of stats command */
82
+ };
83
+
84
+ /* used to store the current or previous running command state */
85
+ typedef struct cmdstat
86
+ {
87
+ int cmd; /* command name */
88
+ int retstat; /* return state of this command */
89
+ bool isfinish; /* if it read all the response data */
90
+ uint64_t key_prefix; /* key prefix */
91
+ } ms_cmdstat_t;
92
+
93
+ /* udp packet structure */
94
+ typedef struct udppkt
95
+ {
96
+ uint8_t *header; /* udp header of the packet */
97
+ char *data; /* udp data of the packet */
98
+ int rbytes; /* number of data in the packet */
99
+ int copybytes; /* number of copied data in the packet */
100
+ } ms_udppkt_t;
101
+
102
+ /* three protocols supported */
103
+ enum protocol
104
+ {
105
+ ascii_prot = 3, /* ASCII protocol */
106
+ binary_prot /* binary protocol */
107
+ };
108
+
109
+ /**
110
+ * concurrency structure
111
+ *
112
+ * Each thread has a libevent to manage the events of network.
113
+ * Each thread has one or more self-governed concurrencies;
114
+ * each concurrency has one or more socket connections. This
115
+ * concurrency structure includes all the private variables of
116
+ * the concurrency.
117
+ */
118
+ typedef struct conn
119
+ {
120
+ uint32_t conn_idx; /* connection index in the thread */
121
+ int sfd; /* current tcp sock handler of the connection structure */
122
+ int udpsfd; /* current udp sock handler of the connection structure*/
123
+ int state; /* state of the connection */
124
+ struct event event; /* event for libevent */
125
+ short ev_flags; /* event flag for libevent */
126
+ short which; /* which events were just triggered */
127
+ bool change_sfd; /* whether change sfd */
128
+
129
+ int *tcpsfd; /* TCP sock array */
130
+ uint32_t total_sfds; /* how many socks in the tcpsfd array */
131
+ uint32_t alive_sfds; /* alive socks */
132
+ uint32_t cur_idx; /* current sock index in tcpsfd array */
133
+
134
+ ms_cmdstat_t precmd; /* previous command state */
135
+ ms_cmdstat_t currcmd; /* current command state */
136
+
137
+ char *rbuf; /* buffer to read commands into */
138
+ char *rcurr; /* but if we parsed some already, this is where we stopped */
139
+ int rsize; /* total allocated size of rbuf */
140
+ int rbytes; /* how much data, starting from rcur, do we have unparsed */
141
+
142
+ bool readval; /* read value state, read known data size */
143
+ int rvbytes; /* total value size need to read */
144
+
145
+ char *wbuf; /* buffer to write commands out */
146
+ char *wcurr; /* for multi-get, where we stopped */
147
+ int wsize; /* total allocated size of wbuf */
148
+ bool ctnwrite; /* continue to write */
149
+
150
+ /* data for the mwrite state */
151
+ struct iovec *iov;
152
+ int iovsize; /* number of elements allocated in iov[] */
153
+ int iovused; /* number of elements used in iov[] */
154
+
155
+ struct msghdr *msglist;
156
+ int msgsize; /* number of elements allocated in msglist[] */
157
+ int msgused; /* number of elements used in msglist[] */
158
+ int msgcurr; /* element in msglist[] being transmitted now */
159
+ int msgbytes; /* number of bytes in current msg */
160
+
161
+ /* data for UDP clients */
162
+ bool udp; /* is this is a UDP "connection" */
163
+ uint32_t request_id; /* UDP request ID of current operation, if this is a UDP "connection" */
164
+ uint8_t *hdrbuf; /* udp packet headers */
165
+ int hdrsize; /* number of headers' worth of space is allocated */
166
+ struct sockaddr srv_recv_addr; /* Sent the most recent request to which server */
167
+ socklen_t srv_recv_addr_size;
168
+
169
+ /* udp read buffer */
170
+ char *rudpbuf; /* buffer to read commands into for udp */
171
+ int rudpsize; /* total allocated size of rudpbuf */
172
+ int rudpbytes; /* how much data, starting from rudpbuf */
173
+
174
+ /* order udp packet */
175
+ ms_udppkt_t *udppkt; /* the offset of udp packet in rudpbuf */
176
+ int packets; /* number of total packets need to read */
177
+ int recvpkt; /* number of received packets */
178
+ int pktcurr; /* current packet in rudpbuf being ordered */
179
+ int ordcurr; /* current ordered packet */
180
+
181
+ ms_task_item_t *item_win; /* task sequence */
182
+ int win_size; /* current task window size */
183
+ uint64_t set_cursor; /* current set item index in the item window */
184
+ ms_task_t curr_task; /* current running task */
185
+ ms_mlget_task_t mlget_task; /* multi-get task */
186
+
187
+ int warmup_num; /* to run how many warm up operations*/
188
+ int remain_warmup_num; /* left how many warm up operations to run */
189
+ int64_t exec_num; /* to run how many task operations */
190
+ int64_t remain_exec_num; /* how many remained task operations to run */
191
+
192
+ /* response time statistic and time out control */
193
+ struct timeval start_time; /* start time of current operation(s) */
194
+ struct timeval end_time; /* end time of current operation(s) */
195
+
196
+ /* Binary protocol stuff */
197
+ protocol_binary_response_header binary_header; /* local temporary binary header */
198
+ enum protocol protocol; /* which protocol this connection speaks */
199
+ } ms_conn_t;
200
+
201
+ /* used to generate the key prefix */
202
+ uint64_t ms_get_key_prefix(void);
203
+
204
+
205
+ /**
206
+ * setup a connection, each connection structure of each
207
+ * thread must call this function to initialize.
208
+ */
209
+ int ms_setup_conn(ms_conn_t *c);
210
+
211
+
212
+ /* after one operation completes, reset the connection */
213
+ void ms_reset_conn(ms_conn_t *c, bool timeout);
214
+
215
+
216
+ /**
217
+ * reconnect several disconnected socks in the connection
218
+ * structure, the ever-1-second timer of the thread will check
219
+ * whether some socks in the connections disconnect. if
220
+ * disconnect, reconnect the sock.
221
+ */
222
+ int ms_reconn_socks(ms_conn_t *c);
223
+
224
+
225
+ /* used to send set command to server */
226
+ int ms_mcd_set(ms_conn_t *c, ms_task_item_t *item);
227
+
228
+
229
+ /* used to send the get command to server */
230
+ int ms_mcd_get(ms_conn_t *c, ms_task_item_t *item);
231
+
232
+
233
+ /* used to send the multi-get command to server */
234
+ int ms_mcd_mlget(ms_conn_t *c);
235
+
236
+
237
+ #ifdef __cplusplus
238
+ }
239
+ #endif
240
+
241
+ #endif /* end of MS_CONN_H */
@@ -0,0 +1,132 @@
1
+ /*
2
+ * File: ms_memslap.h
3
+ * Author: Mingqiang Zhuang
4
+ *
5
+ * Created on February 10, 2009
6
+ *
7
+ * (c) Copyright 2009, Schooner Information Technology, Inc.
8
+ * http://www.schoonerinfotech.com/
9
+ *
10
+ */
11
+ #ifndef MS_MEMSLAP_H
12
+ #define MS_MEMSLAP_H
13
+
14
+ #include <stdlib.h>
15
+ #include <stdio.h>
16
+ #include <errno.h>
17
+ #include <string.h>
18
+ #include <assert.h>
19
+ #include <unistd.h>
20
+ #include <stdint.h>
21
+ #include <pthread.h>
22
+ #if !defined(__cplusplus)
23
+ # include <stdbool.h>
24
+ #endif
25
+ #include <math.h>
26
+
27
+ #include "ms_stats.h"
28
+
29
+ #ifdef __cplusplus
30
+ extern "C" {
31
+ #endif
32
+
33
+ /* command line option */
34
+ typedef enum
35
+ {
36
+ OPT_VERSION= 'V',
37
+ OPT_HELP= 'h',
38
+ OPT_UDP= 'U',
39
+ OPT_SERVERS= 's',
40
+ OPT_EXECUTE_NUMBER= 'x',
41
+ OPT_THREAD_NUMBER= 'T',
42
+ OPT_CONCURRENCY= 'c',
43
+ OPT_FIXED_LTH= 'X',
44
+ OPT_VERIFY= 'v',
45
+ OPT_GETS_DIVISION= 'd',
46
+ OPT_TIME= 't',
47
+ OPT_CONFIG_CMD= 'F',
48
+ OPT_WINDOW_SIZE= 'w',
49
+ OPT_EXPIRE= 'e',
50
+ OPT_STAT_FREQ= 'S',
51
+ OPT_RECONNECT= 'R',
52
+ OPT_VERBOSE= 'b',
53
+ OPT_FACEBOOK_TEST= 'a',
54
+ OPT_SOCK_PER_CONN= 'n',
55
+ OPT_BINARY_PROTOCOL= 'B',
56
+ OPT_OVERWRITE= 'o',
57
+ OPT_TPS= 'P',
58
+ OPT_REP_WRITE_SRV= 'p'
59
+ } ms_options_t;
60
+
61
+ /* global statistic of response time */
62
+ typedef struct statistic
63
+ {
64
+ pthread_mutex_t stat_mutex; /* synchronize the following members */
65
+
66
+ ms_stat_t get_stat; /* statistics of get command */
67
+ ms_stat_t set_stat; /* statistics of set command */
68
+ ms_stat_t total_stat; /* statistics of both get and set commands */
69
+ } ms_statistic_t;
70
+
71
+ /* global status statistic structure */
72
+ typedef struct stats
73
+ {
74
+ volatile uint32_t active_conns; /* active connections */
75
+ size_t bytes_read; /* read bytes */
76
+ size_t bytes_written; /* written bytes */
77
+ size_t obj_bytes; /* object bytes */
78
+ size_t pre_cmd_get; /* previous total get command count */
79
+ size_t pre_cmd_set; /* previous total set command count */
80
+ size_t cmd_get; /* current total get command count */
81
+ size_t cmd_set; /* current total set command count */
82
+ size_t get_misses; /* total objects of get miss */
83
+ size_t vef_miss; /* total objects of verification miss */
84
+ size_t vef_failed; /* total objects of verification failed */
85
+ size_t unexp_unget; /* total objects which is unexpired but not get */
86
+ size_t exp_get; /* total objects which is expired but get */
87
+ volatile size_t pkt_disorder; /* disorder packages of UDP */
88
+ size_t pkt_drop; /* packages dropped of UDP */
89
+ size_t udp_timeout; /* how many times timeout of UDP happens */
90
+ } ms_stats_t;
91
+
92
+ /* lock adapter */
93
+ typedef struct sync_lock
94
+ {
95
+ uint32_t count;
96
+ pthread_mutex_t lock;
97
+ pthread_cond_t cond;
98
+ } ms_sync_lock_t;
99
+
100
+ /* global variable structure */
101
+ typedef struct global
102
+ {
103
+ /* synchronize lock */
104
+ ms_sync_lock_t init_lock;
105
+ ms_sync_lock_t warmup_lock;
106
+ ms_sync_lock_t run_lock;
107
+
108
+ /* mutex for outputing error log synchronously when memslap crashes */
109
+ pthread_mutex_t quit_mutex;
110
+
111
+ /* mutex for generating key prefix */
112
+ pthread_mutex_t seq_mutex;
113
+
114
+ /* global synchronous flags for slap mode */
115
+ bool finish_warmup;
116
+ bool time_out;
117
+ } ms_global_t;
118
+
119
+ /* global structure */
120
+ ms_global_t ms_global;
121
+
122
+ /* global stats information structure */
123
+ ms_stats_t ms_stats;
124
+
125
+ /* global statistic structure */
126
+ ms_statistic_t ms_statistic;
127
+
128
+ #ifdef __cplusplus
129
+ }
130
+ #endif
131
+
132
+ #endif /* end of MS_MEMSLAP_H */
@@ -0,0 +1,1068 @@
1
+ /*
2
+ * File: ms_setting.c
3
+ * Author: Mingqiang Zhuang
4
+ *
5
+ * Created on February 10, 2009
6
+ *
7
+ * (c) Copyright 2009, Schooner Information Technology, Inc.
8
+ * http://www.schoonerinfotech.com/
9
+ *
10
+ */
11
+
12
+ #include "config.h"
13
+
14
+ #include <libmemcached/memcached.h>
15
+
16
+ #include <ctype.h>
17
+ #include <inttypes.h>
18
+ #include <limits.h>
19
+ #include <pwd.h>
20
+ #include <strings.h>
21
+ #include <sys/types.h>
22
+ #include <unistd.h>
23
+
24
+
25
+
26
+ #include "ms_setting.h"
27
+ #include "ms_conn.h"
28
+
29
+ #define MAX_EXEC_NUM 0x4000000000000000 /* 1 << 62 */
30
+ #define ADDR_ALIGN(addr) ((addr + 15) & ~(16 - 1)) /* 16 bytes aligned */
31
+ #define RAND_CHAR_SIZE (10 * 1024 * 1024) /* 10M character table */
32
+ #define RESERVED_RAND_CHAR_SIZE (2 * 1024 * 1024) /* reserved 2M to avoid pointer sloping over */
33
+
34
+ #define DEFAULT_CONFIG_NAME ".memslap.cnf"
35
+
36
+ #define DEFAULT_THREADS_NUM 1 /* default start one thread */
37
+ #define DEFAULT_CONNS_NUM 16 /* default each thread with 16 connections */
38
+ #define DEFAULT_EXE_NUM 0 /* default execute number is 0 */
39
+ #define DEFAULT_VERIFY_RATE 0.0 /* default it doesn't do data verification */
40
+ #define DEFAULT_OVERWRITE_RATE 0.0 /* default it doesn't do overwrite */
41
+ #define DEFAULT_DIV 1 /* default it runs single get */
42
+ #define DEFAULT_RUN_TIME 600 /* default run time 10 minutes */
43
+ #define DEFAULT_WINDOW_SIZE (10 * UNIT_ITEMS_COUNT) /* default window size is 10k */
44
+ #define DEFAULT_SOCK_PER_CONN 1 /* default socks per connection is 1 */
45
+
46
+ /* Use this for string generation */
47
+ #define CHAR_COUNT 64 /* number of characters used to generate character table */
48
+ const char ALPHANUMBERICS[]=
49
+ "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-";
50
+
51
+ ms_setting_st ms_setting; /* store the settings specified by user */
52
+
53
+
54
+ /* read setting from configuration file */
55
+ static void ms_get_serverlist(char *str);
56
+ static uint32_t ms_get_cpu_count(void);
57
+ ms_conf_type_t ms_get_conf_type(char *line);
58
+ static int ms_is_line_data(char *line);
59
+ static int ms_read_is_data(char *line, ssize_t nread);
60
+ static void ms_no_config_file(void);
61
+ static void ms_parse_cfg_file(char *cfg_file);
62
+
63
+
64
+ /* initialize setting structure */
65
+ static void ms_init_random_block(void);
66
+ static void ms_calc_avg_size(void);
67
+ static int ms_shuffle_distr(ms_distr_t *distr, int length);
68
+ static void ms_build_distr(void);
69
+ static void ms_print_setting(void);
70
+ static void ms_setting_slapmode_init_pre(void);
71
+ static void ms_setting_slapmode_init_post(void);
72
+
73
+ #if !defined(HAVE_GETLINE)
74
+ #include <limits.h>
75
+ static ssize_t getline (char **line, size_t *line_size, FILE *fp)
76
+ {
77
+ char delim= '\n';
78
+ ssize_t result= 0;
79
+ size_t cur_len= 0;
80
+
81
+ if (line == NULL || line_size == NULL || fp == NULL)
82
+ {
83
+ errno = EINVAL;
84
+ return -1;
85
+ }
86
+
87
+ if (*line == NULL || *line_size == 0)
88
+ {
89
+ char *new_line;
90
+ *line_size = 120;
91
+ new_line= (char *) realloc (*line, *line_size);
92
+ if (new_line == NULL)
93
+ {
94
+ result= -1;
95
+ return result;
96
+ }
97
+ *line= new_line;
98
+ }
99
+
100
+ for (;;)
101
+ {
102
+ int i= getc(fp);
103
+ if (i == EOF)
104
+ {
105
+ result = -1;
106
+ break;
107
+ }
108
+
109
+ /* Make enough space for len+1 (for final NUL) bytes. */
110
+ if (cur_len + 1 >= *line_size)
111
+ {
112
+ size_t needed_max=
113
+ SSIZE_MAX < SIZE_MAX ? (size_t) SSIZE_MAX + 1 : SIZE_MAX;
114
+ size_t needed= (2 * (*line_size)) + 1;
115
+ char *new_line;
116
+
117
+ if (needed_max < needed)
118
+ needed= needed_max;
119
+ if (cur_len + 1 >= needed)
120
+ {
121
+ result= -1;
122
+ errno= EOVERFLOW;
123
+ return result;
124
+ }
125
+
126
+ new_line= (char *)realloc(*line, needed);
127
+ if (new_line == NULL)
128
+ {
129
+ result= -1;
130
+ return result;
131
+ }
132
+
133
+ *line= new_line;
134
+ *line_size= needed;
135
+ }
136
+
137
+ (*line)[cur_len]= (char)i;
138
+ cur_len++;
139
+
140
+ if (i == delim)
141
+ break;
142
+ }
143
+ (*line)[cur_len] = '\0';
144
+ if (cur_len != 0)
145
+ return (ssize_t)cur_len;
146
+ return result;
147
+ }
148
+ #endif
149
+
150
+ /**
151
+ * parse the server list string, and build the servers
152
+ * information structure array. this function is used to parse
153
+ * the command line options specified by user.
154
+ *
155
+ * @param str, the string of server list
156
+ */
157
+ static void ms_get_serverlist(char *str)
158
+ {
159
+ ms_mcd_server_t *srvs= NULL;
160
+
161
+ /**
162
+ * Servers list format is like this. For example:
163
+ * "localhost:11108, localhost:11109"
164
+ */
165
+ memcached_server_st *server_pool;
166
+ server_pool = memcached_servers_parse(str);
167
+
168
+ for (uint32_t loop= 0; loop < memcached_server_list_count(server_pool); loop++)
169
+ {
170
+ assert(ms_setting.srv_cnt < ms_setting.total_srv_cnt);
171
+ strcpy(ms_setting.servers[ms_setting.srv_cnt].srv_host_name, server_pool[loop].hostname);
172
+ ms_setting.servers[ms_setting.srv_cnt].srv_port= server_pool[loop].port;
173
+ ms_setting.servers[ms_setting.srv_cnt].disconn_cnt= 0;
174
+ ms_setting.servers[ms_setting.srv_cnt].reconn_cnt= 0;
175
+ ms_setting.srv_cnt++;
176
+
177
+ if (ms_setting.srv_cnt >= ms_setting.total_srv_cnt)
178
+ {
179
+ srvs= (ms_mcd_server_t *)realloc( ms_setting.servers,
180
+ (size_t)ms_setting.total_srv_cnt * sizeof(ms_mcd_server_t) * 2);
181
+ if (srvs == NULL)
182
+ {
183
+ fprintf(stderr, "Can't reallocate servers structure.\n");
184
+ exit(1);
185
+ }
186
+ ms_setting.servers= srvs;
187
+ ms_setting.total_srv_cnt*= 2;
188
+ }
189
+ }
190
+
191
+ memcached_server_free(server_pool);
192
+ } /* ms_get_serverlist */
193
+
194
+
195
+ /**
196
+ * used to get the CPU count of the current system
197
+ *
198
+ * @return return the cpu count if get, else return EXIT_FAILURE
199
+ */
200
+ static uint32_t ms_get_cpu_count()
201
+ {
202
+ #ifdef HAVE__SC_NPROCESSORS_ONLN
203
+ return sysconf(_SC_NPROCESSORS_CONF);
204
+
205
+ #else
206
+ # ifdef HAVE_CPU_SET_T
207
+ int cpu_count= 0;
208
+ cpu_set_t cpu_set;
209
+
210
+ sched_getaffinity(0, sizeof(cpu_set_t), &cpu_set);
211
+
212
+ for (int i= 0; i < (sizeof(cpu_set_t) * 8); i++)
213
+ {
214
+ if (CPU_ISSET(i, &cpu_set))
215
+ {
216
+ cpu_count++;
217
+ }
218
+ }
219
+
220
+ return cpu_count;
221
+
222
+ # endif
223
+ #endif
224
+
225
+ /* the system with one cpu at least */
226
+ return EXIT_FAILURE;
227
+ } /* ms_get_cpu_count */
228
+
229
+
230
+ /**
231
+ * used to get the configure type based on the type string read
232
+ * from the configuration file.
233
+ *
234
+ * @param line, string of one line
235
+ *
236
+ * @return ms_conf_type_t
237
+ */
238
+ ms_conf_type_t ms_get_conf_type(char *line)
239
+ {
240
+ if (! memcmp(line, "key", strlen("key")))
241
+ {
242
+ return CONF_KEY;
243
+ }
244
+ else if (! memcmp(line, "value", strlen("value")))
245
+ {
246
+ return CONF_VALUE;
247
+ }
248
+ else if (! memcmp(line, "cmd", strlen("cmd")))
249
+ {
250
+ return CONF_CMD;
251
+ }
252
+ else
253
+ {
254
+ return CONF_NULL;
255
+ }
256
+ } /* ms_get_conf_type */
257
+
258
+
259
+ /**
260
+ * judge whether the line is a line with useful data. used to
261
+ * parse the configuration file.
262
+ *
263
+ * @param line, string of one line
264
+ *
265
+ * @return if success, return EXIT_FAILURE, else return EXIT_SUCCESS
266
+ */
267
+ static int ms_is_line_data(char *line)
268
+ {
269
+ assert(line != NULL);
270
+
271
+ char *begin_ptr= line;
272
+
273
+ while (isspace(*begin_ptr))
274
+ {
275
+ begin_ptr++;
276
+ }
277
+ if ((begin_ptr[0] == '\0') || (begin_ptr[0] == '#'))
278
+ return EXIT_SUCCESS;
279
+
280
+ return EXIT_FAILURE;
281
+ } /* ms_is_line_data */
282
+
283
+
284
+ /**
285
+ * function to bypass blank line and comments
286
+ *
287
+ * @param line, string of one line
288
+ * @param nread, length of the line
289
+ *
290
+ * @return if it's EOF or not line data, return EXIT_SUCCESS, else return EXIT_FAILURE
291
+ */
292
+ static int ms_read_is_data(char *line, ssize_t nread)
293
+ {
294
+ if ((nread == EOF) || ! ms_is_line_data(line))
295
+ return EXIT_SUCCESS;
296
+
297
+ return EXIT_FAILURE;
298
+ } /* ms_read_is_data */
299
+
300
+
301
+ /**
302
+ * if no configuration file, use this function to create the default
303
+ * configuration file.
304
+ */
305
+ static void ms_no_config_file()
306
+ {
307
+ char userpath[PATH_MAX];
308
+ struct passwd *usr= NULL;
309
+ FILE *fd;
310
+
311
+ usr= getpwuid(getuid());
312
+
313
+ snprintf(userpath, PATH_MAX, "%s/%s", usr->pw_dir, DEFAULT_CONFIG_NAME);
314
+
315
+ if (access (userpath, F_OK | R_OK) == 0)
316
+ goto exit;
317
+
318
+ fd= fopen(userpath, "w+");
319
+
320
+ if (fd == NULL)
321
+ {
322
+ fprintf(stderr, "Could not create default configure file %s\n", userpath);
323
+ perror(strerror(errno));
324
+ exit(1);
325
+ }
326
+ fprintf(fd, "%s", DEFAULT_CONGIF_STR);
327
+ fclose(fd);
328
+
329
+ exit:
330
+ ms_setting.cfg_file= strdup(userpath);
331
+ } /* ms_no_config_file */
332
+
333
+
334
+ /**
335
+ * parse the configuration file
336
+ *
337
+ * @param cfg_file, the configuration file name
338
+ */
339
+ static void ms_parse_cfg_file(char *cfg_file)
340
+ {
341
+ FILE *f;
342
+ size_t start_len, end_len;
343
+ double proportion;
344
+ char *line= NULL;
345
+ size_t read_len;
346
+ ssize_t nread;
347
+ int cmd_type;
348
+ ms_conf_type_t conf_type;
349
+ int end_of_file= 0;
350
+ ms_key_distr_t *key_distr= NULL;
351
+ ms_value_distr_t *val_distr= NULL;
352
+
353
+ if (cfg_file == NULL)
354
+ {
355
+ ms_no_config_file();
356
+ cfg_file= ms_setting.cfg_file;
357
+ }
358
+
359
+ /*read key value configure file*/
360
+ if ((f= fopen(cfg_file, "r")) == NULL)
361
+ {
362
+ fprintf(stderr, "Can not open file: '%s'.\n", cfg_file);
363
+ exit(1);
364
+ }
365
+
366
+ while (1)
367
+ {
368
+ if ((((nread= getline(&line, &read_len, f)) == 1)
369
+ || ! ms_read_is_data(line, nread)) && (nread != EOF)) /* bypass blank line */
370
+ continue;
371
+
372
+ if (nread == EOF)
373
+ {
374
+ fprintf(stderr, "Bad configuration file, no configuration find.\n");
375
+ exit(1);
376
+ }
377
+ conf_type= ms_get_conf_type(line);
378
+ break;
379
+ }
380
+
381
+ while (! end_of_file)
382
+ {
383
+ switch (conf_type)
384
+ {
385
+ case CONF_KEY:
386
+ while (1)
387
+ {
388
+ if ((((nread= getline(&line, &read_len, f)) == 1)
389
+ || ! ms_read_is_data(line, nread)) && (nread != EOF)) /* bypass blank line */
390
+ continue;
391
+
392
+ if (nread != EOF)
393
+ {
394
+ if (sscanf(line, "%zu %zu %lf ", &start_len,
395
+ &end_len, &proportion) != 3)
396
+ {
397
+ conf_type= ms_get_conf_type(line);
398
+ break;
399
+ }
400
+ ms_setting.key_distr[ms_setting.key_rng_cnt].start_len= start_len;
401
+ ms_setting.key_distr[ms_setting.key_rng_cnt].end_len= end_len;
402
+ ms_setting.key_distr[ms_setting.key_rng_cnt].key_prop= proportion;
403
+ ms_setting.key_rng_cnt++;
404
+
405
+ if (ms_setting.key_rng_cnt >= ms_setting.total_key_rng_cnt)
406
+ {
407
+ key_distr= (ms_key_distr_t *)realloc(
408
+ ms_setting.key_distr,
409
+ (size_t)ms_setting.
410
+ total_key_rng_cnt * sizeof(ms_key_distr_t) * 2);
411
+ if (key_distr == NULL)
412
+ {
413
+ fprintf(stderr,
414
+ "Can't reallocate key distribution structure.\n");
415
+ exit(1);
416
+ }
417
+ ms_setting.key_distr= key_distr;
418
+ ms_setting.total_key_rng_cnt*= 2;
419
+ }
420
+ continue;
421
+ }
422
+ end_of_file= 1;
423
+ break;
424
+ }
425
+ break;
426
+
427
+ case CONF_VALUE:
428
+ while (1)
429
+ {
430
+ if ((((nread= getline(&line, &read_len, f)) == 1)
431
+ || ! ms_read_is_data(line, nread)) && (nread != EOF)) /* bypass blank line */
432
+ continue;
433
+
434
+ if (nread != EOF)
435
+ {
436
+ if (sscanf(line, "%zu %zu %lf", &start_len, &end_len,
437
+ &proportion) != 3)
438
+ {
439
+ conf_type= ms_get_conf_type(line);
440
+ break;
441
+ }
442
+ ms_setting.value_distr[ms_setting.val_rng_cnt].start_len=
443
+ start_len;
444
+ ms_setting.value_distr[ms_setting.val_rng_cnt].end_len= end_len;
445
+ ms_setting.value_distr[ms_setting.val_rng_cnt].value_prop=
446
+ proportion;
447
+ ms_setting.val_rng_cnt++;
448
+
449
+ if (ms_setting.val_rng_cnt >= ms_setting.total_val_rng_cnt)
450
+ {
451
+ val_distr= (ms_value_distr_t *)realloc(
452
+ ms_setting.value_distr,
453
+ (size_t)ms_setting.
454
+ total_val_rng_cnt * sizeof(ms_value_distr_t) * 2);
455
+ if (val_distr == NULL)
456
+ {
457
+ fprintf(stderr,
458
+ "Can't reallocate key distribution structure.\n");
459
+ exit(1);
460
+ }
461
+ ms_setting.value_distr= val_distr;
462
+ ms_setting.total_val_rng_cnt*= 2;
463
+ }
464
+ continue;
465
+ }
466
+ end_of_file= 1;
467
+ break;
468
+ }
469
+ break;
470
+
471
+ case CONF_CMD:
472
+ while (1)
473
+ {
474
+ if ((((nread= getline(&line, &read_len, f)) == 1)
475
+ || ! ms_read_is_data(line, nread)) && (nread != EOF)) /* bypass blank line */
476
+ continue;
477
+
478
+ if (nread != EOF)
479
+ {
480
+ if (sscanf(line, "%d %lf", &cmd_type, &proportion) != 2)
481
+ {
482
+ conf_type= ms_get_conf_type(line);
483
+ break;
484
+ }
485
+ if (cmd_type >= CMD_NULL)
486
+ {
487
+ continue;
488
+ }
489
+ ms_setting.cmd_distr[ms_setting.cmd_used_count].cmd_type=
490
+ cmd_type;
491
+ ms_setting.cmd_distr[ms_setting.cmd_used_count].cmd_prop=
492
+ proportion;
493
+ ms_setting.cmd_used_count++;
494
+ continue;
495
+ }
496
+ end_of_file= 1;
497
+ break;
498
+ }
499
+
500
+ case CONF_NULL:
501
+ while (1)
502
+ {
503
+ if ((((nread= getline(&line, &read_len, f)) == 1)
504
+ || ! ms_read_is_data(line, nread)) && (nread != EOF)) /* bypass blank line */
505
+ continue;
506
+
507
+ if (nread != EOF)
508
+ {
509
+ if ((conf_type= ms_get_conf_type(line)) != CONF_NULL)
510
+ {
511
+ break;
512
+ }
513
+ continue;
514
+ }
515
+ end_of_file= 1;
516
+ break;
517
+ }
518
+ break;
519
+
520
+ default:
521
+ assert(0);
522
+ break;
523
+ } /* switch */
524
+ }
525
+
526
+ fclose(f);
527
+
528
+ if (line != NULL)
529
+ {
530
+ free(line);
531
+ }
532
+ } /* ms_parse_cfg_file */
533
+
534
+
535
+ /* calculate the average size of key and value */
536
+ static void ms_calc_avg_size()
537
+ {
538
+ double avg_val_size= 0.0;
539
+ double avg_key_size= 0.0;
540
+ double val_pro= 0.0;
541
+ double key_pro= 0.0;
542
+ double averge_len= 0.0;
543
+ size_t start_len= 0;
544
+ size_t end_len= 0;
545
+
546
+ for (int j= 0; j < ms_setting.val_rng_cnt; j++)
547
+ {
548
+ val_pro= ms_setting.value_distr[j].value_prop;
549
+ start_len= ms_setting.value_distr[j].start_len;
550
+ end_len= ms_setting.value_distr[j].end_len;
551
+
552
+ averge_len= val_pro * ((double)(start_len + end_len)) / 2;
553
+ avg_val_size+= averge_len;
554
+ }
555
+
556
+ for (int j= 0; j < ms_setting.key_rng_cnt; j++)
557
+ {
558
+ key_pro= ms_setting.key_distr[j].key_prop;
559
+ start_len= ms_setting.key_distr[j].start_len;
560
+ end_len= ms_setting.key_distr[j].end_len;
561
+
562
+ averge_len= key_pro * ((double)(start_len + end_len)) / 2;
563
+ avg_key_size+= averge_len;
564
+ }
565
+
566
+ ms_setting.avg_val_size= (size_t)avg_val_size;
567
+ ms_setting.avg_key_size= (size_t)avg_key_size;
568
+ } /* ms_calc_avg_size */
569
+
570
+
571
+ /**
572
+ * used to shuffle key and value distribution array to ensure
573
+ * (key, value) pair with different set.
574
+ *
575
+ * @param distr, pointer of distribution structure array
576
+ * @param length, length of the array
577
+ *
578
+ * @return always return EXIT_SUCCESS
579
+ */
580
+ static int ms_shuffle_distr(ms_distr_t *distr, int length)
581
+ {
582
+ int i, j;
583
+ int tmp_offset;
584
+ size_t tmp_size;
585
+ int64_t rnd;
586
+
587
+ for (i= 0; i < length; i++)
588
+ {
589
+ rnd= random();
590
+ j= (int)(rnd % (length - i)) + i;
591
+
592
+ switch (rnd % 3)
593
+ {
594
+ case 0:
595
+ tmp_size= distr[j].key_size;
596
+ distr[j].key_size= distr[i].key_size;
597
+ distr[i].key_size= tmp_size;
598
+ break;
599
+
600
+ case 1:
601
+ tmp_offset= distr[j].key_offset;
602
+ distr[j].key_offset= distr[i].key_offset;
603
+ distr[i].key_offset= tmp_offset;
604
+ break;
605
+
606
+ case 2:
607
+ tmp_size= distr[j].value_size;
608
+ distr[j].value_size= distr[i].value_size;
609
+ distr[i].value_size= tmp_size;
610
+ break;
611
+
612
+ default:
613
+ break;
614
+ } /* switch */
615
+ }
616
+
617
+ return EXIT_SUCCESS;
618
+ } /* ms_shuffle_distr */
619
+
620
+
621
+ /**
622
+ * according to the key and value distribution, to build the
623
+ * (key, value) pair distribution. the (key, value) pair
624
+ * distribution array is global, each connection set or get
625
+ * object keeping this distribution, for the final result, we
626
+ * can reach the expected key and value distribution.
627
+ */
628
+ static void ms_build_distr()
629
+ {
630
+ int offset= 0;
631
+ int end= 0;
632
+ int key_cnt= 0;
633
+ int value_cnt= 0;
634
+ size_t average_len= 0;
635
+ size_t diff_len= 0;
636
+ size_t start_len= 0;
637
+ size_t end_len= 0;
638
+ int rnd= 0;
639
+ ms_distr_t *distr= NULL;
640
+ int units= (int)ms_setting.win_size / UNIT_ITEMS_COUNT;
641
+
642
+ /* calculate average value size and key size */
643
+ ms_calc_avg_size();
644
+
645
+ ms_setting.char_blk_size= RAND_CHAR_SIZE;
646
+ int key_scope_size=
647
+ (int)((ms_setting.char_blk_size - RESERVED_RAND_CHAR_SIZE)
648
+ / UNIT_ITEMS_COUNT);
649
+
650
+ ms_setting.distr= (ms_distr_t *)malloc(
651
+ sizeof(ms_distr_t) * ms_setting.win_size);
652
+ if (ms_setting.distr == NULL)
653
+ {
654
+ fprintf(stderr, "Can't allocate distribution array.");
655
+ exit(1);
656
+ }
657
+
658
+ /**
659
+ * character block is divided by how many different key
660
+ * size, each different key size has the same size character
661
+ * range.
662
+ */
663
+ for (int m= 0; m < units; m++)
664
+ {
665
+ for (int i= 0; i < UNIT_ITEMS_COUNT; i++)
666
+ {
667
+ ms_setting.distr[m * UNIT_ITEMS_COUNT + i].key_offset=
668
+ ADDR_ALIGN(key_scope_size * i);
669
+ }
670
+ }
671
+
672
+ /* initialize key size distribution */
673
+ for (int m= 0; m < units; m++)
674
+ {
675
+ for (int j= 0; j < ms_setting.key_rng_cnt; j++)
676
+ {
677
+ key_cnt= (int)(UNIT_ITEMS_COUNT * ms_setting.key_distr[j].key_prop);
678
+ start_len= ms_setting.key_distr[j].start_len;
679
+ end_len= ms_setting.key_distr[j].end_len;
680
+ if ((start_len < MIN_KEY_SIZE) || (end_len < MIN_KEY_SIZE))
681
+ {
682
+ fprintf(stderr, "key length must be greater than 16 bytes.\n");
683
+ exit(1);
684
+ }
685
+
686
+ if (! ms_setting.binary_prot
687
+ && ((start_len > MAX_KEY_SIZE) || (end_len > MAX_KEY_SIZE)))
688
+ {
689
+ fprintf(stderr, "key length must be less than 250 bytes.\n");
690
+ exit(1);
691
+ }
692
+
693
+ average_len= (start_len + end_len) / 2;
694
+ diff_len= (end_len - start_len) / 2;
695
+ for (int k= 0; k < key_cnt; k++)
696
+ {
697
+ if (offset >= (m + 1) * UNIT_ITEMS_COUNT)
698
+ {
699
+ break;
700
+ }
701
+ rnd= (int)random();
702
+ if (k % 2 == 0)
703
+ {
704
+ ms_setting.distr[offset].key_size=
705
+ (diff_len == 0) ? average_len :
706
+ average_len + (size_t)rnd
707
+ % diff_len;
708
+ }
709
+ else
710
+ {
711
+ ms_setting.distr[offset].key_size=
712
+ (diff_len == 0) ? average_len :
713
+ average_len - (size_t)rnd
714
+ % diff_len;
715
+ }
716
+ offset++;
717
+ }
718
+ }
719
+
720
+ if (offset < (m + 1) * UNIT_ITEMS_COUNT)
721
+ {
722
+ end= (m + 1) * UNIT_ITEMS_COUNT - offset;
723
+ for (int i= 0; i < end; i++)
724
+ {
725
+ ms_setting.distr[offset].key_size= ms_setting.avg_key_size;
726
+ offset++;
727
+ }
728
+ }
729
+ }
730
+ offset= 0;
731
+
732
+ /* initialize value distribution */
733
+ if (ms_setting.fixed_value_size != 0)
734
+ {
735
+ for (int i= 0; i < units * UNIT_ITEMS_COUNT; i++)
736
+ {
737
+ ms_setting.distr[i].value_size= ms_setting.fixed_value_size;
738
+ }
739
+ }
740
+ else
741
+ {
742
+ for (int m= 0; m < units; m++)
743
+ {
744
+ for (int j= 0; j < ms_setting.val_rng_cnt; j++)
745
+ {
746
+ value_cnt=
747
+ (int)(UNIT_ITEMS_COUNT * ms_setting.value_distr[j].value_prop);
748
+ start_len= ms_setting.value_distr[j].start_len;
749
+ end_len= ms_setting.value_distr[j].end_len;
750
+ if ((start_len <= 0) || (end_len <= 0))
751
+ {
752
+ fprintf(stderr, "value length must be greater than 0 bytes.\n");
753
+ exit(1);
754
+ }
755
+
756
+ if ((start_len > MAX_VALUE_SIZE) || (end_len > MAX_VALUE_SIZE))
757
+ {
758
+ fprintf(stderr, "key length must be less than or equal to 1M.\n");
759
+ exit(1);
760
+ }
761
+
762
+ average_len= (start_len + end_len) / 2;
763
+ diff_len= (end_len - start_len) / 2;
764
+ for (int k= 0; k < value_cnt; k++)
765
+ {
766
+ if (offset >= (m + 1) * UNIT_ITEMS_COUNT)
767
+ {
768
+ break;
769
+ }
770
+ rnd= (int)random();
771
+ if (k % 2 == 0)
772
+ {
773
+ ms_setting.distr[offset].value_size=
774
+ (diff_len == 0) ? average_len :
775
+ average_len
776
+ + (size_t)rnd % diff_len;
777
+ }
778
+ else
779
+ {
780
+ ms_setting.distr[offset].value_size=
781
+ (diff_len == 0) ? average_len :
782
+ average_len
783
+ - (size_t)rnd % diff_len;
784
+ }
785
+ offset++;
786
+ }
787
+ }
788
+
789
+ if (offset < (m + 1) * UNIT_ITEMS_COUNT)
790
+ {
791
+ end= (m + 1) * UNIT_ITEMS_COUNT - offset;
792
+ for (int i= 0; i < end; i++)
793
+ {
794
+ ms_setting.distr[offset++].value_size= ms_setting.avg_val_size;
795
+ }
796
+ }
797
+ }
798
+ }
799
+
800
+ /* shuffle distribution */
801
+ for (int i= 0; i < units; i++)
802
+ {
803
+ distr= &ms_setting.distr[i * UNIT_ITEMS_COUNT];
804
+ for (int j= 0; j < 4; j++)
805
+ {
806
+ ms_shuffle_distr(distr, UNIT_ITEMS_COUNT);
807
+ }
808
+ }
809
+ } /* ms_build_distr */
810
+
811
+
812
+ /**
813
+ * used to initialize the global character block. The character
814
+ * block is used to generate the suffix of the key and value. we
815
+ * only store a pointer in the character block for each key
816
+ * suffix or value string. It can save much memory to store key
817
+ * or value string.
818
+ */
819
+ static void ms_init_random_block()
820
+ {
821
+ char *ptr= NULL;
822
+
823
+ assert(ms_setting.char_blk_size > 0);
824
+
825
+ ms_setting.char_block= (char *)malloc(ms_setting.char_blk_size);
826
+ if (ms_setting.char_block == NULL)
827
+ {
828
+ fprintf(stderr, "Can't allocate global char block.");
829
+ exit(1);
830
+ }
831
+ ptr= ms_setting.char_block;
832
+
833
+ for (int i= 0; (size_t)i < ms_setting.char_blk_size; i++)
834
+ {
835
+ *(ptr++)= ALPHANUMBERICS[random() % CHAR_COUNT];
836
+ }
837
+ } /* ms_init_random_block */
838
+
839
+
840
+ /**
841
+ * after initialization, call this function to output the main
842
+ * configuration user specified.
843
+ */
844
+ static void ms_print_setting()
845
+ {
846
+ fprintf(stdout, "servers : %s\n", ms_setting.srv_str);
847
+ fprintf(stdout, "threads count: %d\n", ms_setting.nthreads);
848
+ fprintf(stdout, "concurrency: %d\n", ms_setting.nconns);
849
+ if (ms_setting.run_time > 0)
850
+ {
851
+ fprintf(stdout, "run time: %ds\n", ms_setting.run_time);
852
+ }
853
+ else
854
+ {
855
+ fprintf(stdout, "execute number: %" PRId64 "\n", ms_setting.exec_num);
856
+ }
857
+ fprintf(stdout, "windows size: %" PRId64 "k\n",
858
+ (int64_t)(ms_setting.win_size / 1024));
859
+ fprintf(stdout, "set proportion: set_prop=%.2f\n",
860
+ ms_setting.cmd_distr[CMD_SET].cmd_prop);
861
+ fprintf(stdout, "get proportion: get_prop=%.2f\n",
862
+ ms_setting.cmd_distr[CMD_GET].cmd_prop);
863
+ fflush(stdout);
864
+ } /* ms_print_setting */
865
+
866
+
867
+ /**
868
+ * previous part of slap mode initialization of setting structure
869
+ */
870
+ static void ms_setting_slapmode_init_pre()
871
+ {
872
+ ms_setting.exec_num= DEFAULT_EXE_NUM;
873
+ ms_setting.verify_percent= DEFAULT_VERIFY_RATE;
874
+ ms_setting.exp_ver_per= DEFAULT_VERIFY_RATE;
875
+ ms_setting.overwrite_percent= DEFAULT_OVERWRITE_RATE;
876
+ ms_setting.mult_key_num= DEFAULT_DIV;
877
+ ms_setting.fixed_value_size= 0;
878
+ ms_setting.win_size= DEFAULT_WINDOW_SIZE;
879
+ ms_setting.udp= false;
880
+ ms_setting.reconnect= false;
881
+ ms_setting.verbose= false;
882
+ ms_setting.facebook_test= false;
883
+ ms_setting.binary_prot= false;
884
+ ms_setting.stat_freq= 0;
885
+ ms_setting.srv_str= NULL;
886
+ ms_setting.cfg_file= NULL;
887
+ ms_setting.sock_per_conn= DEFAULT_SOCK_PER_CONN;
888
+ ms_setting.expected_tps= 0;
889
+ ms_setting.rep_write_srv= 0;
890
+ } /* ms_setting_slapmode_init_pre */
891
+
892
+
893
+ /**
894
+ * previous part of initialization of setting structure
895
+ */
896
+ void ms_setting_init_pre()
897
+ {
898
+ memset(&ms_setting, 0, sizeof(ms_setting));
899
+
900
+ /* common initialize */
901
+ ms_setting.ncpu= ms_get_cpu_count();
902
+ ms_setting.nthreads= DEFAULT_THREADS_NUM;
903
+ ms_setting.nconns= DEFAULT_CONNS_NUM;
904
+ ms_setting.run_time= DEFAULT_RUN_TIME;
905
+ ms_setting.total_srv_cnt= MCD_SRVS_NUM_INIT;
906
+ ms_setting.servers= (ms_mcd_server_t *)malloc(
907
+ (size_t)ms_setting.total_srv_cnt
908
+ * sizeof(ms_mcd_server_t));
909
+ if (ms_setting.servers == NULL)
910
+ {
911
+ fprintf(stderr, "Can't allocate servers structure.\n");
912
+ exit(1);
913
+ }
914
+
915
+ ms_setting_slapmode_init_pre();
916
+ } /* ms_setting_init_pre */
917
+
918
+
919
+ /**
920
+ * post part of slap mode initialization of setting structure
921
+ */
922
+ static void ms_setting_slapmode_init_post()
923
+ {
924
+ ms_setting.total_key_rng_cnt= KEY_RANGE_COUNT_INIT;
925
+ ms_setting.key_distr=
926
+ (ms_key_distr_t *)malloc((size_t)ms_setting.total_key_rng_cnt * sizeof(ms_key_distr_t));
927
+
928
+ if (ms_setting.key_distr == NULL)
929
+ {
930
+ fprintf(stderr, "Can't allocate key distribution structure.\n");
931
+ exit(1);
932
+ }
933
+
934
+ ms_setting.total_val_rng_cnt= VALUE_RANGE_COUNT_INIT;
935
+
936
+ ms_setting.value_distr=
937
+ (ms_value_distr_t *)malloc((size_t)ms_setting.total_val_rng_cnt * sizeof( ms_value_distr_t));
938
+
939
+ if (ms_setting.value_distr == NULL)
940
+ {
941
+ fprintf(stderr, "Can't allocate value distribution structure.\n");
942
+ exit(1);
943
+ }
944
+
945
+ ms_parse_cfg_file(ms_setting.cfg_file);
946
+
947
+ /* run time mode */
948
+ if ((ms_setting.exec_num == 0) && (ms_setting.run_time != 0))
949
+ {
950
+ ms_setting.exec_num= (int64_t)MAX_EXEC_NUM;
951
+ }
952
+ else
953
+ {
954
+ /* execute number mode */
955
+ ms_setting.run_time= 0;
956
+ }
957
+
958
+ if (ms_setting.rep_write_srv > 0)
959
+ {
960
+ /* for replication test, need enable reconnect feature */
961
+ ms_setting.reconnect= true;
962
+ }
963
+
964
+ if (ms_setting.facebook_test && (ms_setting.mult_key_num < 2))
965
+ {
966
+ fprintf(stderr, "facebook test must work with multi-get, "
967
+ "please specify multi-get key number "
968
+ "with '--division' option.\n");
969
+ exit(1);
970
+ }
971
+
972
+ if (ms_setting.facebook_test && ms_setting.udp)
973
+ {
974
+ fprintf(stderr, "facebook test couldn't work with UDP.\n");
975
+ exit(1);
976
+ }
977
+
978
+ if (ms_setting.udp && (ms_setting.sock_per_conn > 1))
979
+ {
980
+ fprintf(stderr, "UDP doesn't support multi-socks "
981
+ "in one connection structure.\n");
982
+ exit(1);
983
+ }
984
+
985
+ if ((ms_setting.rep_write_srv > 0) && (ms_setting.srv_cnt < 2))
986
+ {
987
+ fprintf(stderr, "Please specify 2 servers at least for replication\n");
988
+ exit(1);
989
+ }
990
+
991
+ if ((ms_setting.rep_write_srv > 0)
992
+ && (ms_setting.srv_cnt < ms_setting.rep_write_srv))
993
+ {
994
+ fprintf(stderr, "Servers to do replication writing "
995
+ "is larger than the total servers\n");
996
+ exit(1);
997
+ }
998
+
999
+ if (ms_setting.udp && (ms_setting.rep_write_srv > 0))
1000
+ {
1001
+ fprintf(stderr, "UDP doesn't support replication.\n");
1002
+ exit(1);
1003
+ }
1004
+
1005
+ if (ms_setting.facebook_test && (ms_setting.rep_write_srv > 0))
1006
+ {
1007
+ fprintf(stderr, "facebook test couldn't work with replication.\n");
1008
+ exit(1);
1009
+ }
1010
+
1011
+ ms_build_distr();
1012
+
1013
+ /* initialize global character block */
1014
+ ms_init_random_block();
1015
+ ms_print_setting();
1016
+ } /* ms_setting_slapmode_init_post */
1017
+
1018
+
1019
+ /**
1020
+ * post part of initialization of setting structure
1021
+ */
1022
+ void ms_setting_init_post()
1023
+ {
1024
+ ms_get_serverlist(ms_setting.srv_str);
1025
+ ms_setting_slapmode_init_post();
1026
+ }
1027
+
1028
+
1029
+ /**
1030
+ * clean up the global setting structure
1031
+ */
1032
+ void ms_setting_cleanup()
1033
+ {
1034
+ if (ms_setting.distr != NULL)
1035
+ {
1036
+ free(ms_setting.distr);
1037
+ }
1038
+
1039
+ if (ms_setting.char_block != NULL)
1040
+ {
1041
+ free(ms_setting.char_block);
1042
+ }
1043
+
1044
+ if (ms_setting.srv_str != NULL)
1045
+ {
1046
+ free(ms_setting.srv_str);
1047
+ }
1048
+
1049
+ if (ms_setting.cfg_file != NULL)
1050
+ {
1051
+ free(ms_setting.cfg_file);
1052
+ }
1053
+
1054
+ if (ms_setting.servers != NULL)
1055
+ {
1056
+ free(ms_setting.servers);
1057
+ }
1058
+
1059
+ if (ms_setting.key_distr != NULL)
1060
+ {
1061
+ free(ms_setting.key_distr);
1062
+ }
1063
+
1064
+ if (ms_setting.value_distr != NULL)
1065
+ {
1066
+ free(ms_setting.value_distr);
1067
+ }
1068
+ } /* ms_setting_cleanup */