Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Move to pandora build

Change-Id: I2abaad1ecc38ade465f0a65a772bbb9629c8ae0d
Reviewed-on: http://review.northscale.com/1551
Reviewed-by: Steve Yen <steve.yen@gmail.com>
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
  • Loading branch information...
commit 6fcace5dc1d657c5fd425a3fe3a3019ef15bb3f7 1 parent 641c208
@trondn trondn authored steveyen committed
Showing with 328 additions and 70,663 deletions.
  1. +5 −0 .gitignore
  2. +34 −55 Makefile.am
  3. +1 −1  agent.h
  4. +1 −2  agent_config.c
  5. +1 −2  agent_ping.c
  6. +2 −3 agent_stats.c
  7. +0 −5 assoc.c
  8. +1 −0  cache.h
  9. +93 −0 config_static.h
  10. +60 −338 configure.ac
  11. +1 −2  cproxy.c
  12. +1 −2  cproxy_config.c
  13. +1 −2  cproxy_front.c
  14. +1 −2  cproxy_multiget.c
  15. +1 −2  cproxy_protocol_a.c
  16. +1 −2  cproxy_protocol_a2a.c
  17. +1 −2  cproxy_protocol_a2b.c
  18. +1 −2  cproxy_protocol_b.c
  19. +1 −2  cproxy_protocol_b2b.c
  20. +1 −2  cproxy_stats.c
  21. +1 −0  daemon.c
  22. +0 −15 doc/Makefile.am
  23. +0 −226 doc/protocol-binary-range.xml
  24. +0 −1,467 doc/protocol-binary.xml
  25. +1 −7 items.c
  26. +0 −1  libconflate
  27. +0 −7 libmemcached-0.30/AUTHORS
  28. +0 −32 libmemcached-0.30/COPYING
  29. +0 −287 libmemcached-0.30/ChangeLog
  30. +0 −237 libmemcached-0.30/INSTALL
  31. +0 −36 libmemcached-0.30/Makefile.am
  32. +0 −680 libmemcached-0.30/Makefile.in
  33. +0 −1  libmemcached-0.30/NEWS
  34. +0 −33 libmemcached-0.30/README
  35. +0 −14 libmemcached-0.30/THANKS
  36. +0 −11 libmemcached-0.30/TODO
  37. +0 −7,520 libmemcached-0.30/aclocal.m4
  38. +0 −63 libmemcached-0.30/clients/Makefile.am
  39. +0 −625 libmemcached-0.30/clients/Makefile.in
  40. +0 −30 libmemcached-0.30/clients/client_options.h
  41. +0 −64 libmemcached-0.30/clients/execute.c
  42. +0 −5 libmemcached-0.30/clients/execute.h
  43. +0 −71 libmemcached-0.30/clients/generator.c
  44. +0 −20 libmemcached-0.30/clients/generator.h
  45. +0 −159 libmemcached-0.30/clients/memcat.c
  46. +0 −234 libmemcached-0.30/clients/memcp.c
  47. +0 −152 libmemcached-0.30/clients/memdump.c
  48. +0 −80 libmemcached-0.30/clients/memerror.c
  49. +0 −124 libmemcached-0.30/clients/memflush.c
  50. +0 −141 libmemcached-0.30/clients/memrm.c
  51. +0 −419 libmemcached-0.30/clients/memslap.c
  52. +0 −327 libmemcached-0.30/clients/memstat.c
  53. +0 −112 libmemcached-0.30/clients/utilities.c
  54. +0 −30 libmemcached-0.30/clients/utilities.h
  55. +0 −1,526 libmemcached-0.30/config/config.guess
  56. +0 −1,658 libmemcached-0.30/config/config.sub
  57. +0 −589 libmemcached-0.30/config/depcomp
  58. +0 −519 libmemcached-0.30/config/install-sh
  59. +0 −6,956 libmemcached-0.30/config/ltmain.sh
  60. +0 −367 libmemcached-0.30/config/missing
  61. +0 −24,639 libmemcached-0.30/configure
  62. +0 −167 libmemcached-0.30/configure.ac
  63. +0 −376 libmemcached-0.30/docs/Makefile.am
  64. +0 −790 libmemcached-0.30/docs/Makefile.in
  65. +0 −127 libmemcached-0.30/docs/libmemcached.pod
  66. +0 −115 libmemcached-0.30/docs/libmemcached_examples.pod
  67. +0 −40 libmemcached-0.30/docs/libmemcachedutil.pod
  68. +0 −52 libmemcached-0.30/docs/memcached_analyze.pod
  69. +0 −97 libmemcached-0.30/docs/memcached_auto.pod
  70. +0 −224 libmemcached-0.30/docs/memcached_behavior.pod
  71. +0 −133 libmemcached-0.30/docs/memcached_callback.pod
  72. +0 −61 libmemcached-0.30/docs/memcached_create.pod
  73. +0 −54 libmemcached-0.30/docs/memcached_delete.pod
  74. +0 −53 libmemcached-0.30/docs/memcached_dump.pod
  75. +0 −46 libmemcached-0.30/docs/memcached_flush.pod
  76. +0 −42 libmemcached-0.30/docs/memcached_flush_buffers.pod
  77. +0 −57 libmemcached-0.30/docs/memcached_generate_hash_value.pod
  78. +0 −133 libmemcached-0.30/docs/memcached_get.pod
  79. +0 −77 libmemcached-0.30/docs/memcached_pool.pod
  80. +0 −47 libmemcached-0.30/docs/memcached_quit.pod
  81. +0 −65 libmemcached-0.30/docs/memcached_server_st.pod
  82. +0 −102 libmemcached-0.30/docs/memcached_servers.pod
  83. +0 −187 libmemcached-0.30/docs/memcached_set.pod
  84. +0 −82 libmemcached-0.30/docs/memcached_stats.pod
  85. +0 −46 libmemcached-0.30/docs/memcached_strerror.pod
  86. +0 −41 libmemcached-0.30/docs/memcached_verbosity.pod
  87. +0 −56 libmemcached-0.30/docs/memcached_version.pod
  88. +0 −37 libmemcached-0.30/docs/memcat.pod
  89. +0 −40 libmemcached-0.30/docs/memcp.pod
  90. +0 −31 libmemcached-0.30/docs/memdump.pod
  91. +0 −30 libmemcached-0.30/docs/memerror.pod
  92. +0 −35 libmemcached-0.30/docs/memflush.pod
  93. +0 −34 libmemcached-0.30/docs/memrm.pod
  94. +0 −33 libmemcached-0.30/docs/memslap.pod
  95. +0 −35 libmemcached-0.30/docs/memstat.pod
  96. +0 −96 libmemcached-0.30/libmemcached/Makefile.am
  97. +0 −31 libmemcached-0.30/libmemcached/byteorder.c
  98. +0 −149 libmemcached-0.30/libmemcached/common.h
  99. +0 −87 libmemcached-0.30/libmemcached/crc.c
  100. +0 −68 libmemcached-0.30/libmemcached/hsieh_hash.c
  101. +0 −210 libmemcached-0.30/libmemcached/jenkins_hash.c
  102. +0 −1  libmemcached-0.30/libmemcached/libmemcached.ver
  103. +0 −123 libmemcached-0.30/libmemcached/libmemcached_config.h.in
  104. +0 −24 libmemcached-0.30/libmemcached/libmemcached_probes.d
  105. +0 −78 libmemcached-0.30/libmemcached/libmemcached_probes.h
  106. +0 −354 libmemcached-0.30/libmemcached/md5.c
  107. +0 −144 libmemcached-0.30/libmemcached/memcached.c
  108. +0 −239 libmemcached-0.30/libmemcached/memcached.h
  109. +0 −175 libmemcached-0.30/libmemcached/memcached.hh
  110. +0 −7 libmemcached-0.30/libmemcached/memcached/README.txt
  111. +0 −361 libmemcached-0.30/libmemcached/memcached/protocol_binary.h
  112. +0 −97 libmemcached-0.30/libmemcached/memcached_analyze.c
  113. +0 −199 libmemcached-0.30/libmemcached/memcached_auto.c
  114. +0 −284 libmemcached-0.30/libmemcached/memcached_behavior.c
  115. +0 −171 libmemcached-0.30/libmemcached/memcached_callback.c
  116. +0 −353 libmemcached-0.30/libmemcached/memcached_connect.c
  117. +0 −147 libmemcached-0.30/libmemcached/memcached_constants.h
  118. +0 −130 libmemcached-0.30/libmemcached/memcached_delete.c
  119. +0 −34 libmemcached-0.30/libmemcached/memcached_do.c
  120. +0 −79 libmemcached-0.30/libmemcached/memcached_dump.c
  121. +0 −102 libmemcached-0.30/libmemcached/memcached_fetch.c
  122. +0 −89 libmemcached-0.30/libmemcached/memcached_flush.c
  123. +0 −22 libmemcached-0.30/libmemcached/memcached_flush_buffers.c
  124. +0 −359 libmemcached-0.30/libmemcached/memcached_get.c
  125. +0 −56 libmemcached-0.30/libmemcached/memcached_get.h
  126. +0 −222 libmemcached-0.30/libmemcached/memcached_hash.c
  127. +0 −472 libmemcached-0.30/libmemcached/memcached_hosts.c
  128. +0 −547 libmemcached-0.30/libmemcached/memcached_io.c
  129. +0 −49 libmemcached-0.30/libmemcached/memcached_io.h
  130. +0 −28 libmemcached-0.30/libmemcached/memcached_key.c
  131. +0 −75 libmemcached-0.30/libmemcached/memcached_parse.c
  132. +0 −33 libmemcached-0.30/libmemcached/memcached_pool.h
  133. +0 −76 libmemcached-0.30/libmemcached/memcached_purge.c
  134. +0 −68 libmemcached-0.30/libmemcached/memcached_quit.c
  135. +0 −482 libmemcached-0.30/libmemcached/memcached_response.c
  136. +0 −60 libmemcached-0.30/libmemcached/memcached_result.c
  137. +0 −53 libmemcached-0.30/libmemcached/memcached_result.h
  138. +0 −138 libmemcached-0.30/libmemcached/memcached_server.c
  139. +0 −75 libmemcached-0.30/libmemcached/memcached_server.h
  140. +0 −461 libmemcached-0.30/libmemcached/memcached_stats.c
  141. +0 −473 libmemcached-0.30/libmemcached/memcached_storage.c
  142. +0 −93 libmemcached-0.30/libmemcached/memcached_storage.h
  143. +0 −84 libmemcached-0.30/libmemcached/memcached_strerror.c
  144. +0 −161 libmemcached-0.30/libmemcached/memcached_string.c
  145. +0 −46 libmemcached-0.30/libmemcached/memcached_string.h
  146. +0 −43 libmemcached-0.30/libmemcached/memcached_types.h
  147. +0 −23 libmemcached-0.30/libmemcached/memcached_util.h
  148. +0 −36 libmemcached-0.30/libmemcached/memcached_verbosity.c
  149. +0 −112 libmemcached-0.30/libmemcached/memcached_version.c
  150. +0 −45 libmemcached-0.30/libmemcached/memcached_watchpoint.h
  151. +0 −75 libmemcached-0.30/libmemcached/murmur_hash.c
  152. +0 −11 libmemcached-0.30/libmemcachedutil/Makefile.am
  153. +0 −502 libmemcached-0.30/libmemcachedutil/Makefile.in
  154. +0 −1  libmemcached-0.30/libmemcachedutil/libmemcachedutil.ver
  155. +0 −168 libmemcached-0.30/libmemcachedutil/memcached_pool.c
  156. +0 −31 libmemcached-0.30/m4/64bit.m4
  157. +0 −41 libmemcached-0.30/m4/byteorder.m4
  158. +0 −20 libmemcached-0.30/m4/debug.m4
  159. +0 −37 libmemcached-0.30/m4/dtrace.m4
  160. +0 −94 libmemcached-0.30/m4/extensions.m4
  161. +0 −22 libmemcached-0.30/m4/hsieh.m4
  162. +0 −32 libmemcached-0.30/m4/memcached.m4
  163. +0 −5 libmemcached-0.30/m4/pod2man.m4
  164. +0 −20 libmemcached-0.30/m4/protocol_binary.m4
  165. +0 −55 libmemcached-0.30/m4/setsockopt.m4
  166. +0 −20 libmemcached-0.30/m4/util.m4
  167. +0 −4 libmemcached-0.30/support/Makefile.am
  168. +0 −395 libmemcached-0.30/support/Makefile.in
  169. +0 −105 libmemcached-0.30/support/libmemcached-fc.spec.in
  170. +0 −10 libmemcached-0.30/support/libmemcached.pc.in
  171. +0 −105 libmemcached-0.30/support/libmemcached.spec.in
  172. +0 −5 libmemcached-0.30/support/set_benchmark.sh
  173. +0 −97 libmemcached-0.30/tests/Makefile.am
  174. +0 −643 libmemcached-0.30/tests/Makefile.in
  175. +0 −245 libmemcached-0.30/tests/atomsmasher.c
  176. +0 −4,346 libmemcached-0.30/tests/function.c
  177. +0 −108 libmemcached-0.30/tests/ketama_test_cases.h
  178. +0 −673 libmemcached-0.30/tests/output.res
  179. +0 −46 libmemcached-0.30/tests/output2.res
  180. +0 −139 libmemcached-0.30/tests/plus.cpp
  181. +0 −19 libmemcached-0.30/tests/r/memcat.res
  182. +0 −27 libmemcached-0.30/tests/r/memcp.res
  183. +0 −19 libmemcached-0.30/tests/r/memrm.res
  184. +0 −33 libmemcached-0.30/tests/r/memslap.res
  185. +0 −33 libmemcached-0.30/tests/r/memstat.res
  186. +0 −118 libmemcached-0.30/tests/server.c
  187. +0 −25 libmemcached-0.30/tests/server.h
  188. +0 −16 libmemcached-0.30/tests/start.c
  189. +0 −4 libmemcached-0.30/tests/t/memcat.test
  190. +0 −3  libmemcached-0.30/tests/t/memcp.test
  191. +0 −3  libmemcached-0.30/tests/t/memrm.test
  192. +0 −5 libmemcached-0.30/tests/t/memslap.test
  193. +0 −3  libmemcached-0.30/tests/t/memstat.test
  194. +0 −138 libmemcached-0.30/tests/test.c
  195. +0 −46 libmemcached-0.30/tests/test.h
  196. +0 −76 libmemcached-0.30/tests/udp.c
  197. +28 −10 log.c
  198. +40 −0 m4/pandora_have_libconflate.m4
  199. +42 −0 m4/pandora_have_libhashkit.m4
  200. +1 −2  matcher.c
  201. +0 −6 mcs.c
  202. +0 −9 memcached.c
  203. +1 −4 memcached.h
  204. +0 −295 memcached_dtrace.d
  205. +1 −0  sizes.c
  206. +0 −6 slabs.c
  207. +1 −0  solaris_priv.c
  208. +1 −0  stdin_check.c
  209. +1 −26 testapp.c
  210. +1 −0  util.c
  211. +1 −2  work.c
  212. +0 −1  work.h
View
5 .gitignore
@@ -67,3 +67,8 @@ moxi_*.tar.gz
stamp-h1
stamp-h2
tags
+m4/libtool.m4
+m4/ltoptions.m4
+m4/ltsugar.m4
+m4/ltversion.m4
+m4/lt~obsolete.m4
View
89 Makefile.am
@@ -1,12 +1,11 @@
AUTOMAKE_OPTIONS = foreign
+ACLOCAL_AMFLAGS = -I m4 --force
bin_PROGRAMS = moxi
-noinst_PROGRAMS = moxi-debug sizes testapp timedrun
-
-## INCLUDES is apparently not previously set, if you set it
-## change this
-INCLUDES = $(CONFLATE_CFLAGS)
-LIBS += $(CONFLATE_LIBS)
+noinst_PROGRAMS =
+if BUILD_TESTAPPS
+noinst_PROGRAMS += sizes testapp timedrun
+endif
BUILT_SOURCES =
@@ -18,7 +17,7 @@ moxi_SOURCES = memcached.c memcached.h \
slabs.c slabs.h \
items.c items.h \
assoc.c assoc.h \
- thread.c daemon.c \
+ thread.c \
stats.c stats.h \
util.c util.h \
trace.h cache.h \
@@ -41,10 +40,14 @@ moxi_SOURCES = memcached.c memcached.h \
log.c log.h \
cJSON.c cJSON.h
+if BUILD_DAEMON
+moxi_SOURCES += daemon.c
+endif
+
timedrun_SOURCES = timedrun.c
TESTS = check_util check_moxi check_work
-if BUILD_WITH_CONFLATE
+if HAVE_LIBCONFLATE
TESTS += check_moxi_agent
endif
@@ -52,7 +55,7 @@ check_PROGRAMS = check_util \
check_moxi \
check_work
-if BUILD_WITH_CONFLATE
+if HAVE_LIBCONFLATE
check_PROGRAMS += check_moxi_agent
endif
@@ -68,7 +71,7 @@ moxi_SOURCES += cache.c
testapp_SOURCES += cache.c
endif
-if BUILD_WITH_CONFLATE
+if HAVE_LIBCONFLATE
moxi_SOURCES += agent.h agent_config.c agent_ping.c agent_stats.c
endif
@@ -76,52 +79,28 @@ if BUILD_SOLARIS_PRIVS
moxi_SOURCES += solaris_priv.c
endif
-moxi_debug_SOURCES = $(moxi_SOURCES)
-moxi_debug_CPPFLAGS = -DCONFLATE_DB_PATH=\"$(CONFLATE_DB_PATH)\"
-moxi_CPPFLAGS = -DNDEBUG $(moxi_debug_CPPFLAGS)
-moxi_debug_LDADD = @PROFILER_LDFLAGS@
-moxi_debug_CFLAGS = @PROFILER_FLAGS@
-
+moxi_CPPFLAGS = -DNDEBUG -DCONFLATE_DB_PATH=\"$(CONFLATE_DB_PATH)\"
moxi_LDADD =
+moxi_LDFLAGS = $(LTLIBEVENT) $(LTLIBCONFLATE) $(LTLIBHASHKIT)
moxi_DEPENDENCIES =
-moxi_debug_DEPENDENCIES =
-
-CLEANFILES=
-
-if BUILD_DTRACE
-BUILT_SOURCES += memcached_dtrace.h
-CLEANFILES += memcached_dtrace.h
-endif
-if DTRACE_INSTRUMENT_OBJ
-moxi_LDADD += memcached_dtrace.o
-moxi_DEPENDENCIES += memcached_dtrace.o
-moxi_debug_LDADD += memcached_debug_dtrace.o
-moxi_debug_DEPENDENCIES += memcached_debug_dtrace.o
-CLEANFILES += memcached_dtrace.o memcached_debug_dtrace.o
+if MOXI_USE_VBUCKET
+moxi_LDFLAGS += $(LTLIBVBUCKET)
+else
+moxi_LDFLAGS += $(LTLIBMEMCACHED)
endif
-memcached_dtrace.h: memcached_dtrace.d
- ${DTRACE} -h -s memcached_dtrace.d
- sed -e 's,void \*,const void \*,g' memcached_dtrace.h | \
- sed -e 's,char \*,const char \*,g' | tr '\t' ' ' > mmc_dtrace.tmp
- mv mmc_dtrace.tmp memcached_dtrace.h
-
-memcached_dtrace.o: $(moxi_OBJECTS)
- $(DTRACE) $(DTRACEFLAGS) -G -o memcached_dtrace.o -s ${srcdir}/memcached_dtrace.d $(moxi_OBJECTS)
-
-memcached_debug_dtrace.o: $(moxi_debug_OBJECTS)
- $(DTRACE) $(DTRACEFLAGS) -G -o memcached_debug_dtrace.o -s ${srcdir}/memcached_dtrace.d $(moxi_debug_OBJECTS)
+CLEANFILES=
SUBDIRS = doc $(MAYBE_LIBCONFLATE)
DIST_SUBDIRS = doc $(MAYBE_LIBCONFLATE)
DIST_DIRS = scripts
-EXTRA_DIST = doc scripts TODO t memcached_dtrace.d m4/version.m4 protocol_binary.h patches debian
+EXTRA_DIST = doc scripts TODO t m4/version.m4 protocol_binary.h patches debian
MOSTLYCLEANFILES = *.gcov *.gcno *.gcda *.tcov
-memcached-debug: moxi-debug
- cp moxi-debug memcached-debug
+memcached-debug: moxi
+ cp moxi memcached-debug
test: memcached-debug sizes testapp
$(srcdir)/sizes
@@ -164,22 +143,22 @@ dist-hook:
install-data-hook:
$(mkdir_p) $(DESTDIR)$(CONFLATE_DB_PATH)
-check_work_SOURCES = check_work.c $(moxi_debug_SOURCES)
-check_work_CFLAGS = @CHECK_CFLAGS@ $(moxi_debug_CPPFLAGS) -DMAIN_CHECK
-check_work_LDADD = @CHECK_LIBS@ $(moxi_debug_LDADD)
+check_work_SOURCES = check_work.c $(moxi_SOURCES)
+check_work_CFLAGS = @CHECK_CFLAGS@ $(moxi_CPPFLAGS) -DMAIN_CHECK
+check_work_LDADD = @CHECK_LIBS@ $(moxi_LDADD)
-check_moxi_SOURCES = check_moxi.c $(moxi_debug_SOURCES)
-check_moxi_CFLAGS = @CHECK_CFLAGS@ $(moxi_debug_CPPFLAGS) -DMAIN_CHECK
-check_moxi_LDADD = @CHECK_LIBS@ $(moxi_debug_LDADD)
+check_moxi_SOURCES = check_moxi.c $(moxi_SOURCES)
+check_moxi_CFLAGS = @CHECK_CFLAGS@ $(moxi_CPPFLAGS) -DMAIN_CHECK
+check_moxi_LDADD = @CHECK_LIBS@ $(moxi_LDADD)
-if BUILD_WITH_CONFLATE
-check_moxi_agent_SOURCES = check_moxi_agent.c redirects.c $(moxi_debug_SOURCES)
-check_moxi_agent_CFLAGS = @CHECK_CFLAGS@ $(moxi_debug_CPPFLAGS) -DMAIN_CHECK -DREDIRECTS_FOR_MOCKS
-check_moxi_agent_LDADD = @CHECK_LIBS@ $(moxi_debug_LDADD)
+if HAVE_LIBCONFLATE
+check_moxi_agent_SOURCES = check_moxi_agent.c redirects.c $(moxi_SOURCES)
+check_moxi_agent_CFLAGS = @CHECK_CFLAGS@ $(moxi_CPPFLAGS) -DMAIN_CHECK -DREDIRECTS_FOR_MOCKS
+check_moxi_agent_LDADD = @CHECK_LIBS@ $(moxi_LDADD)
endif
check-syntax:
- $(COMPILE) $(moxi_debug_CPPFLAGS) -o /dev/null -S ${CHK_SOURCES}
+ $(COMPILE) $(moxi_CPPFLAGS) -o /dev/null -S ${CHK_SOURCES}
fc_rpm_inner:
-rm $(rpmtop)/SRPMS/moxi-$(VERSION)*.rpm
View
2  agent.h
@@ -3,7 +3,7 @@
#ifndef AGENT_H
#define AGENT_H
-#include <conflate.h>
+#include <libconflate/conflate.h>
#ifdef REDIRECTS_FOR_MOCKS
#include "redirects.h"
#endif
View
3  agent_config.c
@@ -1,10 +1,9 @@
/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-
+#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
-#include <sysexits.h>
#include <pthread.h>
#include <assert.h>
#include "memcached.h"
View
3  agent_ping.c
@@ -1,10 +1,9 @@
/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-
+#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
-#include <sysexits.h>
#include <pthread.h>
#include <assert.h>
#include "memcached.h"
View
5 agent_stats.c
@@ -1,16 +1,15 @@
/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-
+#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
-#include <sysexits.h>
#include <pthread.h>
#include <assert.h>
#include <math.h>
+#include <libconflate/conflate.h>
#include "memcached.h"
-#include "conflate.h"
#include "cproxy.h"
#include "work.h"
#include "agent.h"
View
5 assoc.c
@@ -13,11 +13,6 @@
#include "memcached.h"
#include <sys/stat.h>
-#include <sys/socket.h>
-#include <sys/signal.h>
-#include <sys/resource.h>
-#include <fcntl.h>
-#include <netinet/in.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
View
1  cache.h
@@ -1,6 +1,7 @@
/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
#ifndef CACHE_H
#define CACHE_H
+#include "config.h"
#include <pthread.h>
#ifdef HAVE_UMEM_H
View
93 config_static.h
@@ -0,0 +1,93 @@
+/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/*
+ * Copyright 2010 NorthScale, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef CONFIG_STATIC_H
+#define CONFIG_STATIC_H 1
+
+// The intention of this file is to avoid cluttering the code with #ifdefs
+
+#ifdef WIN32
+// HAVE_CONFIG_H is causing problems with pthreads.h on in32
+#undef HAVE_CONFIG_H
+
+#define _WIN32_WINNT 0x0501
+#include <winsock2.h>
+#include <ws2tcpip.h>
+
+struct iovec {
+ size_t iov_len;
+ void* iov_base;
+};
+
+#include "win32/win32.h"
+
+#define EX_USAGE EXIT_FAILURE
+#define EX_OSERR EXIT_FAILURE
+
+#else
+#define initialize_sockets()
+#endif
+
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+
+#ifdef HAVE_NETDB_H
+#include <netdb.h>
+#endif
+
+#ifdef HAVE_ARPA_INET_H
+#include <arpa/inet.h>
+#endif
+
+#ifdef HAVE_PWD_H
+#include <pwd.h>
+#endif
+
+#ifdef HAVE_SYS_MMAN_H
+#include <sys/mman.h>
+#endif
+
+#ifdef HAVE_NETINET_TCP_H
+#include <netinet/tcp.h>
+#endif
+
+#ifdef HAVE_SYSEXITS_H
+#include <sysexits.h>
+#endif
+
+#ifdef HAVE_SYS_UIO_H
+#include <sys/uio.h>
+#endif
+
+#ifdef HAVE_SYS_UN_H
+#include <sys/un.h>
+#endif
+
+#ifdef HAVE_SYS_RESOURCE_H
+#include <sys/resource.h>
+#endif
+
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+
+#ifdef HAVE_SYSLOG_H
+#include <syslog.h>
+#endif
+
+
+#endif
View
398 configure.ac
@@ -1,317 +1,62 @@
AC_PREREQ(2.52)
m4_include([m4/version.m4])
AC_INIT(moxi, VERSION_NUMBER, moxi@googlegroups.com)
-AC_CANONICAL_SYSTEM
-AC_CONFIG_SRCDIR(memcached.c)
-AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
-AM_CONFIG_HEADER(config.h)
+AC_CONFIG_SRCDIR([memcached.c])
+AC_CONFIG_AUX_DIR(config)
+AM_CONFIG_HEADER([config.h])
AC_CONFIG_MACRO_DIR([m4])
+AC_DISABLE_STATIC
-AC_PROG_CC
-AC_PROG_CXX
-AC_DISABLE_SHARED
-AM_PROG_LIBTOOL
-
-#shared library versioning
-MEMCACHED_LIBRARY_VERSION=2:0:0
-# | | |
-# +------+ | +---+
-# | | |
-# current:revision:age
-# | | |
-# | | +- increment if interfaces have been added
-# | | set to zero if interfaces have been removed or changed
-# | +- increment if source code has changed
-# | set to zero if current is incremented
-# +- increment if interfaces have been added, removed or changed
-AC_SUBST(MEMCACHED_LIBRARY_VERSION)
-
-dnl **********************************************************************
-dnl DETECT_ICC ([ACTION-IF-YES], [ACTION-IF-NO])
-dnl
-dnl check if this is the Intel ICC compiler, and if so run the ACTION-IF-YES
-dnl sets the $ICC variable to "yes" or "no"
-dnl **********************************************************************
-AC_DEFUN([DETECT_ICC],
-[
- ICC="no"
- AC_MSG_CHECKING([for icc in use])
- if test "$GCC" = "yes"; then
- dnl check if this is icc acting as gcc in disguise
- AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER],
- AC_MSG_RESULT([no])
- [$2],
- AC_MSG_RESULT([yes])
- [$1]
- ICC="yes")
- else
- AC_MSG_RESULT([no])
- [$2]
- fi
-])
-
-DETECT_ICC([], [])
-
-dnl **********************************************************************
-dnl DETECT_SUNCC ([ACTION-IF-YES], [ACTION-IF-NO])
-dnl
-dnl check if this is the Sun Studio compiler, and if so run the ACTION-IF-YES
-dnl sets the $SUNCC variable to "yes" or "no"
-dnl **********************************************************************
-AC_DEFUN([DETECT_SUNCC],
-[
- SUNCC="no"
- AC_MSG_CHECKING([for Sun cc in use])
- AC_RUN_IFELSE(
- [AC_LANG_PROGRAM([], [dnl
-#ifdef __SUNPRO_C
- return 0;
-#else
- return 1;
-#endif
- ])
- ],[
- AC_MSG_RESULT([yes])
- [$1]
- SUNCC="yes"
- ], [
- AC_MSG_RESULT([no])
- [$2]
- ])
-])
-
-DETECT_SUNCC([CFLAGS="-mt $CFLAGS"], [])
+PANDORA_CANONICAL_TARGET(less-warnings, warnings-always-on, require-cxx,
+ force-gcc42)
AC_PROG_CC_C99
-
AC_PROG_INSTALL
-AC_ARG_ENABLE(dtrace,
- [AS_HELP_STRING([--enable-dtrace],[Enable dtrace probes])])
-if test "x$enable_dtrace" = "xyes"; then
- AC_PATH_PROG([DTRACE], [dtrace], "no", [/usr/sbin:$PATH])
- if test "x$DTRACE" != "xno"; then
- AC_DEFINE([ENABLE_DTRACE],1,[Set to nonzero if you want to include DTRACE])
- build_dtrace=yes
- # DTrace on MacOSX does not use -G option
- $DTRACE -G -o conftest.$$ -s memcached_dtrace.d 2>/dev/zero
- if test $? -eq 0
- then
- dtrace_instrument_obj=yes
- rm conftest.$$
- fi
-
- if test "`which tr`" = "/usr/ucb/tr"; then
- AC_MSG_ERROR([Please remove /usr/ucb from your path. See man standards for more info])
- fi
- else
- AC_MSG_ERROR([Need dtrace binary and OS support.])
- fi
-fi
-
-AM_CONDITIONAL([BUILD_DTRACE],[test "$build_dtrace" = "yes"])
-AM_CONDITIONAL([DTRACE_INSTRUMENT_OBJ],[test "$dtrace_instrument_obj" = "yes"])
+PANDORA_REQUIRE_LIBEVENT
+PANDORA_REQUIRE_PTHREAD
+PANDORA_REQUIRE_LIBMEMCACHED
+PANDORA_REQUIRE_LIBHASHKIT
+PANDORA_HAVE_LIBCONFLATE
+AS_IF([test "x${ac_cv_libconflate}" = "xyes"], [
+ AC_DEFINE([HAVE_CONFLATE_H], 1,
+ [Defined if building with libconflate XMPP management])])
+PANDORA_HAVE_LIBVBUCKET
-AC_SUBST(DTRACE)
-AC_SUBST(DTRACEFLAGS)
+AC_SUBST(PROFILER_FLAGS)
AC_SUBST(PROFILER_LDFLAGS)
-
AC_HEADER_TIME
-
+AC_HEADER_STDBOOL
AC_SUBST(NO_STRICT_ALIASING)
-AC_ARG_ENABLE(coverage,
- [AS_HELP_STRING([--disable-coverage],[Disable code coverage])])
-
-if test "x$enable_coverage" != "xno"; then
- if test "$ICC" = "yes"
- then
- dnl ICC trying to be gcc, but not well
- CFLAGS="$CFLAGS -pthread -D_GNU_SOURCE -w1"
- elif test "$GCC" = "yes"
- then
- CFLAGS="$CFLAGS -pthread"
- AC_PATH_PROG([PROFILER], [gcov], "no", [$PATH])
- if test "x$PROFILER" != "xno"; then
- PROFILER_FLAGS="-fprofile-arcs -ftest-coverage"
- PROFILER_LDFLAGS="-lgcov"
- fi
- elif test "$SUNCC" = "yes"
- then
- AC_PATH_PROG([PROFILER], [tcov], "no", [$PATH])
- if test "x$PROFILER" != "xno"; then
- PROFILER_FLAGS=-xprofile=tcov
- fi
- fi
-fi
-
-AC_SUBST(PROFILER_FLAGS)
-
-AC_ARG_ENABLE(64bit,
- [AS_HELP_STRING([--enable-64bit],[build 64bit version])])
-
-if test "x$enable_64bit" = "xyes"
-then
- org_cflags=$CFLAGS
- CFLAGS=-m64
- AC_RUN_IFELSE(
- [AC_LANG_PROGRAM([], [dnl
-return sizeof(void*) == 8 ? 0 : 1;
- ])
- ],[
- CFLAGS="-m64 $org_cflags"
- ],[
- AC_MSG_ERROR([Don't know how to build a 64-bit object.])
- ])
-fi
-
-PKG_PROG_PKG_CONFIG
-
-AC_ARG_WITH(libconflate, [AS_HELP_STRING([--with-libconflate], [build with libconflate management @<:@default=check@:>@])],
- [], [with_libconflate=check])
-
-CONFLATE_CFLAGS=
-CONFLATE_LIBS=
-
-AC_SUBST(CONFLATE_CFLAGS)
-AC_SUBST(CONFLATE_LIBS)
-
-if test "x$with_libconflate" == xno; then
- echo "libconflate support is manually disabled"
-elif test "x$with_libconflate" = xbundled; then
- conflate_pkg_not_found=yes
-elif test "x$with_libconflate" = xhave; then
- BUILD_WITH_CONFLATE=yes
- AC_DEFINE([HAVE_CONFLATE_H], 1,
- [Defined if building with libconflate management])
-else
- PKG_CHECK_MODULES([CONFLATE], [libconflate], [
- BUILD_WITH_CONFLATE=yes
- AC_DEFINE([HAVE_CONFLATE_H], 1,
- [Defined if building with libconflate management])
- ], [
- conflate_pkg_not_found=yes
- ])
-fi
-
-if test "x$conflate_pkg_not_found" = "xyes"; then
- if test -f "$srcdir/libconflate/configure"; then
- if test "x$with_libconflate" = xbundled; then
- AC_MSG_NOTICE([forced use of bundled libconflate])
- else
- AC_MSG_NOTICE([will use bundled libconflate])
- fi
- AC_CONFIG_SUBDIRS([libconflate])
- CONFLATE_LIBS="-Llibconflate -lconflate"
- CONFLATE_CFLAGS="-Ilibconflate"
- BUILD_WITH_CONFLATE=yes
- AC_DEFINE([HAVE_CONFLATE_H], 1,
- [Defined if building with libconflate management])
- AC_SUBST([MAYBE_LIBCONFLATE], [libconflate])
- else
- if test "x$with_libconflate" = xbundled; then
- AC_MSG_FAILURE([build with bundled libconflate is requested, but libconflate/configure is missing])
- fi
- if test "x$with_libconflate" != xcheck; then
- AC_MSG_FAILURE([--with-libconflate was given, but pkg-config package for libconflate is missing])
- fi
- BUILD_WITH_CONFLATE=no
- AC_MSG_NOTICE([support for libconflate management will be disabled])
- fi
-fi
-
-AM_CONDITIONAL([BUILD_WITH_CONFLATE], [test "x$BUILD_WITH_CONFLATE" = xyes])
-
-trylibeventdir=""
-AC_ARG_WITH(libevent,
- [ --with-libevent=PATH Specify path to libevent installation ],
- [
- if test "x$withval" != "xno" ; then
- trylibeventdir=$withval
- fi
- ]
-)
-
-dnl ------------------------------------------------------
-dnl libevent detection. swiped from Tor. modified a bit.
-
-LIBEVENT_URL=http://www.monkey.org/~provos/libevent/
-
-AC_CACHE_CHECK([for libevent directory], ac_cv_libevent_dir, [
- saved_LIBS="$LIBS"
- saved_LDFLAGS="$LDFLAGS"
- saved_CPPFLAGS="$CPPFLAGS"
- le_found=no
- for ledir in $trylibeventdir "" $prefix /usr/local ; do
- LDFLAGS="$saved_LDFLAGS"
- LIBS="$saved_LIBS -levent"
-
- # Skip the directory if it isn't there.
- if test ! -z "$ledir" -a ! -d "$ledir" ; then
- continue;
- fi
- if test ! -z "$ledir" ; then
- if test -d "$ledir/lib" ; then
- LDFLAGS="-L$ledir/lib $LDFLAGS"
- else
- LDFLAGS="-L$ledir $LDFLAGS"
- fi
- if test -d "$ledir/include" ; then
- CPPFLAGS="-I$ledir/include $CPPFLAGS"
- else
- CPPFLAGS="-I$ledir $CPPFLAGS"
- fi
- fi
- # Can I compile and link it?
- AC_TRY_LINK([#include <sys/time.h>
-#include <sys/types.h>
-#include <event.h>], [ event_init(); ],
- [ libevent_linked=yes ], [ libevent_linked=no ])
- if test $libevent_linked = yes; then
- if test ! -z "$ledir" ; then
- ac_cv_libevent_dir=$ledir
- else
- ac_cv_libevent_dir="(system)"
- fi
- le_found=yes
- break
- fi
- done
- LIBS="$saved_LIBS"
- LDFLAGS="$saved_LDFLAGS"
- CPPFLAGS="$saved_CPPFLAGS"
- if test $le_found = no ; then
- AC_MSG_ERROR([libevent is required. You can get it from $LIBEVENT_URL
-
- If it's already installed, specify its path using --with-libevent=/dir/
-])
- fi
+AH_TOP([
+#ifndef CONFIG_H
+#define CONFIG_H
+/*
+ * Copyright (C) 2010 NorthScale, Inc
+ * All rights reserved.
+ *
+ * Use and distribution licensed under the BSD license. See
+ * the COPYING file in this directory for full text.
+ */
+#ifdef _SYS_FEATURE_TESTS_H
+#error "You should include config.h as your first include file"
+#endif
])
-LIBS="$LIBS -levent"
-
-if test $ac_cv_libevent_dir != "(system)"; then
- if test -d "$ac_cv_libevent_dir/lib" ; then
- LDFLAGS="$LDFLAGS -L$ac_cv_libevent_dir/lib"
- le_libdir="$ac_cv_libevent_dir/lib"
- else
- LDFLAGS="$LDFLAGS -L$ac_cv_libevent_dir"
- le_libdir="$ac_cv_libevent_dir"
- fi
- if test -d "$ac_cv_libevent_dir/include" ; then
- CPPFLAGS="$CPPFLAGS -I$ac_cv_libevent_dir/include"
- else
- CPPFLAGS="$CPPFLAGS -I$ac_cv_libevent_dir"
- fi
-fi
+AH_BOTTOM([
+#include "config_static.h"
+#endif
+])
AC_ARG_ENABLE(moxi-vbucket,
- [AS_HELP_STRING([--enable-moxi-vbucket], [use libvbucket instead of libmemcached])])
+ [AS_HELP_STRING([--enable-moxi-vbucket], [use libvbucket instead of libmemcached @<:@default=off@:>@])],
+ [ac_cv_enable_moxi_vbucket="$enableval"],
+ [ac_cv_enable_moxi_vbucket="no"])
-if test "x$enable_moxi_vbucket" != "xno"; then
- AC_DEFINE([MOXI_USE_VBUCKET], 1, [Defined moxi to use libvbucket])
- LIBS="$LIBS -lvbucket"
-fi
+AS_IF(test "x$ac_cv_enable_moxi_vbucket" = "xyes",
+ AC_DEFINE([MOXI_USE_VBUCKET], 1, [Defined moxi to use libvbucket]))
+AM_CONDITIONAL(MOXI_USE_VBUCKET, test "x$ac_cv_enable_moxi_vbucket" = "xyes")
AC_ARG_ENABLE(moxi-malloc,
[AS_HELP_STRING([--enable-moxi-malloc], [use malloc for items instead of slabber])])
@@ -327,15 +72,13 @@ AC_SEARCH_LIBS(gethostbyname, nsl)
AC_SEARCH_LIBS(umem_cache_create, umem)
AC_ARG_WITH([check],
- [AS_HELP_STRING([--with-check=yes], [look for check tool for unit tests])])
+ [AS_HELP_STRING([--with-check=yes], [look for check tool for unit tests @<:@default=yes@:>@])],
+ [ac_cv_with_check="$withval"], [ac_cv_with_check=yes])
-if test "x$with_check" = "xno"; then
- AC_MSG_NOTICE([skipping check unit-test dependency])
-else
- PKG_CHECK_MODULES([CHECK], [check >= 0.9.4])
-fi
+AS_IF(test "x$ac_cv_with_check" = "xyes",
+ [ PKG_CHECK_MODULES([CHECK], [check >= 0.9.4]) ],
+ [ AC_MSG_NOTICE([skipping check unit-test dependency])])
-AC_HEADER_STDBOOL
AC_C_CONST
dnl From licq: Copyright (c) 2000 Dirk Mueller
@@ -344,8 +87,13 @@ AC_DEFUN([AC_C_SOCKLEN_T],
[AC_CACHE_CHECK(for socklen_t, ac_cv_c_socklen_t,
[
AC_TRY_COMPILE([
+#ifdef WIN32
+ #include <winsock2.h>
+ #include <ws2tcpip.h>
+#else
#include <sys/types.h>
#include <sys/socket.h>
+#endif
],[
socklen_t foo;
],[
@@ -387,13 +135,6 @@ fi
AC_C_ENDIAN
-dnl Check whether the user's system supports pthread
-AC_SEARCH_LIBS(pthread_create, pthread)
-
-if test "x$ac_cv_search_pthread_create" = "xno"; then
- AC_MSG_ERROR([Can't enable threads without the POSIX thread library.])
-fi
-
AC_CHECK_FUNCS(mlockall)
AC_CHECK_FUNCS(getpagesizes)
AC_CHECK_FUNCS(memcntl)
@@ -458,32 +199,16 @@ AC_PATH_PROG([XSLTPROC], [xsltproc], "no")
AM_CONDITIONAL([BUILD_SPECIFICATIONS],
[test "x$enable_docs" != "xno" -a "x$XML2RFC" != "xno" -a "x$XSLTPROC" != "xno"])
-AC_CHECK_HEADERS_ONCE([netinet/in.h])
-
-dnl Let the compiler be a bit more picky. Please note that you cannot
-dnl specify these flags to the compiler before AC_CHECK_FUNCS, because
-dnl the test program will generate a compilation warning and hence fail
-dnl to detect the function ;-)
-if test "$ICC" = "yes"
-then
- dnl ICC trying to be gcc.
- CFLAGS="$CFLAGS -diag-disable 187 -Wall "
- AC_DEFINE([_GNU_SOURCE],[1],[find sigignore on Linux])
-elif test "$GCC" = "yes"
-then
- GCC_VERSION=`$CC -dumpversion`
- CFLAGS="$CFLAGS -Wall -Werror -pedantic -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls"
- case $GCC_VERSION in
- 4.4.*)
- CFLAGS="$CFLAGS -fno-strict-aliasing"
- ;;
- esac
- AC_DEFINE([_GNU_SOURCE],[1],[find sigignore on Linux])
- NO_STRICT_ALIASING="-fno-strict-aliasing -Wno-strict-aliasing"
-elif test "$SUNCC" = "yes"
-then
- CFLAGS="$CFLAGS -errfmt=error -errwarn -erroff=E_ATTRIBUTE_UNKNOWN -errshort=tags"
-fi
+
+AC_CHECK_HEADERS_ONCE(sys/socket.h netdb.h arpa/inet.h pwd.h sys/mman.h netinet/tcp.h sysexits.h sys/uio.h sys/resource.h sys/un.h netinet/in.h winsock2.h syslog.h)
+AS_IF(test "x$ac_cv_header_winsock2_h" = "xyes",
+ [AM_LDFLAGS="$AM_LDFLAGS -lws2_32"
+ AM_CFLAGS="$AM_CFLAGS $NO_WERROR"
+ AM_CXXFLAGS="$AM_CXXFLAGS $NO_WERROR"
+ ])
+
+AM_CONDITIONAL([BUILD_TESTAPPS], [test "x$ac_cv_header_winsock2_h" = "xno"])
+AM_CONDITIONAL([BUILD_DAEMON], [test "x$ac_cv_header_winsock2_h" = "xno"])
AC_ARG_VAR([CONFLATE_DB_PATH], [Directory for libconflate config database (default $prefix/var/lib/]AC_PACKAGE_NAME[)])
@@ -493,10 +218,7 @@ if test "x$BUILD_WITH_CONFLATE" = "xyes"; then
fi
fi
-AC_SUBST([DATE], [`LANG=C date -R`])
-
LIBS="$LIBS -lm"
AC_CONFIG_FILES(Makefile doc/Makefile debian/changelog scripts/rpm/moxi.spec)
AC_OUTPUT
-
View
3  cproxy.c
@@ -1,10 +1,9 @@
/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-
+#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
-#include <sysexits.h>
#include <pthread.h>
#include <assert.h>
#include <math.h>
View
3  cproxy_config.c
@@ -1,12 +1,11 @@
/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-
+#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#include <unistd.h>
-#include <sysexits.h>
#include <pthread.h>
#include <assert.h>
#include <math.h>
View
3  cproxy_front.c
@@ -1,10 +1,9 @@
/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-
+#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
-#include <sysexits.h>
#include <pthread.h>
#include <assert.h>
#include <math.h>
View
3  cproxy_multiget.c
@@ -1,10 +1,9 @@
/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-
+#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
-#include <sysexits.h>
#include <pthread.h>
#include <assert.h>
#include "memcached.h"
View
3  cproxy_protocol_a.c
@@ -1,9 +1,8 @@
/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-
+#include "config.h"
#include <stdio.h>
#include <string.h>
#include <errno.h>
-#include <sysexits.h>
#include <pthread.h>
#include <assert.h>
#include "memcached.h"
View
3  cproxy_protocol_a2a.c
@@ -1,9 +1,8 @@
/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-
+#include "config.h"
#include <stdio.h>
#include <string.h>
#include <errno.h>
-#include <sysexits.h>
#include <pthread.h>
#include <assert.h>
#include "memcached.h"
View
3  cproxy_protocol_a2b.c
@@ -1,10 +1,9 @@
/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-
+#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
-#include <sysexits.h>
#include <pthread.h>
#include <assert.h>
#include <math.h>
View
3  cproxy_protocol_b.c
@@ -1,10 +1,9 @@
/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-
+#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
-#include <sysexits.h>
#include <pthread.h>
#include <assert.h>
#include "memcached.h"
View
3  cproxy_protocol_b2b.c
@@ -1,10 +1,9 @@
/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-
+#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
-#include <sysexits.h>
#include <pthread.h>
#include <assert.h>
#include <math.h>
View
3  cproxy_stats.c
@@ -1,10 +1,9 @@
/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-
+#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
-#include <sysexits.h>
#include <pthread.h>
#include <assert.h>
#include "memcached.h"
View
1  daemon.c
@@ -34,6 +34,7 @@
# pragma ident "$NetBSD: daemon.c,v 1.9 2003/08/07 16:42:46 agc Exp $"
#endif
+#include "config.h"
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
View
15 doc/Makefile.am
@@ -3,18 +3,3 @@ man_MANS = moxi.1
EXTRA_DIST = *.txt
BUILT_SOURCES=
-
-if BUILD_SPECIFICATIONS
-BUILT_SOURCES += protocol-binary.txt protocol-binary-range.txt
-MOSTLYCLEANFILES = protocol-binary.txt protocol-binary-range.txt
-endif
-
-%.txt: %.full
- @XML2RFC@ $< $@
-
-%.chk: %.xml xml2rfc/rfc2629-refchk.xsl
- @XSLTPROC@ xml2rfc/rfc2629-refchk.xsl $< >$@
-
-%.full: %.xml xml2rfc/rfc2629-noinc.xsl
- @XSLTPROC@ xml2rfc/rfc2629-noinc.xsl $< >$@
-
View
226 doc/protocol-binary-range.xml
@@ -1,226 +0,0 @@
-<?xml version="1.0" encoding="US-ASCII"?>
-<!DOCTYPE rfc SYSTEM "xml2rfc/rfc2629.dtd">
-<?xml-stylesheet type='text/xsl' href='xml2rfc/rfc2629.xslt'?>
-<?rfc toc="yes"?>
-<?rfc strict="yes"?>
-<?rfc symrefs="yes"?>
-<?rfc sortrefs="yes" ?>
-<?rfc compact="yes" ?>
-<?rfc subcompact="yes" ?>
-<rfc category="info" docName="draft-stone-memcache-udp-01" ipr="none">
-
- <front>
-
- <title abbrev="Memcache Over UDP"> Memcache Binary Protocol: Extensions for UDP </title>
-
- <author fullname="Aaron Stone" surname="Aaron Stone" role="editor">
- <organization>Six Apart, Ltd.</organization>
- <address>
- <postal>
- <street>548 4th Street</street>
- <city>San Francisco</city>
- <region>CA</region>
- <code>94107</code>
- <country>USA</country>
- </postal>
- <email>aaron@serendipity.palo-alto.ca.us</email>
- </address>
- </author>
-
- <date day="14" month="December" year="2007" />
-
- <area>Applications</area>
-
- <keyword>memcache memcached cache udp</keyword>
-
- <abstract>
- <t>
- This memo explains extensions to the memcache binary protocol for use in a UDP environment.
- </t>
-
- <t>
- Memcache is a high performance key-value cache. It is intentionally a
- dumb cache, optimized for speed only. Applications using memcache do
- not rely on it for data -- a persistent database with guaranteed reliability
- is strongly recommended -- but applications can run much faster when
- cached data is available in memcache.
- </t>
- </abstract>
- </front>
-
- <middle>
- <section anchor="introduction" title="Introduction">
- <t>
- Memcache is a high performance key-value cache. It is intentionally a
- dumb cache, optimized for speed only. Applications using memcache do
- not rely on it for data -- a persistent database with guaranteed reliability
- is strongly recommended -- but applications can run much faster when
- cached data is available in memcache.
- </t>
- <t>
- Sites may find that, due to their network architecture or application usage patterns,
- the stateless <xref target="UDP"/> protocol better suits their needs. This document
- provides extensions and descriptions of use of the <xref target="MEMCACHE">memcache protocol</xref>
- in a UDP environment.
- </t>
- <t>
- It is a goal of this document to provide sufficient information in each UDP packet
- as to avoid any requirement for statefulness on the part of the server nor significant
- caching of outstanding packets on the part of the client.
- </t>
- <section anchor="conventions" title="Conventions Used In This Document">
- <t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
- "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
- document are to be interpreted as described in <xref target="KEYWORDS"/>.
- </t>
- </section>
- </section>
-
- <section anchor="values" title="Defined Values">
- <section anchor="value-magic" title="Magic Byte">
- <t>
- The magic bytes remains the same as in <xref target="MEMCACHE"/>.
- </t>
- </section>
-
- <section anchor="value-status" title="Response Status">
- <t>
- Additional status values:
- <list hangIndent="8" style="hanging">
- <t hangText="0x0004">Value is larger than a single response packet</t>
- </list>
- </t>
- </section>
-
- <section anchor="value-opcodes" title="Command Opcodes">
- <t>
- Additional opcode values:
- <list hangIndent="8" style="hanging">
- <t hangText="0x0C">Get Range</t>
- <t hangText="0x0D">Set Range</t>
- </list>
- </t>
- </section>
-
- <section anchor="value-types" title="Data Types">
- <t>
- There are no new data types in this extension.
- </t>
- </section>
- </section>
-
- <section anchor="commands" title="Commands">
-
- <section anchor="command-get" title="Get Response">
- <t>
- This section extends the behavior of the Get and GetQ commands as described in
- <xref target="MEMCACHE" x:sec="command-get"/>.
- </t>
-
- <t>
- When a Get or GetQ request is made via UDP, and the value of the key for which
- the request was made is larger than can be placed into a single UDP packet (noting
- that the protocol header must also be counted), a Get Range response packet
- MUST be sent instead of the Get response packet. In this instance:
- <list style="numbers">
- <t>The Status field of the response header MUST be 0x0004.</t>
- <t>The Offset field of the GetR response extras MUST be 0.</t>
- <t>The Length field of the GetR response extras, and the data contained in
- the Value field of the packet, SHOULD be the maximum
- allowed length of a UDP packet, less the space required by the header
- and extras; however it MAY be any amount below this maximum.</t>
- <t>The Total value length field of the response extras MUST be the
- actual length of the complete value.</t>
- </list>
- </t>
-
- <t>
- The client, upon receipt of a Get Range response bearing Status 0x004
- and a Message ID corresponding to its Get request, shall then know that
- it has received only the first portion of the value. The client MAY choose
- to request the remaining portion of the value by sending one or more Get Range requests.
- </t>
- </section>
-
- <section anchor="command-getr-request" title="Get Range Request">
- <t>
- The Get Range request is primarily intended for use over a UDP transport
- to request byte ranges of the value for a key. In the event that the Data version
- check fails to match that of the key, an error MUST be returned.
- </t>
- <t>
- <figure>
- <preamble>Extra data for get range request:</preamble>
- <artwork>
-Byte/ 0 | 1 | 2 | 3 |
- / | | | |
- |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
- +---------------+---------------+---------------+---------------+
- 0| Flags |
- +---------------+---------------+---------------+---------------+
- 4| Data version check |
- | |
- +---------------+---------------+---------------+---------------+
-12| Offset |
- +---------------+---------------+---------------+---------------+
-16| Length |
- +---------------+---------------+---------------+---------------+
-Total 20 bytes
- </artwork></figure>
- </t>
- </section>
-
- <section anchor="command-getr-response" title="Get Range Response">
- <t>
- The Get Range request is primarily intended for use over a UDP transport
- to indicate the location of the bytes of the value for a key contained in
- a given packet. A client receives enough information in each Get Range
- extras to construct an appropriately sized buffer in its own memory and
- blindly insert the contents of the packet at the given byte offset.
- </t>
- <t>
- <figure>
- <preamble>Extra data for get range response:</preamble>
- <artwork>
-Byte/ 0 | 1 | 2 | 3 |
- / | | | |
- |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
- +---------------+---------------+---------------+---------------+
- 0| Flags |
- +---------------+---------------+---------------+---------------+
- 4| Data version check |
- | |
- +---------------+---------------+---------------+---------------+
-12| Offset |
- +---------------+---------------+---------------+---------------+
-16| Length |
- +---------------+---------------+---------------+---------------+
-20| Total value length |
- +---------------+---------------+---------------+---------------+
-Total 24 bytes
- </artwork></figure>
- </t>
- </section>
-
- </section>
-
- <section anchor="security" title="Security Considerations">
- <t>
- This document does not introduce any new security considerations
- beyond those discussed in <xref target="MEMCACHE" x:sec="security"/>.
- </t>
- </section>
-
- </middle>
-
- <back>
- <references title="Normative References">
- <dwdrfc-ref anchor='UDP' src='http://xml.resource.org/public/rfc/bibxml/reference.RFC.0768.xml'/>
- <dwdrfc-ref anchor='KEYWORDS' src='http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml'/>
- <!-- FIXME: Get a draft reference for the base document. -->
- <dwdrfc-ref anchor='MEMCACHE' src='http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml'/>
- </references>
- </back>
-
-</rfc>
-
View
1,467 doc/protocol-binary.xml
@@ -1,1467 +0,0 @@
-<?xml version="1.0" encoding="US-ASCII"?>
-<!DOCTYPE rfc SYSTEM "xml2rfc/rfc2629.dtd">
-<?xml-stylesheet type='text/xsl' href='xml2rfc/rfc2629.xslt'?>
-<?rfc toc="yes"?>
-<?rfc strict="yes"?>
-<?rfc symrefs="yes"?>
-<?rfc sortrefs="yes" ?>
-<?rfc compact="yes" ?>
-<?rfc subcompact="yes" ?>
-<rfc category="info" docName="draft-stone-memcache-binary-01" ipr="none">
- <front>
- <title> Memcache Binary Protocol </title>
-
- <author fullname="Aaron Stone" surname="Stone" role="editor">
- <organization>Six Apart, Ltd.</organization>
- <address>
- <postal>
- <street>548 4th Street</street>
- <city>San Francisco</city>
- <region>CA</region>
- <code>94107</code>
- <country>USA</country>
- </postal>
- <email>aaron@serendipity.palo-alto.ca.us</email>
- </address>
- </author>
- <author fullname="Trond Norbye" surname="Norbye" role="editor">
- <organization>Sun Microsystems, INC</organization>
- <address>
- <postal>
- <street>Haakon VII g. 7B</street>
- <city>Trondheim</city>
- <code>NO-7485 Trondheim</code>
- <country>Norway</country>
- </postal>
- <email>trond.norbye@sun.com</email>
- </address>
- </author>
- <date day="28" month="August" year="2008" />
- <area>Applications</area>
- <keyword>memcache memcached cache</keyword>
- <abstract>
- <t>
- This memo explains the memcache binary protocol for informational
- purposes.
- </t>
- <t>
- Memcache is a high performance key-value cache. It is intentionally a
- dumb cache, optimized for speed only. Applications using memcache do
- not rely on it for data -- a persistent database with guaranteed
- reliability is strongly recommended -- but applications can run much
- faster when cached data is available in memcache.
- </t>
- </abstract>
- </front>
-
- <middle>
- <section anchor="introduction" title="Introduction">
- <t>
- Memcache is a high performance key-value cache. It is intentionally a
- dumb cache, optimized for speed only. Applications using memcache should
- not rely on it for data -- a persistent database with guaranteed
- reliability is strongly recommended -- but applications can run much
- faster when cached data is available in memcache.
- </t>
- <t>
- Memcache was originally written to make
- <xref target="LJ">LiveJournal</xref> faster. It now powers all of
- the fastest web sites that you love.
- </t>
- <section anchor="conventions" title="Conventions Used In This Document">
- <t>
- The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
- "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
- document are to be interpreted as described in
- <xref target="KEYWORDS"/>.
- </t>
- </section>
- </section>
-
- <section anchor="packet" title="Packet Structure">
- <figure>
- <preamble>General format of a packet:</preamble>
- <artwork>
- Byte/ 0 | 1 | 2 | 3 |
- / | | | |
- |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
- +---------------+---------------+---------------+---------------+
- 0/ HEADER /
- / /
- / /
- / /
- +---------------+---------------+---------------+---------------+
- 24/ COMMAND-SPECIFIC EXTRAS (as needed) /
- +/ (note length in the extras length header field) /
- +---------------+---------------+---------------+---------------+
- m/ Key (as needed) /
- +/ (note length in key length header field) /
- +---------------+---------------+---------------+---------------+
- n/ Value (as needed) /
- +/ (note length is total body length header field, minus /
- +/ sum of the extras and key length body fields) /
- +---------------+---------------+---------------+---------------+
- Total 24 bytes
- </artwork>
- </figure>
-
- <figure>
- <preamble>Request header:</preamble>
- <artwork>
- Byte/ 0 | 1 | 2 | 3 |
- / | | | |
- |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
- +---------------+---------------+---------------+---------------+
- 0| Magic | Opcode | Key length |
- +---------------+---------------+---------------+---------------+
- 4| Extras length | Data type | Reserved |
- +---------------+---------------+---------------+---------------+
- 8| Total body length |
- +---------------+---------------+---------------+---------------+
- 12| Opaque |
- +---------------+---------------+---------------+---------------+
- 16| CAS |
- | |
- +---------------+---------------+---------------+---------------+
- Total 24 bytes
- </artwork>
- </figure>
-
- <figure>
- <preamble>Response header:</preamble>
- <artwork>
- Byte/ 0 | 1 | 2 | 3 |
- / | | | |
- |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
- +---------------+---------------+---------------+---------------+
- 0| Magic | Opcode | Key Length |
- +---------------+---------------+---------------+---------------+
- 4| Extras length | Data type | Status |
- +---------------+---------------+---------------+---------------+
- 8| Total body length |
- +---------------+---------------+---------------+---------------+
- 12| Opaque |
- +---------------+---------------+---------------+---------------+
- 16| CAS |
- | |
- +---------------+---------------+---------------+---------------+
- Total 24 bytes
- </artwork>
- </figure>
-
- <t>
- Header fields:
- <list hangIndent="20" style="hanging">
- <t hangText="Magic">Magic number.</t>
- <t hangText="Opcode">Command code.</t>
- <t hangText="Key length">Length in bytes of the text key that follows the command extras.</t>
- <t hangText="Status">Status of the response (non-zero on error).</t>
- <t hangText="Extras length">Length in bytes of the command extras.</t>
- <t hangText="Data type">Reserved for future use (Sean is using this soon).</t>
- <t hangText="Reserved">Really reserved for future use (up for grabs).</t>
- <t hangText="Total body length">Length in bytes of extra + key + value.</t>
- <t hangText="Opaque">Will be copied back to you in the response.</t>
- <t hangText="CAS">Data version check.</t>
- </list>
- </t>
- </section>
-
- <section anchor="values" title="Defined Values">
- <section anchor="value-magic" title="Magic Byte">
- <t>
- <list hangIndent="8" style="hanging">
- <t hangText="0x80">Request packet for this protocol version</t>
- <t hangText="0x81">Response packet for this protocol version</t>
- </list>
- </t>
-
- <t>
- Magic byte / version. For each version of the protocol, we'll use a
- different request/response value pair. This is useful for protocol
- analyzers to distinguish the nature of the packet from the direction
- which it is moving. Note, it is common to run a memcached instance on
- a host that also runs an application server. Such a host will both
- send and receive memcache packets.
- </t>
-
- <t>
- The version should hopefully correspond only to different meanings of
- the command byte. In an ideal world, we will not change the header
- format. As reserved bytes are given defined meaning, the protocol
- version / magic byte values should be incremented.
- </t>
-
- <t>
- Traffic analysis tools are encouraged to identify memcache packets
- and provide detailed interpretation if the magic bytes are recognized
- and otherwise to provide a generic breakdown of the packet. Note, that
- the key and value positions can always be identified even if the magic
- byte or command opcode are not recognized.
- </t>
- </section>
-
- <section anchor="value-status" title="Response Status">
- <t>
- Possible values of this two-byte field:
- <list hangIndent="8" style="hanging">
- <t hangText="0x0000">No error</t>
- <t hangText="0x0001">Key not found</t>
- <t hangText="0x0002">Key exists</t>
- <t hangText="0x0003">Value too large</t>
- <t hangText="0x0004">Invalid arguments</t>
- <t hangText="0x0005">Item not stored</t>
- <t hangText="0x0006">Incr/Decr on non-numeric value.</t>
- <t hangText="0x0081">Unknown command</t>
- <t hangText="0x0082">Out of memory</t>
- </list>
- </t>
- </section>
-
- <section anchor="value-opcodes" title="Command Opcodes">
- <t>
- Possible values of the one-byte field:
- <list hangIndent="8" style="hanging">
- <t hangText="0x00">Get</t>
- <t hangText="0x01">Set</t>
- <t hangText="0x02">Add</t>
- <t hangText="0x03">Replace</t>
- <t hangText="0x04">Delete</t>
- <t hangText="0x05">Increment</t>
- <t hangText="0x06">Decrement</t>
- <t hangText="0x07">Quit</t>
- <t hangText="0x08">Flush</t>
- <t hangText="0x09">GetQ</t>
- <t hangText="0x0A">No-op</t>
- <t hangText="0x0B">Version</t>
- <t hangText="0x0C">GetK</t>
- <t hangText="0x0D">GetKQ</t>
- <t hangText="0x0E">Append</t>
- <t hangText="0x0F">Prepend</t>
- <t hangText="0x10">Stat</t>
- <t hangText="0x11">SetQ</t>
- <t hangText="0x12">AddQ</t>
- <t hangText="0x13">ReplaceQ</t>
- <t hangText="0x14">DeleteQ</t>
- <t hangText="0x15">IncrementQ</t>
- <t hangText="0x16">DecrementQ</t>
- <t hangText="0x17">QuitQ</t>
- <t hangText="0x18">FlushQ</t>
- <t hangText="0x19">AppendQ</t>
- <t hangText="0x1A">PrependQ</t>
- </list>
- </t>
- <t>
- As a convention all of the commands ending with "Q" for
- Quiet. A quiet version of a command will omit responses
- that are considered uninteresting. Whether a given response
- is interesting is dependent upon the command. See the
- descriptions of the
- <xref target="command-get">set commands</xref>
- and <xref target="command-set">set commands</xref> for
- examples of commands that include quiet variants.
- </t>
- </section>
-
- <section anchor="value-types" title="Data Types">
- <t>
- Possible values of the one-byte field:
- <list hangIndent="8" style="hanging">
- <t hangText="0x00">Raw bytes</t>
- </list>
- </t>
- </section>
- </section>
-
- <section title="Commands">
- <section anchor="command-introduction" title="Introduction">
- <t>
- All communication is initiated by a request from the client,
- and the server will respond to each request with zero or
- multiple packets for each request. If the status code of a response
- packet is non-nil, the body of the packet will contain a textual error
- message. If the status code is nil, the command opcode will define the
- layout of the body of the message.
- </t>
- <section anchor="command-introduction-example" title="Example">
- <t>
- The following figure illustrates the packet layout for
- a packet with an error message.
- </t>
- <figure>
- <preamble>Packet layout:</preamble>
- <artwork>
-
- Byte/ 0 | 1 | 2 | 3 |
- / | | | |
- |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
- +---------------+---------------+---------------+---------------+
- 0| 0x81 | 0x00 | 0x00 | 0x00 |
- +---------------+---------------+---------------+---------------+
- 4| 0x00 | 0x00 | 0x00 | 0x01 |
- +---------------+---------------+---------------+---------------+
- 8| 0x00 | 0x00 | 0x00 | 0x09 |
- +---------------+---------------+---------------+---------------+
- 12| 0x00 | 0x00 | 0x00 | 0x00 |
- +---------------+---------------+---------------+---------------+
- 16| 0x00 | 0x00 | 0x00 | 0x00 |
- +---------------+---------------+---------------+---------------+
- 20| 0x00 | 0x00 | 0x00 | 0x00 |
- +---------------+---------------+---------------+---------------+
- 24| 0x4e ('N') | 0x6f ('o') | 0x74 ('t') | 0x20 (' ') |
- +---------------+---------------+---------------+---------------+
- 28| 0x66 ('f') | 0x6f ('o') | 0x75 ('u') | 0x6e ('n') |
- +---------------+---------------+---------------+---------------+
- 32| 0x64 ('d') |
- +---------------+
- Total 33 bytes (24 byte header, and 9 bytes value)
-
-Field (offset) (value)
-Magic (0) : 0x81
-Opcode (1) : 0x00
-Key length (2,3) : 0x0000
-Extra length (4) : 0x00
-Data type (5) : 0x00
-Status (6,7) : 0x0001
-Total body (8-11) : 0x00000009
-Opaque (12-15): 0x00000000
-CAS (16-23): 0x0000000000000000
-Extras : None
-Key : None
-Value (24-32): The textual string "Not found"
- </artwork>
- </figure>
- </section>
- </section>
-
- <section anchor="command-get" title="Get, Get Quietly, Get Key, Get Key Quietly">
- <t>
- Request:
- </t>
- <t>
- <list style="empty">
- <t>MUST NOT have extras.</t>
- <t>MUST have key.</t>
- <t>MUST NOT have value.</t>
- </list>
- </t>
-
- <t>
- <list style="symbols">
- <t>4 byte flags</t>
- </list>
- </t>
-
- <t>
- Response (if found):
- </t>
- <t>
- <list style="empty">
- <t>MUST have extras.</t>
- <t>MAY have key.</t>
- <t>MAY have value.</t>
- </list>
- </t>
-
- <t>
- <list style="symbols">
- <t>4 byte flags</t>
- </list>
- </t>
-
- <t>
- <figure>
- <preamble>Extra data for the get commands:</preamble>
- <artwork>
- Byte/ 0 | 1 | 2 | 3 |
- / | | | |
- |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
- +---------------+---------------+---------------+---------------+
- 0| Flags |
- +---------------+---------------+---------------+---------------+
-
- Total 4 bytes
- </artwork>
- </figure>
- </t>
-
- <t>
- The get command gets a single key. The getq command is both mum
- on cache miss and quiet, holding its response until a non-quiet
- command is issued. Getk and getkq differs from get and getq by
- adding the key into the response packet.
- </t>
-
- <t>
- You're not guaranteed a response to a getq/getkq cache hit until
- you send a non-getq/getkq command later, which uncorks the
- server and bundles up IOs to send to the client in one go.
- </t>
-
- <t>
- Clients should implement multi-get (still important for
- reducing network roundtrips!) as n pipelined requests, the
- first n-1 being getq/getkq, the last being a regular
- get/getk. That way you're guaranteed to get a response, and
- you know when the server's done. You can also do the naive
- thing and send n pipelined get/getks, but then you could potentially
- get back a lot of "NOT_FOUND" error code packets.
- Alternatively, you can send 'n' getq/getkqs, followed by a
- 'noop' command.
- </t>
-
- <section anchor="command-get-example" title="Example">
- <t>
- To request the data associated with the key "Hello" the
- following fields must be specified in the packet.
- </t>
- <figure>
- <preamble>get request:</preamble>
- <artwork>
- Byte/ 0 | 1 | 2 | 3 |
- / | | | |
- |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
- +---------------+---------------+---------------+---------------+
- 0| 0x80 | 0x00 | 0x00 | 0x05 |
- +---------------+---------------+---------------+---------------+
- 4| 0x00 | 0x00 | 0x00 | 0x00 |
- +---------------+---------------+---------------+---------------+
- 8| 0x00 | 0x00 | 0x00 | 0x05 |
- +---------------+---------------+---------------+---------------+
- 12| 0x00 | 0x00 | 0x00 | 0x00 |
- +---------------+---------------+---------------+---------------+
- 16| 0x00 | 0x00 | 0x00 | 0x00 |
- +---------------+---------------+---------------+---------------+
- 20| 0x00 | 0x00 | 0x00 | 0x00 |
- +---------------+---------------+---------------+---------------+
- 24| 0x48 ('H') | 0x65 ('e') | 0x6c ('l') | 0x6c ('l') |
- +---------------+---------------+---------------+---------------+
- 28| 0x6f ('o') |
- +---------------+
-
- Total 29 bytes (24 byte header, and 5 bytes key)
-
-Field (offset) (value)
-Magic (0) : 0x80
-Opcode (1) : 0x00
-Key length (2,3) : 0x0005
-Extra length (4) : 0x00
-Data type (5) : 0x00
-Reserved (6,7) : 0x0000
-Total body (8-11) : 0x00000005
-Opaque (12-15): 0x00000000
-CAS (16-23): 0x0000000000000000
-Extras : None
-Key (24-29): The textual string: "Hello"
-Value : None
- </artwork>
- </figure>
- <t>If the item exist on the server the following packet is returned,
- otherwise a packet with status code != 0 will be returned (see
- <xref target="command-introduction">Introduction</xref>)
- </t>
- <figure>
- <preamble>get/getq response:</preamble>
- <artwork>
-
- Byte/ 0 | 1 | 2 | 3 |
- / | | | |
- |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
- +---------------+---------------+---------------+---------------+
- 0| 0x81 | 0x00 | 0x00 | 0x00 |
- +---------------+---------------+---------------+---------------+
- 4| 0x04 | 0x00 | 0x00 | 0x00 |
- +---------------+---------------+---------------+---------------+
- 8| 0x00 | 0x00 | 0x00 | 0x09 |
- +---------------+---------------+---------------+---------------+
- 12| 0x00 | 0x00 | 0x00 | 0x00 |
- +---------------+---------------+---------------+---------------+
- 16| 0x00 | 0x00 | 0x00 | 0x00 |
- +---------------+---------------+---------------+---------------+
- 20| 0x00 | 0x00 | 0x00 | 0x01 |
- +---------------+---------------+---------------+---------------+
- 24| 0xde | 0xad | 0xbe | 0xef |
- +---------------+---------------+---------------+---------------+
- 28| 0x57 ('W') | 0x6f ('o') | 0x72 ('r') | 0x6c ('l') |
- +---------------+---------------+---------------+---------------+
- 32| 0x64 ('d') |
- +---------------+
-
- Total 33 bytes (24 byte header, 4 byte extras and 5 byte value)
-
-Field (offset) (value)
-Magic (0) : 0x81
-Opcode (1) : 0x00
-Key length (2,3) : 0x0000
-Extra length (4) : 0x04
-Data type (5) : 0x00
-Status (6,7) : 0x0000
-Total body (8-11) : 0x00000009
-Opaque (12-15): 0x00000000
-CAS (16-23): 0x0000000000000001
-Extras :
- Flags (24-27): 0xdeadbeef
-Key : None
-Value (28-32): The textual string "World"
- </artwork>
- </figure>
- <figure>
- <preamble>getk/getkq response:</preamble>
- <artwork>
-
- Byte/ 0 | 1 | 2 | 3 |
- / | | | |
- |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
- +---------------+---------------+---------------+---------------+
- 0| 0x81 | 0x00 | 0x00 | 0x05 |
- +---------------+---------------+---------------+---------------+
- 4| 0x04 | 0x00 | 0x00 | 0x00 |
- +---------------+---------------+---------------+---------------+
- 8| 0x00 | 0x00 | 0x00 | 0x09 |
- +---------------+---------------+---------------+---------------+
- 12| 0x00 | 0x00 | 0x00 | 0x00 |
- +---------------+---------------+---------------+---------------+
- 16| 0x00 | 0x00 | 0x00 | 0x00 |
- +---------------+---------------+---------------+---------------+
- 20| 0x00 | 0x00 | 0x00 | 0x01 |
- +---------------+---------------+---------------+---------------+
- 24| 0xde | 0xad | 0xbe | 0xef |
- +---------------+---------------+---------------+---------------+
- 28| 0x48 ('H') | 0x65 ('e') | 0x6c ('l') | 0x6c ('l') |
- +---------------+---------------+---------------+---------------+
- 32| 0x6f ('o') | 0x57 ('W') | 0x6f ('o') | 0x72 ('r') |
- +---------------+---------------+---------------+---------------+
- 36| 0x6c ('l') | 0x64 ('d') |
- +---------------+---------------+
-
- Total 38 bytes (24 byte header, 4 byte extras, 5 byte key
- and 5 byte value)
-
-Field (offset) (value)
-Magic (0) : 0x81
-Opcode (1) : 0x00
-Key length (2,3) : 0x0005
-Extra length (4) : 0x04
-Data type (5) : 0x00
-Status (6,7) : 0x0000
-Total body (8-11) : 0x00000009
-Opaque (12-15): 0x00000000
-CAS (16-23): 0x0000000000000001
-Extras :
- Flags (24-27): 0xdeadbeef
-Key (28-32): The textual string: "Hello"
-Value (33-37): The textual string: "World"
- </artwork>
- </figure>
- </section>
- </section>
-
- <section anchor="command-set" title="Set, Add, Replace">
- <t>
- <list style="empty">
- <t>MUST have extras.</t>
- <t>MUST have key.</t>
- <t>MUST have value.</t>
- </list>
- </t>
-
- <t>
- <list style="symbols">
- <t>4 byte flags</t>
- <t>4 byte expiration time</t>
- </list>
- </t>
-
- <figure>
- <preamble>Extra data for set/add/replace:</preamble>
- <artwork>
- Byte/ 0 | 1 | 2 | 3 |
- / | | | |
- |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
- +---------------+---------------+---------------+---------------+
- 0| Flags |
- +---------------+---------------+---------------+---------------+
- 4| Expiration |
- +---------------+---------------+---------------+---------------+
- Total 8 bytes
- </artwork>
- </figure>
-
- <t>
- If the Data Version Check (CAS) is nonzero, the requested
- operation MUST only succeed if the item exists and has a CAS value
- identical to the provided value.
- </t>
-
- <t>
- Add MUST fail if the item already exist.
- </t>
-
- <t>
- Replace MUST fail if the item doesn't exist.
- </t>
-
- <t>
- Set should store the data unconditionally if the item exists
- or not.
- </t>
-
- <t>
- Quiet mutations only return responses on failure. Success
- is considered the general case and is suppressed when in
- quiet mode, but errors should not be allowed to go
- unnoticed.
- </t>
-
- <section anchor="command-set-example" title="Example">
- <t>The following figure shows an add-command for
- <list style="empty">
- <t>Key: "Hello"</t>
- <t>Value: "World"</t>
- <t>Flags: 0xdeadbeef</t>
- <t>Expiry: in two hours</t>
- </list>
- </t>
- <figure>
- <preamble>Add request:</preamble>
- <artwork>
-
- Byte/ 0 | 1 | 2 | 3 |
- / | | | |
- |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
- +---------------+---------------+---------------+---------------+
- 0| 0x80 | 0x02 | 0x00 | 0x05 |
- +---------------+---------------+---------------+---------------+
- 4| 0x08 | 0x00 | 0x00 | 0x00 |
- +---------------+---------------+---------------+---------------+
- 8| 0x00 | 0x00 | 0x00 | 0x12 |
- +---------------+---------------+---------------+---------------+
- 12| 0x00 | 0x00 | 0x00 | 0x00 |
- +---------------+---------------+---------------+---------------+
- 16| 0x00 | 0x00 | 0x00 | 0x00 |
- +---------------+---------------+---------------+---------------+
- 20| 0x00 | 0x00 | 0x00 | 0x00 |
- +---------------+---------------+---------------+---------------+
- 24| 0xde | 0xad | 0xbe | 0xef |
- +---------------+---------------+---------------+---------------+
- 28| 0x00 | 0x00 | 0x0e | 0x10 |
- +---------------+---------------+---------------+---------------+
- 32| 0x48 ('H') | 0x65 ('e') | 0x6c ('l') | 0x6c ('l') |
- +---------------+---------------+---------------+---------------+
- 36| 0x6f ('o') | 0x57 ('W') | 0x6f ('o') | 0x72 ('r') |
- +---------------+---------------+---------------+---------------+
- 40| 0x6c ('l') | 0x64 ('d') |
- +---------------+---------------+
-
- Total 42 bytes (24 byte header, 8 byte extras, 5 byte key and
- 5 byte value)
-
-Field (offset) (value)
-Magic (0) : 0x80
-Opcode (1) : 0x02
-Key length (2,3) : 0x0005
-Extra length (4) : 0x08
-Data type (5) : 0x00
-Reserved (6,7) : 0x0000
-Total body (8-11) : 0x00000012
-Opaque (12-15): 0x00000000
-CAS (16-23): 0x0000000000000000
-Extras :
- Flags (24-27): 0xdeadbeef
- Expiry (28-31): 0x00000e10
-Key (32-36): The textual string "Hello"
-Value (37-41): The textual string "World"
- </artwork>
- </figure>
- <t>
- The response-packet contains no extra data, and the result of the
- operation is signaled through the status code. If the command
- succeeds, the CAS value for the item is returned in the CAS-field
- of the packet.
- </t>
- <figure>
- <preamble>Successful add response:</preamble>
- <artwork>
-
- Byte/ 0 | 1 | 2 | 3 |
- / | | | |
- |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
- +---------------+---------------+---------------+---------------+
- 0| 0x81 | 0x02 | 0x00 | 0x00 |
- +---------------+---------------+---------------+---------------+
- 4| 0x00 | 0x00 | 0x00 | 0x00 |
- +---------------+---------------+---------------+---------------+
- 8| 0x00 | 0x00 | 0x00 | 0x00 |
- +---------------+---------------+---------------+---------------+
- 12| 0x00 | 0x00 | 0x00 | 0x00 |
- +---------------+---------------+---------------+---------------+
- 16| 0x00 | 0x00 | 0x00 | 0x00 |
- +---------------+---------------+---------------+---------------+
- 20| 0x00 | 0x00 | 0x00 | 0x01 |
- +---------------+---------------+---------------+---------------+
-
- Total 24 bytes
-
-Field (offset) (value)
-Magic (0) : 0x81
-Opcode (1) : 0x02
-Key length (2,3) : 0x0000
-Extra length (4) : 0x00
-Data type (5) : 0x00
-Status (6,7) : 0x0000
-Total body (8-11) : 0x00000000
-Opaque (12-15): 0x00000000
-CAS (16-23): 0x0000000000000001
-Extras : None
-Key : None
-Value : None
- </artwork>
- </figure>
- </section>
- </section>
-
- <section anchor="command-delete" title="Delete">
- <t>
- <list style="empty">
- <t>MUST NOT have extras.</t>
- <t>MUST have key.</t>
- <t>MUST NOT have value.</t>
- </list>
- </t>
-
- <t>
- Delete the item with the specific key.
- </t>
-
- <section anchor="command-delete-example" title="Example">
- <t>The following figure shows a delete message for the
- item "Hello".</t>
- <figure>
- <preamble>Delete request:</preamble>
- <artwork>
- Byte/ 0 | 1 | 2 | 3 |
- / | | | |
- |0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|0 1 2 3 4 5 6 7|
- +---------------+---------------+---------------+---------------+
- 0| 0x80 | 0x04 | 0x00 | 0x05 |
- +---------------+---------------+---------------+---------------+
- 4| 0x00 | 0x00 | 0x00 | 0x00 |
- +---------------+---------------+---------------+---------------+
- 8| 0x00 | 0x00 | 0x00 | 0x05 |
- +---------------+---------------+---------------+---------------+
- 12| 0x00 | 0x00 | 0x00 | 0x00 |
- +---------------+---------------+---------------+---------------+
- 16| 0x00 | 0x00 | 0x00 | 0x00 |
- +---------------+---------------+---------------+---------------+
- 20| 0x00 | 0x00 | 0x00 | 0x00 |
- +---------------+---------------+---------------+---------------+
- 24| 0x48 ('H') | 0x65 ('e') | 0x6c ('l') | 0x6c ('l') |
- +---------------+---------------+---------------+---------------+
- 28| 0x6f ('o') |
- +---------------+
-
- Total 29 bytes (24 byte header, 5 byte value)
-
-Field (offset) (value)
-Magic (0) : 0x80
-Opcode (1) : 0x04
-Key length (2,3) : 0x0005
-Extra length (4) : 0x00
-Data type (5) : 0x00
-Reserved (6,7) : 0x0000
-Total body (8-11) : 0x00000005
-Opaque (12-15): 0x00000000
-CAS (16-23): 0x0000000000000000
-Extras : None
-Key : The textual string "Hello"
-Value : None
- </artwork>
- </figure>
- <t>
- The response-packet contains no extra data, and the result of the
- operation is signaled through the status code.
- </t>
- </section>
- </section>
-
- <section anchor="command-incr" title="Increment, Decrement">