Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of ssh://git.varnish-cache.org/git/varnish-cach…

…e into experimental-ims

Conflicts resolved, but IMS is *not* working in this commit
  • Loading branch information...
commit 901e0f634568f83958a93a26dae6f109f625a37d 2 parents a18ff47 + 57b4594
@slimhazard slimhazard authored
Showing with 7,785 additions and 5,002 deletions.
  1. +2 −2 INSTALL
  2. +0 −2  Makefile.am
  3. +4 −0 autogen.des
  4. +3 −0  autogen.sh
  5. +19 −13 bin/varnishadm/varnishadm.c
  6. +10 −4 bin/varnishd/Makefile.am
  7. +183 −146 bin/varnishd/cache/cache.h
  8. +18 −12 bin/varnishd/cache/cache_acceptor.c
  9. +58 −48 bin/varnishd/cache/cache_backend.c
  10. +3 −5 bin/varnishd/cache/cache_backend.h
  11. +2 −2 bin/varnishd/cache/cache_backend_cfg.c
  12. +1 −1  bin/varnishd/cache/cache_backend_poll.c
  13. +50 −37 bin/varnishd/cache/cache_ban.c
  14. +72 −77 bin/varnishd/cache/cache_busyobj.c
  15. +20 −32 bin/varnishd/cache/cache_dir.c
  16. +41 −42 bin/varnishd/cache/cache_dir_dns.c
  17. +45 −34 bin/varnishd/cache/cache_dir_random.c
  18. +7 −8 bin/varnishd/cache/cache_dir_round_robin.c
  19. +0 −2  bin/varnishd/cache/cache_esi.h
  20. +141 −119 bin/varnishd/cache/cache_esi_deliver.c
  21. +17 −14 bin/varnishd/cache/cache_esi_fetch.c
  22. +3 −3 bin/varnishd/cache/cache_esi_parse.c
  23. +33 −24 bin/varnishd/cache/cache_expire.c
  24. +207 −146 bin/varnishd/cache/cache_fetch.c
  25. +54 −45 bin/varnishd/cache/cache_gzip.c
  26. +196 −196 bin/varnishd/cache/cache_hash.c
  27. +63 −60 bin/varnishd/cache/cache_http.c
  28. +370 −0 bin/varnishd/cache/cache_http1_fsm.c
  29. +37 −57 bin/varnishd/cache/cache_httpconn.c
  30. +13 −25 bin/varnishd/cache/cache_lck.c
  31. +80 −23 bin/varnishd/cache/cache_main.c
  32. +0 −3  bin/varnishd/cache/cache_mempool.c
  33. +91 −58 bin/varnishd/cache/cache_panic.c
  34. +30 −28 bin/varnishd/cache/cache_pipe.c
  35. +78 −133 bin/varnishd/cache/cache_pool.c
  36. +368 −777 bin/varnishd/cache/{cache_center.c → cache_req_fsm.c}
  37. +46 −62 bin/varnishd/cache/cache_response.c
  38. +36 −35 bin/varnishd/cache/cache_rfc2616.c
  39. +159 −117 bin/varnishd/cache/cache_session.c
  40. +54 −37 bin/varnishd/cache/cache_shmlog.c
  41. +85 −43 bin/varnishd/cache/cache_vary.c
  42. +20 −11 bin/varnishd/cache/cache_vcl.c
  43. +91 −97 bin/varnishd/cache/cache_vrt.c
  44. +12 −10 bin/varnishd/cache/cache_vrt_re.c
  45. +288 −275 bin/varnishd/cache/cache_vrt_var.c
  46. +5 −15 bin/varnishd/cache/cache_wrk.c
  47. +14 −14 bin/varnishd/cache/cache_wrw.c
  48. +8 −8 bin/varnishd/cache/cache_ws.c
  49. +28 −18 bin/varnishd/common/params.h
  50. +15 −2 bin/varnishd/flint.lnt
  51. +1 −0  bin/varnishd/flint.sh
  52. +30 −16 bin/varnishd/hash/hash_classic.c
  53. +73 −60 bin/varnishd/hash/hash_critbit.c
  54. +0 −1  bin/varnishd/hash/hash_mgt.c
  55. +21 −10 bin/varnishd/hash/hash_simple_list.c
  56. +13 −11 bin/varnishd/hash/hash_slinger.h
  57. +14 −5 bin/varnishd/mgt/mgt.h
  58. +10 −9 bin/varnishd/mgt/mgt_child.c
  59. +2 −0  bin/varnishd/mgt/mgt_cli.c
  60. +66 −72 bin/varnishd/mgt/mgt_main.c
  61. +94 −87 bin/varnishd/mgt/mgt_param.c
  62. +6 −1 bin/varnishd/mgt/mgt_param.h
  63. +263 −0 bin/varnishd/mgt/mgt_param_bits.c
  64. +53 −61 bin/varnishd/mgt/mgt_pool.c
  65. +23 −14 bin/varnishd/mgt/mgt_sandbox.c
  66. +114 −34 bin/varnishd/mgt/mgt_sandbox_solaris.c
  67. +4 −2 bin/varnishd/mgt/mgt_shmem.c
  68. +29 −10 bin/varnishd/mgt/mgt_vcc.c
  69. +61 −46 bin/varnishd/storage/stevedore.c
  70. +1 −0  bin/varnishd/storage/stevedore_utils.c
  71. +12 −7 bin/varnishd/storage/storage.h
  72. +5 −1 bin/varnishd/storage/storage_file.c
  73. +6 −2 bin/varnishd/storage/storage_malloc.c
  74. +15 −28 bin/varnishd/storage/storage_persistent.c
  75. +2 −3 bin/varnishd/storage/storage_persistent.h
  76. +7 −9 bin/varnishd/storage/storage_persistent_silo.c
  77. +1 −4 bin/varnishd/waiter/cache_waiter.c
  78. +4 −4 bin/varnishd/waiter/cache_waiter_epoll.c
  79. +5 −7 bin/varnishd/waiter/cache_waiter_kqueue.c
  80. +1 −1  bin/varnishd/waiter/cache_waiter_poll.c
  81. +2 −3 bin/varnishd/waiter/cache_waiter_ports.c
  82. +2 −2 bin/varnishd/waiter/mgt_waiter.c
  83. +2 −0  bin/varnishd/waiter/waiter.h
  84. +5 −6 bin/varnishlog/varnishlog.c
  85. +17 −17 bin/varnishncsa/varnishncsa.c
  86. +7 −7 bin/varnishreplay/varnishreplay.c
  87. +1 −1  bin/varnishstat/varnishstat.c
  88. +12 −6 bin/varnishtest/Makefile.am
  89. +1 −1  bin/varnishtest/tests.disabled/t00000.vtc
  90. +4 −2 bin/varnishtest/tests/a00009.vtc
  91. +1 −1  bin/varnishtest/tests/b00000.vtc
  92. +1 −1  bin/varnishtest/tests/b00003.vtc
  93. +2 −2 bin/varnishtest/tests/b00007.vtc
  94. +1 −7 bin/varnishtest/tests/b00008.vtc
  95. +1 −1  bin/varnishtest/tests/b00010.vtc
  96. +1 −1  bin/varnishtest/tests/b00011.vtc
  97. +5 −5 bin/varnishtest/tests/b00012.vtc
  98. +7 −7 bin/varnishtest/tests/b00013.vtc
  99. +5 −5 bin/varnishtest/tests/b00015.vtc
  100. +5 −1 bin/varnishtest/tests/b00020.vtc
  101. +3 −0  bin/varnishtest/tests/b00021.vtc
  102. +3 −0  bin/varnishtest/tests/b00022.vtc
  103. +5 −1 bin/varnishtest/tests/b00027.vtc
  104. +2 −2 bin/varnishtest/tests/c00002.vtc
  105. +1 −0  bin/varnishtest/tests/c00003.vtc
  106. +4 −4 bin/varnishtest/tests/c00004.vtc
  107. +1 −1  bin/varnishtest/tests/c00005.vtc
  108. +2 −2 bin/varnishtest/tests/c00006.vtc
  109. +1 −1  bin/varnishtest/tests/c00008.vtc
  110. +1 −1  bin/varnishtest/tests/c00009.vtc
  111. +3 −3 bin/varnishtest/tests/c00010.vtc
  112. +3 −3 bin/varnishtest/tests/c00011.vtc
  113. +3 −3 bin/varnishtest/tests/c00012.vtc
  114. +9 −4 bin/varnishtest/tests/c00013.vtc
  115. +3 −3 bin/varnishtest/tests/c00014.vtc
  116. +5 −5 bin/varnishtest/tests/c00015.vtc
  117. +5 −5 bin/varnishtest/tests/c00020.vtc
  118. +18 −18 bin/varnishtest/tests/c00023.vtc
  119. +1 −1  bin/varnishtest/tests/c00025.vtc
  120. +1 −1  bin/varnishtest/tests/c00026.vtc
  121. +2 −2 bin/varnishtest/tests/c00033.vtc
  122. +1 −1  bin/varnishtest/tests/c00049.vtc
  123. +6 −0 bin/varnishtest/tests/c00051.vtc
  124. +51 −0 bin/varnishtest/tests/c00052.vtc
  125. +29 −0 bin/varnishtest/tests/c00053.vtc
  126. +32 −0 bin/varnishtest/tests/c00054.vtc
  127. +1 −1  bin/varnishtest/tests/e00000.vtc
  128. +1 −1  bin/varnishtest/tests/e00008.vtc
  129. +0 −1  bin/varnishtest/tests/e00009.vtc
  130. +1 −1  bin/varnishtest/tests/e00019.vtc
  131. +0 −1  bin/varnishtest/tests/e00022.vtc
  132. +1 −1  bin/varnishtest/tests/e00023.vtc
  133. +1 −1  bin/varnishtest/tests/e00024.vtc
  134. +1 −1  bin/varnishtest/tests/e00026.vtc
  135. +4 −1 bin/varnishtest/tests/g00004.vtc
  136. +0 −5 bin/varnishtest/tests/i00001.vtc
  137. +8 −5 bin/varnishtest/tests/m00000.vtc
  138. +3 −3 bin/varnishtest/tests/m00001.vtc
  139. +1 −1  bin/varnishtest/tests/m00003.vtc
  140. +3 −3 bin/varnishtest/tests/m00004.vtc
  141. +23 −0 bin/varnishtest/tests/m00008.vtc
  142. +3 −2 bin/varnishtest/tests/p00000.vtc
  143. +5 −3 bin/varnishtest/tests/p00001.vtc
  144. +1 −1  bin/varnishtest/tests/p00002.vtc
  145. +1 −1  bin/varnishtest/tests/p00003.vtc
  146. +5 −5 bin/varnishtest/tests/p00004.vtc
  147. +3 −1 bin/varnishtest/tests/p00005.vtc
  148. +4 −3 bin/varnishtest/tests/p00006.vtc
  149. +1 −1  bin/varnishtest/tests/r00102.vtc
  150. +1 −1  bin/varnishtest/tests/r00262.vtc
  151. +3 −4 bin/varnishtest/tests/r00306.vtc
  152. +1 −1  bin/varnishtest/tests/r00345.vtc
  153. +1 −1  bin/varnishtest/tests/r00386.vtc
  154. +5 −1 bin/varnishtest/tests/r00387.vtc
  155. +1 −1  bin/varnishtest/tests/r00433.vtc
  156. +4 −2 bin/varnishtest/tests/r00466.vtc
  157. +3 −0  bin/varnishtest/tests/r00702.vtc
  158. +3 −0  bin/varnishtest/tests/r00704.vtc
  159. +3 −0  bin/varnishtest/tests/r00801.vtc
  160. +6 −6 bin/varnishtest/tests/r00878.vtc
  161. +1 −1  bin/varnishtest/tests/r00902.vtc
  162. +0 −1  bin/varnishtest/tests/r00911.vtc
  163. +1 −1  bin/varnishtest/tests/r00913.vtc
  164. +1 −1  bin/varnishtest/tests/r00915.vtc
  165. +1 −1  bin/varnishtest/tests/r00917.vtc
  166. +6 −2 bin/varnishtest/tests/r00942.vtc
  167. +2 −2 bin/varnishtest/tests/r00962.vtc
  168. +8 −0 bin/varnishtest/tests/r01035.vtc
  169. +1 −0  bin/varnishtest/tests/r01036.vtc
  170. +55 −0 bin/varnishtest/tests/r01073.vtc
  171. +36 −0 bin/varnishtest/tests/r01091.vtc
  172. +43 −0 bin/varnishtest/tests/r01109.vtc
  173. +62 −0 bin/varnishtest/tests/r01113.vtc
  174. +24 −0 bin/varnishtest/tests/r01120.vtc
  175. +25 −0 bin/varnishtest/tests/r01123.vtc
  176. +19 −0 bin/varnishtest/tests/r01134.vtc
  177. +39 −0 bin/varnishtest/tests/r01140.vtc
  178. +38 −0 bin/varnishtest/tests/r01144.vtc
  179. +43 −0 bin/varnishtest/tests/r01145.vtc
  180. +53 −0 bin/varnishtest/tests/r01156.vtc
  181. +26 −0 bin/varnishtest/tests/r01157.vtc
  182. +23 −0 bin/varnishtest/tests/r01164.vtc
  183. +26 −0 bin/varnishtest/tests/r01168.vtc
  184. +9 −0 bin/varnishtest/tests/r01169.vtc
  185. +20 −0 bin/varnishtest/tests/r01175.vtc
  186. +14 −0 bin/varnishtest/tests/r01176.vtc
  187. +108 −0 bin/varnishtest/tests/r01184.vtc
  188. +3 −3 bin/varnishtest/tests/s00000.vtc
  189. +3 −3 bin/varnishtest/tests/s00001.vtc
  190. +1 −1  bin/varnishtest/tests/s00002.vtc
  191. +3 −3 bin/varnishtest/tests/v00006.vtc
  192. +6 −6 bin/varnishtest/tests/v00009.vtc
  193. +36 −4 bin/varnishtest/tests/v00010.vtc
  194. +2 −2 bin/varnishtest/tests/v00011.vtc
  195. +0 −2  bin/varnishtest/tests/v00012.vtc
  196. +0 −5 bin/varnishtest/tests/v00018.vtc
  197. +40 −13 bin/varnishtest/vtc.c
  198. +1 −0  bin/varnishtest/vtc.h
  199. +2 −0  bin/varnishtest/vtc_http.c
  200. +5 −4 bin/varnishtest/vtc_log.c
  201. +3 −3 bin/varnishtest/vtc_server.c
  202. +10 −4 bin/varnishtest/vtc_varnish.c
  203. +33 −4 configure.ac
  204. +207 −0 doc/changes.rst
  205. +0 −5 doc/sphinx/Makefile.am
  206. +0 −53 doc/sphinx/faq/configuration.rst
  207. +0 −238 doc/sphinx/faq/general.rst
  208. +0 −55 doc/sphinx/faq/http.rst
  209. +0 −20 doc/sphinx/faq/index.rst
  210. +0 −8 doc/sphinx/faq/logging.rst
  211. +1 −2  doc/sphinx/glossary/index.rst
  212. +0 −1  doc/sphinx/index.rst
  213. +55 −3 doc/sphinx/installation/upgrade.rst
  214. +316 −0 doc/sphinx/phk/http20.rst
  215. +3 −1 doc/sphinx/phk/index.rst
  216. +42 −39 doc/sphinx/reference/varnish-cli.rst
  217. +74 −48 doc/sphinx/reference/varnishd.rst
  218. +2 −2 doc/sphinx/reference/varnishncsa.rst
  219. +3 −2 doc/sphinx/reference/varnishreplay.rst
  220. +50 −27 doc/sphinx/reference/vcl.rst
  221. +7 −2 doc/sphinx/reference/vmod.rst
  222. +25 −26 doc/sphinx/reference/vmod_std.rst
  223. +32 −2 doc/sphinx/tutorial/cookies.rst
  224. +268 −0 doc/sphinx/tutorial/devicedetection.rst
  225. +19 −26 doc/sphinx/tutorial/esi.rst
  226. +1 −1  doc/sphinx/tutorial/increasing_your_hitrate.rst
  227. +3 −1 doc/sphinx/tutorial/index.rst
  228. +1 −1  doc/sphinx/tutorial/logging.rst
  229. +3 −3 doc/sphinx/tutorial/purging.rst
  230. +2 −1  doc/sphinx/tutorial/vcl.rst
  231. +1 −1  doc/sphinx/tutorial/{virtualised.rst → virtualized.rst}
  232. +20 −0 doc/sphinx/tutorial/websockets.rst
  233. +69 −0 etc/devicedetect.vcl
  234. +24 −14 include/Makefile.am
  235. +2 −0  include/libvcl.h
  236. +2 −3 include/tbl/acct_fields.h
  237. +39 −0 include/tbl/debug_bits.h
  238. +43 −0 include/tbl/feature_bits.h
  239. +3 −1 include/tbl/http_headers.h
  240. +43 −0 include/tbl/sess_close.h
  241. +20 −16 include/tbl/steps.h
  242. +46 −46 include/tbl/vsc_f_main.h
  243. +0 −4 include/tbl/vsc_fields.h
  244. +120 −65 include/tbl/vsl_tags.h
  245. +41 −0 include/tbl/vsl_tags_http.h
  246. +1 −1  include/vapi/vsl_int.h
  247. +1 −1  include/vapi/vsm_int.h
  248. +26 −8 include/vas.h
  249. +0 −1  include/vcli_serve.h
  250. +1 −0  include/vcs.h
  251. +25 −26 include/vrt.h
  252. +2 −0  lib/Makefile.am
  253. +3 −1 lib/libvarnish/Makefile.am
  254. +0 −1  lib/libvarnish/cli_serve.c
  255. +12 −4 lib/libvarnish/vas.c
  256. +4 −2 lib/libvarnish/version.c
  257. +46 −11 lib/libvarnish/vre.c
  258. +1 −1  lib/libvarnish/vsha256.c
  259. +6 −1 lib/libvarnish/vss.c
  260. +28 −15 lib/libvarnish/vtcp.c
  261. +3 −1 lib/libvarnishapi/Makefile.am
  262. +0 −2  lib/libvarnishapi/vsc.c
  263. +5 −2 lib/libvarnishapi/vsl.c
  264. +0 −1  lib/libvarnishapi/vsl_api.h
  265. +1 −1  lib/libvarnishapi/vsm.c
  266. +2 −1  lib/libvarnishcompat/Makefile.am
  267. +21 −262 lib/libvarnishcompat/execinfo.c
  268. +6 −1 lib/libvcl/Makefile.am
  269. +75 −74 lib/libvcl/generate.py
  270. +9 −6 lib/libvcl/vcc_acl.c
  271. +11 −25 lib/libvcl/vcc_action.c
  272. +7 −0 lib/libvcl/vcc_backend.c
  273. +28 −4 lib/libvcl/vcc_compile.c
  274. +2 −0  lib/libvcl/vcc_compile.h
  275. +21 −14 lib/libvcl/vcc_expr.c
  276. +25 −11 lib/libvcl/vcc_parse.c
  277. +2 −2 lib/libvcl/vcc_symb.c
  278. +2 −2 lib/libvcl/vcc_var.c
  279. +8 −1 lib/libvcl/vcc_vmod.c
  280. +2 −3 lib/{libvmod_std/vmod.py → libvcl/vmodtool.py}
  281. +2 −1  lib/libvgz/Makefile.am
  282. +26 −0 lib/libvmod_debug/Makefile.am
  283. +33 −0 lib/libvmod_debug/vmod.vcc
  284. +96 −0 lib/libvmod_debug/vmod_debug.c
  285. +7 −4 lib/libvmod_std/Makefile.am
  286. +2 −4 lib/libvmod_std/vmod.vcc
  287. +56 −75 lib/libvmod_std/vmod_std.c
  288. +4 −4 lib/libvmod_std/vmod_std_conversions.c
  289. +9 −5 lib/libvmod_std/vmod_std_fileread.c
  290. +5 −1 redhat/Makefile.am
  291. +35 −0 redhat/varnish.params
  292. +46 −0 redhat/varnish.service
  293. +113 −13 redhat/varnish.spec
  294. +11 −0 redhat/varnishlog.service
  295. +11 −0 redhat/varnishncsa.service
  296. +20 −0 varnishapi-uninstalled.pc.in
  297. +9 −2 varnishapi.pc.in
View
4 INSTALL
@@ -5,8 +5,8 @@ run the 'configure' script in the top-level directory, then run 'make'
and 'make install'. On Linux, you need to run 'ldconfig' as root
afterwards in order to update the shared library cache.
-If you obtained the sources directly from the Subversion repository,
-you will need to run autogen.sh first to create the configure script.
+If you obtained the sources directly from the Git repository, you will
+need to run autogen.sh first to create the configure script.
Varnish will store run-time state in $localstatedir/varnish; you may
want to tune this using configure's --localstatedir parameter.
View
2  Makefile.am
@@ -1,5 +1,3 @@
-#
-
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = include lib bin man etc doc
View
4 autogen.des
@@ -9,6 +9,10 @@ make -k distclean > /dev/null 2>&1 || true
# Prefer CLANG if we have it, and have not given preferences
if [ -f /usr/bin/clang -a "x${CC}" = "x" ] ; then
CC=clang
+
+ # XXX: clang complains about -g in linker invocations
+ # XXX: so fall back to gcc for now...
+ CC=gcc
export CC
fi
View
3  autogen.sh
@@ -12,6 +12,9 @@ Darwin)
FreeBSD)
LIBTOOLIZE=libtoolize
;;
+OpenBSD)
+ LIBTOOLIZE=libtoolize
+ ;;
Linux)
LIBTOOLIZE=libtoolize
;;
View
32 bin/varnishadm/varnishadm.c
@@ -29,11 +29,18 @@
#include "config.h"
+#include <sys/types.h>
#include <sys/socket.h>
#ifdef HAVE_LIBEDIT
-#include <stdio.h>
-#include <editline/readline.h>
+# include <stdio.h>
+# ifdef HAVE_EDIT_READLINE_READLINE_H
+# include <edit/readline/readline.h>
+# elif HAVE_READLINE_READLINE_H
+# include <readline/readline.h>
+# else
+# include <editline/readline.h>
+# endif
#endif
#include <errno.h>
@@ -291,20 +298,19 @@ n_arg_sock(const char *n_arg)
fprintf(stderr, "%s\n", VSM_Error(vsd));
return (-1);
}
- if (T_arg == NULL) {
- if (VSM_Get(vsd, &vt, "Arg", "-T", "")) {
- fprintf(stderr, "No -T arg in shared memory\n");
- return (-1);
- }
- T_start = T_arg = strdup(vt.b);
+
+ if (!VSM_Get(vsd, &vt, "Arg", "-T", "")) {
+ fprintf(stderr, "No -T arg in shared memory\n");
+ return (-1);
}
- if (S_arg == NULL) {
- if (VSM_Get(vsd, &vt, "Arg", "-S", "")) {
- fprintf(stderr, "No -S arg in shared memory\n");
- return (-1);
- }
+ AN(vt.b);
+ T_start = T_arg = strdup(vt.b);
+
+ if (VSM_Get(vsd, &vt, "Arg", "-S", "")) {
+ AN(vt.b);
S_arg = strdup(vt.b);
}
+
sock = -1;
while (*T_arg) {
p = strchr(T_arg, '\n');
View
14 bin/varnishd/Makefile.am
@@ -17,7 +17,6 @@ varnishd_SOURCES = \
cache/cache_backend_poll.c \
cache/cache_ban.c \
cache/cache_busyobj.c \
- cache/cache_center.c \
cache/cache_cli.c \
cache/cache_dir.c \
cache/cache_dir_dns.c \
@@ -31,6 +30,7 @@ varnishd_SOURCES = \
cache/cache_gzip.c \
cache/cache_hash.c \
cache/cache_http.c \
+ cache/cache_http1_fsm.c \
cache/cache_httpconn.c \
cache/cache_lck.c \
cache/cache_main.c \
@@ -38,6 +38,7 @@ varnishd_SOURCES = \
cache/cache_panic.c \
cache/cache_pipe.c \
cache/cache_pool.c \
+ cache/cache_req_fsm.c \
cache/cache_response.c \
cache/cache_rfc2616.c \
cache/cache_session.c \
@@ -60,6 +61,7 @@ varnishd_SOURCES = \
mgt/mgt_cli.c \
mgt/mgt_main.c \
mgt/mgt_param.c \
+ mgt/mgt_param_bits.c \
mgt/mgt_pool.c \
mgt/mgt_sandbox.c \
mgt/mgt_sandbox_solaris.c \
@@ -84,12 +86,9 @@ varnishd_SOURCES = \
waiter/cache_waiter_ports.c
noinst_HEADERS = \
- cache/cache.h \
cache/cache_backend.h \
cache/cache_esi.h \
- common/common.h \
common/heritage.h \
- common/params.h \
default_vcl.h \
hash/hash_slinger.h \
mgt/mgt.h \
@@ -99,6 +98,13 @@ noinst_HEADERS = \
storage/storage_persistent.h \
waiter/waiter.h
+# Headers for use with vmods
+pkgdataincludedir = $(pkgdatadir)/include
+nobase_pkgdatainclude_HEADERS = \
+ cache/cache.h \
+ common/common.h \
+ common/params.h
+
varnishd_CFLAGS = \
@PCRE_CFLAGS@ \
-DVARNISH_STATE_DIR='"${VARNISH_STATE_DIR}"' \
View
329 bin/varnishd/cache/cache.h
@@ -75,6 +75,30 @@ body_status(enum body_status e)
}
}
+/*--------------------------------------------------------------------*/
+
+enum sess_close {
+ SC_NULL = 0,
+#define SESS_CLOSE(nm, desc) SC_##nm,
+#include "tbl/sess_close.h"
+#undef SESS_CLOSE
+};
+
+static inline const char *
+sess_close_str(enum sess_close sc, int want_desc)
+{
+ switch (sc) {
+ case SC_NULL: return(want_desc ? "(null)": "NULL");
+#define SESS_CLOSE(nm, desc) case SC_##nm: return(want_desc ? desc : #nm);
+#include "tbl/sess_close.h"
+#undef SESS_CLOSE
+
+ default: return(want_desc ? "(invalid)" : "INVALID");
+ }
+}
+
+/*--------------------------------------------------------------------*/
+
/*
* NB: HDR_STATUS is only used in cache_http.c, everybody else uses the
* http->status integer field.
@@ -82,13 +106,9 @@ body_status(enum body_status e)
enum {
/* Fields from the first line of HTTP proto */
- HTTP_HDR_REQ,
- HTTP_HDR_URL,
- HTTP_HDR_PROTO,
- HTTP_HDR_STATUS,
- HTTP_HDR_RESPONSE,
- /* HTTP header lines */
- HTTP_HDR_FIRST,
+#define SLTH(aa, bb) bb,
+#include "tbl/vsl_tags_http.h"
+#undef SLTH
};
struct SHA256Context;
@@ -108,7 +128,6 @@ struct poolparam;
struct sess;
struct sesspool;
struct vbc;
-struct vbo;
struct vef_priv;
struct vrt_backend;
struct vsb;
@@ -127,10 +146,16 @@ typedef struct {
/*--------------------------------------------------------------------*/
-enum step {
-#define STEP(l, u, arg) STP_##u,
+enum sess_step {
+#define SESS_STEP(l, u) S_STP_##u,
+#include "tbl/steps.h"
+#undef SESS_STEP
+};
+
+enum req_step {
+#define REQ_STEP(l, u, arg) R_STP_##u,
#include "tbl/steps.h"
-#undef STEP
+#undef REQ_STEP
};
/*--------------------------------------------------------------------*/
@@ -146,7 +171,7 @@ struct ws {
unsigned overflow; /* workspace overflowed */
const char *id; /* identity */
char *s; /* (S)tart of buffer */
- char *f; /* (F)ree pointer */
+ char *f; /* (F)ree/front pointer */
char *r; /* (R)eserved length */
char *e; /* (E)nd of buffer */
};
@@ -156,9 +181,11 @@ struct ws {
*/
enum httpwhence {
- HTTP_Rx = 1,
- HTTP_Tx = 2,
- HTTP_Obj = 3
+ HTTP_Req = 1,
+ HTTP_Resp,
+ HTTP_Bereq,
+ HTTP_Beresp,
+ HTTP_Obj
};
/* NB: remember to update http_Copy() if you add fields */
@@ -219,6 +246,8 @@ struct dstat {
/* Fetch processors --------------------------------------------------*/
+void VFP_update_length(const struct busyobj *, ssize_t);
+
typedef void vfp_begin_f(struct busyobj *, size_t );
typedef int vfp_bytes_f(struct busyobj *, struct http_conn *, ssize_t);
typedef int vfp_end_f(struct busyobj *);
@@ -254,7 +283,7 @@ struct vsl_log {
/*--------------------------------------------------------------------*/
-struct vxid {
+struct vxid_pool {
uint32_t next;
uint32_t count;
};
@@ -270,7 +299,6 @@ struct wrk_accept {
socklen_t acceptaddrlen;
int acceptsock;
struct listen_sock *acceptlsock;
- uint32_t vxid;
};
/* Worker pool stuff -------------------------------------------------*/
@@ -298,7 +326,7 @@ struct worker {
struct objhead *nobjhead;
struct objcore *nobjcore;
struct waitinglist *nwaitinglist;
- struct vbo *nvbo;
+ struct busyobj *nbo;
void *nhashpriv;
struct dstat stats;
@@ -310,18 +338,12 @@ struct worker {
pthread_cond_t cond;
- struct sess *sp;
-
struct VCL_conf *vcl;
- struct vsl_log vsl[1];
-
struct ws aws[1];
- struct busyobj *busyobj;
+ struct vxid_pool vxid_pool;
- /* Temporary accounting */
- struct acct acct_tmp;
};
/* LRU ---------------------------------------------------------------*/
@@ -377,7 +399,7 @@ struct objcore {
int refcnt;
struct objcore_methods *methods;
void *priv;
- unsigned priv2;
+ uintptr_t priv2;
struct objhead *objhead;
struct busyobj *busyobj;
double timer_when;
@@ -454,10 +476,24 @@ oc_getlru(const struct objcore *oc)
* streaming delivery will make use of.
*/
+enum busyobj_state_e {
+ BOS_INVALID = 0,
+ BOS_FETCHING,
+ BOS_FAILED,
+ BOS_FINISHED
+};
+
struct busyobj {
unsigned magic;
#define BUSYOBJ_MAGIC 0x23b95567
- struct vbo *vbo;
+ struct lock mtx;
+ char *end;
+
+ /*
+ * All fields from refcount and down are zeroed when the busyobj
+ * is recycled.
+ */
+ unsigned refcount;
uint8_t *vary;
unsigned is_gzip;
@@ -465,7 +501,7 @@ struct busyobj {
struct vfp *vfp;
struct vep_state *vep;
- unsigned fetch_failed;
+ enum busyobj_state_e state;
struct vgz *vgz_rx;
struct ws ws[1];
@@ -478,6 +514,8 @@ struct busyobj {
struct http_conn htc;
enum body_status body_status;
+ struct pool_task fetch_task;
+
struct vef_priv *vef_priv;
unsigned should_close;
@@ -505,7 +543,7 @@ VTAILQ_HEAD(storagehead, storage);
struct object {
unsigned magic;
#define OBJECT_MAGIC 0x32851d42
- unsigned xid;
+ uint32_t vxid;
struct storage *objstore;
struct objcore *objcore;
@@ -545,15 +583,20 @@ struct req {
unsigned magic;
#define REQ_MAGIC 0x2751aaa1
- unsigned xid;
int restarts;
int esi_level;
int disable_esi;
uint8_t hash_ignore_busy;
uint8_t hash_always_miss;
+ struct sess *sp;
+ struct worker *wrk;
+ enum req_step req_step;
+ VTAILQ_ENTRY(req) w_list;
+
/* The busy objhead we sleep on */
struct objhead *hash_objhead;
+ struct busyobj *busyobj;
/* Built Vary string */
uint8_t *vary_b;
@@ -562,7 +605,7 @@ struct req {
unsigned char digest[DIGEST_LEN];
- const char *doclose;
+ enum sess_close doclose;
struct exp exp;
unsigned cur_method;
unsigned handling;
@@ -578,6 +621,7 @@ struct req {
uint64_t req_bodybytes;
char *ws_req; /* WS above request data */
+ double t_req;
double t_resp;
struct http_conn htc[1];
@@ -613,6 +657,8 @@ struct req {
/* Transaction VSL buffer */
struct vsl_log vsl[1];
+ /* Temporary accounting */
+ struct acct acct_req;
};
/*--------------------------------------------------------------------
@@ -629,17 +675,14 @@ struct sess {
unsigned magic;
#define SESS_MAGIC 0x2c2f9c5a
- enum step step;
+ enum sess_step sess_step;
int fd;
- unsigned vsl_id;
+ enum sess_close reason;
uint32_t vxid;
- uint32_t vseq;
/* Cross references ------------------------------------------*/
struct sesspool *sesspool;
- struct worker *wrk;
- struct req *req;
struct pool_task task;
VTAILQ_ENTRY(sess) list;
@@ -650,7 +693,6 @@ struct sess {
socklen_t mysockaddrlen;
struct sockaddr_storage sockaddr;
struct sockaddr_storage mysockaddr;
- struct listen_sock *mylsock;
/* formatted ascii client address */
char addr[ADDR_BUFSIZE];
@@ -661,7 +703,6 @@ struct sess {
/* Timestamps, all on TIM_real() timescale */
double t_open; /* fd accepted */
double t_idle; /* fd accepted or resp sent */
- double t_req;
#if defined(HAVE_EPOLL_CTL)
struct epoll_event ev;
@@ -674,16 +715,18 @@ struct sess {
void VCA_Init(void);
void VCA_Shutdown(void);
int VCA_Accept(struct listen_sock *ls, struct wrk_accept *wa);
-void VCA_SetupSess(struct worker *w);
+const char *VCA_SetupSess(struct worker *w, struct sess *sp);
void VCA_FailSess(struct worker *w);
/* cache_backend.c */
void VBE_UseHealth(const struct director *vdi);
+void VBE_DiscardHealth(const struct director *vdi);
-struct vbc *VDI_GetFd(const struct director *, struct sess *sp);
-int VDI_Healthy(const struct director *, const struct sess *sp);
-void VDI_CloseFd(struct worker *wrk, struct vbc **vbp);
-void VDI_RecycleFd(struct worker *wrk, struct vbc **vbp);
+
+struct vbc *VDI_GetFd(const struct director *, struct req *);
+int VDI_Healthy(const struct director *, const struct req *);
+void VDI_CloseFd(struct vbc **vbp);
+void VDI_RecycleFd(struct vbc **vbp);
void VDI_AddHostHeader(struct http *to, const struct vbc *vbc);
void VBE_Poll(void);
void VDI_Init(void);
@@ -704,7 +747,7 @@ void BAN_Insert(struct ban *b);
void BAN_Init(void);
void BAN_NewObjCore(struct objcore *oc);
void BAN_DestroyObj(struct objcore *oc);
-int BAN_CheckObject(struct object *o, const struct sess *sp);
+int BAN_CheckObject(struct object *o, struct req *sp);
void BAN_Reload(const uint8_t *ban, unsigned len);
struct ban *BAN_TailRef(void);
void BAN_Compile(void);
@@ -715,13 +758,14 @@ double BAN_Time(const struct ban *ban);
/* cache_busyobj.c */
void VBO_Init(void);
struct busyobj *VBO_GetBusyObj(struct worker *wrk);
-void VBO_RefBusyObj(const struct busyobj *busyobj);
void VBO_DerefBusyObj(struct worker *wrk, struct busyobj **busyobj);
-void VBO_Free(struct vbo **vbo);
+void VBO_Free(struct busyobj **vbo);
+
+/* cache_http1_fsm.c [HTTP1] */
+void HTTP1_Session(struct worker *, struct req *);
-/* cache_center.c [CNT] */
-void CNT_Session(struct sess *sp);
-void CNT_Init(void);
+/* cache_req_fsm.c [CNT] */
+int CNT_Request(struct worker *, struct req *);
/* cache_cli.c [CLI] */
void CLI_Init(void);
@@ -739,9 +783,9 @@ void EXP_Set_ttl(struct exp *e, double v);
void EXP_Set_grace(struct exp *e, double v);
void EXP_Set_keep(struct exp *e, double v);
-double EXP_Ttl(const struct sess *, const struct object*);
-double EXP_Grace(const struct sess *, const struct object*);
-double EXP_Keep(const struct sess *, const struct object*);
+double EXP_Ttl(const struct req *, const struct object*);
+double EXP_Grace(const struct req *, const struct object*);
+double EXP_Keep(const struct req *, const struct object*);
void EXP_Insert(struct object *o);
void EXP_Inject(struct objcore *oc, struct lru *lru, double when);
void EXP_Init(void);
@@ -753,14 +797,21 @@ int EXP_NukeOne(struct busyobj *, struct lru *lru);
struct storage *FetchStorage(struct busyobj *, ssize_t sz);
int FetchError(struct busyobj *, const char *error);
int FetchError2(struct busyobj *, const char *error, const char *more);
-int FetchHdr(struct sess *sp, int need_host_hdr, int sendbody);
-int FetchBody(struct worker *w, struct object *obj);
-int FetchReqBody(const struct sess *sp, int sendbody);
+int FetchHdr(struct req *req, int need_host_hdr, int sendbody);
+void FetchBody(struct worker *w, void *bo);
+int FetchReqBody(struct req *, int sendbody);
void Fetch_Init(void);
/* cache_gzip.c */
struct vgz;
+enum vgzret_e {
+ VGZ_ERROR = -1,
+ VGZ_OK = 0,
+ VGZ_END = 1,
+ VGZ_STUCK = 2,
+};
+
enum vgz_flag { VGZ_NORMAL, VGZ_ALIGN, VGZ_RESET, VGZ_FINISH };
struct vgz *VGZ_NewUngzip(struct vsl_log *vsl, const char *id);
struct vgz *VGZ_NewGzip(struct vsl_log *vsl, const char *id);
@@ -769,21 +820,15 @@ int VGZ_IbufEmpty(const struct vgz *vg);
void VGZ_Obuf(struct vgz *, void *, ssize_t len);
int VGZ_ObufFull(const struct vgz *vg);
int VGZ_ObufStorage(struct busyobj *, struct vgz *vg);
-int VGZ_Gzip(struct vgz *, const void **, size_t *len, enum vgz_flag);
-int VGZ_Gunzip(struct vgz *, const void **, size_t *len);
-int VGZ_Destroy(struct vgz **);
+enum vgzret_e VGZ_Gzip(struct vgz *, const void **, size_t *len, enum vgz_flag);
+enum vgzret_e VGZ_Gunzip(struct vgz *, const void **, size_t *len);
+enum vgzret_e VGZ_Destroy(struct vgz **);
void VGZ_UpdateObj(const struct vgz*, struct object *);
int VGZ_WrwInit(struct vgz *vg);
-int VGZ_WrwGunzip(struct worker *w, struct vgz *, const void *ibuf,
+enum vgzret_e VGZ_WrwGunzip(struct req *, struct vgz *, const void *ibuf,
ssize_t ibufl);
-void VGZ_WrwFlush(struct worker *wrk, struct vgz *vg);
-
-/* Return values */
-#define VGZ_ERROR -1
-#define VGZ_OK 0
-#define VGZ_END 1
-#define VGZ_STUCK 2
+void VGZ_WrwFlush(struct req *, struct vgz *vg);
/* cache_http.c */
unsigned HTTP_estimate(unsigned nhttp);
@@ -793,17 +838,17 @@ const char *http_StatusMessage(unsigned);
unsigned http_EstimateWS(const struct http *fm, unsigned how, uint16_t *nhd);
void HTTP_Init(void);
void http_ClrHeader(struct http *to);
-unsigned http_Write(struct worker *w, const struct http *hp, int resp);
+unsigned http_Write(const struct worker *w, const struct http *hp, int resp);
void http_SetResp(struct http *to, const char *proto, uint16_t status,
const char *response);
-void http_FilterReq(const struct sess *sp, unsigned how);
+void http_FilterReq(const struct req *, unsigned how);
void http_FilterResp(const struct http *fm, struct http *to, unsigned how);
void http_PutProtocol(const struct http *to, const char *protocol);
/* Check if a refresh should be done */
void http_CheckRefresh(struct busyobj *busyobj);
/* Check if we got 304 response */
-void http_Check304(struct worker *wrk);
+void http_Check304(struct worker *wrk, struct busyobj *busyobj);
void http_PutStatus(struct http *to, uint16_t status);
void http_PutResponse(const struct http *to, const char *response);
@@ -812,7 +857,7 @@ void http_PrintfHeader(struct http *to, const char *fmt, ...)
void http_SetHeader(struct http *to, const char *hdr);
void http_SetH(const struct http *to, unsigned n, const char *fm);
void http_ForceGet(const struct http *to);
-void http_Setup(struct http *ht, struct ws *ws, struct vsl_log *);
+void HTTP_Setup(struct http *, struct ws *, struct vsl_log *, enum httpwhence);
void http_Teardown(struct http *ht);
int http_GetHdr(const struct http *hp, const char *hdr, char **ptr);
int http_GetHdrData(const struct http *hp, const char *hdr,
@@ -823,32 +868,40 @@ double http_GetHdrQ(const struct http *hp, const char *hdr, const char *field);
uint16_t http_GetStatus(const struct http *hp);
const char *http_GetReq(const struct http *hp);
int http_HdrIs(const struct http *hp, const char *hdr, const char *val);
-uint16_t http_DissectRequest(const struct sess *sp);
+uint16_t http_DissectRequest(struct req *);
uint16_t http_DissectResponse(struct http *sp, const struct http_conn *htc);
-const char *http_DoConnection(const struct http *hp);
+enum sess_close http_DoConnection(const struct http *);
void http_CopyHome(const struct http *hp);
void http_Unset(struct http *hp, const char *hdr);
void http_CollectHdr(struct http *hp, const char *hdr);
/* cache_httpconn.c */
+enum htc_status_e {
+ HTC_ALL_WHITESPACE = -3,
+ HTC_OVERFLOW = -2,
+ HTC_ERROR_EOF = -1,
+ HTC_NEED_MORE = 0,
+ HTC_COMPLETE = 1
+};
+
void HTC_Init(struct http_conn *htc, struct ws *ws, int fd, struct vsl_log *,
unsigned maxbytes, unsigned maxhdr);
-int HTC_Reinit(struct http_conn *htc);
-int HTC_Rx(struct http_conn *htc);
+enum htc_status_e HTC_Reinit(struct http_conn *htc);
+enum htc_status_e HTC_Rx(struct http_conn *htc);
ssize_t HTC_Read(struct http_conn *htc, void *d, size_t len);
-int HTC_Complete(struct http_conn *htc);
+enum htc_status_e HTC_Complete(struct http_conn *htc);
#define HTTPH(a, b, c) extern char b[];
#include "tbl/http_headers.h"
#undef HTTPH
/* cache_main.c */
-uint32_t VXID_Get(struct vxid *v);
+uint32_t VXID_Get(struct vxid_pool *v);
extern volatile struct params * cache_param;
void THR_SetName(const char *name);
const char* THR_GetName(void);
-void THR_SetSession(const struct sess *sp);
-const struct sess * THR_GetSession(void);
+void THR_SetRequest(const struct req *);
+const struct req * THR_GetRequest(void);
/* cache_lck.c */
@@ -886,7 +939,7 @@ void MPL_Free(struct mempool *mpl, void *item);
void PAN_Init(void);
/* cache_pipe.c */
-void PipeSession(struct sess *sp);
+void PipeRequest(struct req *req);
/* cache_pool.c */
void Pool_Init(void);
@@ -895,25 +948,24 @@ int Pool_Task(struct pool *pp, struct pool_task *task, enum pool_how how);
#define WRW_IsReleased(w) ((w)->wrw == NULL)
int WRW_Error(const struct worker *w);
-void WRW_Chunked(struct worker *w);
-void WRW_EndChunk(struct worker *w);
-void WRW_Reserve(struct worker *w, int *fd);
-unsigned WRW_Flush(struct worker *w);
+void WRW_Chunked(const struct worker *w);
+void WRW_EndChunk(const struct worker *w);
+void WRW_Reserve(struct worker *w, int *fd, struct vsl_log *, double t0);
+unsigned WRW_Flush(const struct worker *w);
unsigned WRW_FlushRelease(struct worker *w);
-unsigned WRW_Write(struct worker *w, const void *ptr, int len);
-unsigned WRW_WriteH(struct worker *w, const txt *hh, const char *suf);
+unsigned WRW_Write(const struct worker *w, const void *ptr, int len);
+unsigned WRW_WriteH(const struct worker *w, const txt *hh, const char *suf);
/* cache_session.c [SES] */
-struct sess *SES_Alloc(void);
-void SES_Close(struct sess *sp, const char *reason);
-void SES_Delete(struct sess *sp, const char *reason, double now);
-void SES_Charge(struct sess *sp);
+void SES_Close(struct sess *sp, enum sess_close reason);
+void SES_Delete(struct sess *sp, enum sess_close reason, double now);
+void SES_Charge(struct worker *, struct req *);
struct sesspool *SES_NewPool(struct pool *pp, unsigned pool_no);
void SES_DeletePool(struct sesspool *sp);
-int SES_Schedule(struct sess *sp);
+int SES_ScheduleReq(struct req *);
+struct req *SES_GetReq(struct worker *, struct sess *);
void SES_Handle(struct sess *sp, double now);
-void SES_GetReq(struct sess *sp);
-void SES_ReleaseReq(struct sess *sp);
+void SES_ReleaseReq(struct req *);
pool_func_t SES_pool_accept_task;
/* cache_shmlog.c */
@@ -924,45 +976,25 @@ void *VSM_Alloc(unsigned size, const char *class, const char *type,
void VSL_Setup(struct vsl_log *vsl, void *ptr, size_t len);
void VSM_Free(void *ptr);
#ifdef VSL_ENDMARKER
-void VSL(enum VSL_tag_e tag, int id, const char *fmt, ...)
+void VSL(enum VSL_tag_e tag, uint32_t vxid, const char *fmt, ...)
__printflike(3, 4);
-void WSLR(struct vsl_log *, enum VSL_tag_e tag, int id, txt t);
-void WSL(struct vsl_log *, enum VSL_tag_e tag, int id, const char *fmt, ...)
- __printflike(4, 5);
-void VSLB(struct busyobj *, enum VSL_tag_e tag, const char *fmt, ...)
+void VSLb(struct vsl_log *, enum VSL_tag_e tag, const char *fmt, ...)
__printflike(3, 4);
+void VSLbt(struct vsl_log *, enum VSL_tag_e tag, txt t);
-void WSL_Flush(struct vsl_log *, int overflow);
-
-#define DSL(flag, tag, id, ...) \
- do { \
- if (cache_param->diag_bitmap & (flag)) \
- VSL((tag), (id), __VA_ARGS__); \
- } while (0)
-
-#define WSP(sess, tag, ...) \
- WSL((sess)->wrk->vsl, tag, (sess)->vsl_id, __VA_ARGS__)
-
-#define WSPR(sess, tag, txt) \
- WSLR((sess)->wrk->vsl, tag, (sess)->vsl_id, txt)
+void VSL_Flush(struct vsl_log *, int overflow);
-#define INCOMPL() do { \
- VSL(SLT_Debug, 0, "INCOMPLETE AT: %s(%d)", __func__, __LINE__); \
- fprintf(stderr, \
- "INCOMPLETE AT: %s(%d)\n", \
- (const char *)__func__, __LINE__); \
- abort(); \
- } while (0)
#endif
/* cache_response.c */
-void RES_BuildHttp(const struct sess *sp);
-void RES_WriteObj(struct sess *sp);
+void RES_BuildHttp(struct req *);
+void RES_WriteObj(struct req *);
/* cache_vary.c */
-struct vsb *VRY_Create(const struct sess *sp, const struct http *hp);
-int VRY_Match(const struct sess *sp, const uint8_t *vary);
+struct vsb *VRY_Create(struct req *sp, const struct http *hp);
+int VRY_Match(struct req *, const uint8_t *vary);
void VRY_Validate(const uint8_t *vary);
+void VRY_Prep(struct req *);
/* cache_vcl.c */
void VCL_Init(void);
@@ -971,7 +1003,7 @@ void VCL_Rel(struct VCL_conf **vcc);
void VCL_Poll(void);
const char *VCL_Return_Name(unsigned method);
-#define VCL_MET_MAC(l,u,b) void VCL_##l##_method(struct sess *);
+#define VCL_MET_MAC(l,u,b) void VCL_##l##_method(struct req *);
#include "tbl/vcl_returns.h"
#undef VCL_MET_MAC
@@ -980,8 +1012,8 @@ const char *VCL_Return_Name(unsigned method);
char *VRT_String(struct ws *ws, const char *h, const char *p, va_list ap);
char *VRT_StringList(char *d, unsigned dl, const char *p, va_list ap);
-void ESI_Deliver(struct sess *);
-void ESI_DeliverChild(const struct sess *);
+void ESI_Deliver(struct req *);
+void ESI_DeliverChild(struct req *);
/* cache_vrt_vmod.c */
void VMOD_Init(void);
@@ -997,7 +1029,7 @@ void WRK_Init(void);
int WRK_TrySumStat(struct worker *w);
void WRK_SumStat(struct worker *w);
void *WRK_thread(void *priv);
-typedef void *bgthread_t(struct sess *, void *priv);
+typedef void *bgthread_t(struct worker *, void *priv);
void WRK_BgThread(pthread_t *thr, const char *name, bgthread_t *func,
void *priv);
@@ -1013,16 +1045,16 @@ char *WS_Alloc(struct ws *ws, unsigned bytes);
char *WS_Snapshot(struct ws *ws);
/* rfc2616.c */
-void RFC2616_Ttl(const struct sess *sp);
-enum body_status RFC2616_Body(const struct sess *sp);
-unsigned RFC2616_Req_Gzip(const struct sess *sp);
-int RFC2616_Do_Cond(const struct sess *sp);
+void RFC2616_Ttl(struct busyobj *);
+enum body_status RFC2616_Body(struct busyobj *, struct dstat *);
+unsigned RFC2616_Req_Gzip(const struct http *);
+int RFC2616_Do_Cond(const struct req *sp);
/* stevedore.c */
-struct object *STV_NewObject(struct worker *wrk, const char *hint, unsigned len,
- uint16_t nhttp);
+struct object *STV_NewObject(struct busyobj *, struct objcore **,
+ const char *hint, unsigned len, uint16_t nhttp);
struct storage *STV_alloc(struct busyobj *, size_t size);
-void STV_trim(struct storage *st, size_t size);
+void STV_trim(struct storage *st, size_t size, int move_ok);
void STV_free(struct storage *st);
void STV_open(void);
void STV_close(void);
@@ -1087,23 +1119,28 @@ Tadd(txt *t, const char *p, int l)
}
}
-static inline void
-AssertOCBusy(const struct objcore *oc)
+/*
+ * We want to cache the most recent timestamp in wrk->lastused to avoid
+ * extra timestamps in cache_pool.c. Hide this detail with a macro
+ */
+#define W_TIM_real(w) ((w)->lastused = VTIM_real())
+
+static inline int
+FEATURE(enum feature_bits x)
{
- AN(oc);
- AN (oc->flags & OC_F_BUSY);
- AN(oc->busyobj);
+ return (cache_param->feature_bits[(unsigned)x>>3] &
+ (0x80U >> ((unsigned)x & 7)));
}
-static inline void
-AssertObjCorePassOrBusy(const struct objcore *oc)
+static inline int
+DO_DEBUG(enum debug_bits x)
{
- if (oc != NULL)
- AN (oc->flags & OC_F_BUSY);
+ return (cache_param->debug_bits[(unsigned)x>>3] &
+ (0x80U >> ((unsigned)x & 7)));
}
-/*
- * We want to cache the most recent timestamp in wrk->lastused to avoid
- * extra timestamps in cache_pool.c. Hide this detail with a macro
- */
-#define W_TIM_real(w) ((w)->lastused = VTIM_real())
+#define DSL(debug_bit, id, ...) \
+ do { \
+ if (DO_DEBUG(debug_bit)) \
+ VSL(SLT_Debug, (id), __VA_ARGS__); \
+ } while (0)
View
30 bin/varnishd/cache/cache_acceptor.c
@@ -172,6 +172,8 @@ vca_pace_good(void)
/*--------------------------------------------------------------------
* Accept on a listen socket, and handle error returns.
+ *
+ * Called from a worker thread from a pool
*/
int
@@ -229,39 +231,34 @@ VCA_FailSess(struct worker *wrk)
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CAST_OBJ_NOTNULL(wa, (void*)wrk->aws->f, WRK_ACCEPT_MAGIC);
- AZ(wrk->sp);
AZ(close(wa->acceptsock));
wrk->stats.sess_drop++;
vca_pace_bad();
+ WS_Release(wrk->aws, 0);
}
/*--------------------------------------------------------------------
* We have allocated a session, move our info into it.
*/
-void
-VCA_SetupSess(struct worker *wrk)
+const char *
+VCA_SetupSess(struct worker *wrk, struct sess *sp)
{
- struct sess *sp;
struct wrk_accept *wa;
+ const char *retval;
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
- CAST_OBJ_NOTNULL(wa, (void*)wrk->aws->f, WRK_ACCEPT_MAGIC);
- sp = wrk->sp;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- sp->vxid = wa->vxid;
- sp->vseq = 0;
+ CAST_OBJ_NOTNULL(wa, (void*)wrk->aws->f, WRK_ACCEPT_MAGIC);
sp->fd = wa->acceptsock;
- sp->vsl_id = wa->acceptsock | VSL_CLIENTMARKER ;
wa->acceptsock = -1;
- sp->t_open = VTIM_real();
- sp->mylsock = wa->acceptlsock;
- CHECK_OBJ_NOTNULL(sp->mylsock, LISTEN_SOCK_MAGIC);
+ retval = wa->acceptlsock->name;
assert(wa->acceptaddrlen <= sp->sockaddrlen);
memcpy(&sp->sockaddr, &wa->acceptaddr, wa->acceptaddrlen);
sp->sockaddrlen = wa->acceptaddrlen;
vca_pace_good();
wrk->stats.sess_conn++;
+ WS_Release(wrk->aws, 0);
if (need_test)
sock_test(sp->fd);
@@ -278,6 +275,7 @@ VCA_SetupSess(struct worker *wrk)
VTCP_Assert(setsockopt(sp->fd, SOL_SOCKET, SO_RCVTIMEO,
&tv_rcvtimeo, sizeof tv_rcvtimeo));
#endif
+ return (retval);
}
/*--------------------------------------------------------------------*/
@@ -293,6 +291,7 @@ vca_acct(void *arg)
#endif
struct listen_sock *ls;
double t0, now;
+ int i;
THR_SetName("cache-acceptor");
(void)arg;
@@ -303,6 +302,13 @@ vca_acct(void *arg)
AZ(listen(ls->sock, cache_param->listen_depth));
AZ(setsockopt(ls->sock, SOL_SOCKET, SO_LINGER,
&linger, sizeof linger));
+ if (cache_param->accept_filter) {
+ i = VTCP_filter_http(ls->sock);
+ if (i)
+ VSL(SLT_Error, ls->sock,
+ "Kernel filtering: sock=%d, ret=%d %s\n",
+ ls->sock, i, strerror(errno));
+ }
}
hack_ready = 1;
View
106 bin/varnishd/cache/cache_backend.c
@@ -87,10 +87,10 @@ VBE_ReleaseConn(struct vbc *vc)
MPL_Free(vbcpool, vc);
}
-#define FIND_TMO(tmx, dst, sp, be) \
+#define FIND_TMO(tmx, dst, req, be) \
do { \
- CHECK_OBJ_NOTNULL(sp->wrk->busyobj, BUSYOBJ_MAGIC); \
- dst = sp->wrk->busyobj->tmx; \
+ CHECK_OBJ_NOTNULL(req->busyobj, BUSYOBJ_MAGIC); \
+ dst = req->busyobj->tmx; \
if (dst == 0.0) \
dst = be->tmx; \
if (dst == 0.0) \
@@ -107,20 +107,20 @@ VBE_ReleaseConn(struct vbc *vc)
*/
static int
-vbe_TryConnect(const struct sess *sp, int pf, const struct sockaddr_storage *sa,
+vbe_TryConnect(const struct req *req, int pf, const struct sockaddr_storage *sa,
socklen_t salen, const struct vdi_simple *vs)
{
int s, i, tmo;
double tmod;
- CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+ CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
CHECK_OBJ_NOTNULL(vs, VDI_SIMPLE_MAGIC);
s = socket(pf, SOCK_STREAM, 0);
if (s < 0)
return (s);
- FIND_TMO(connect_timeout, tmod, sp, vs->vrt);
+ FIND_TMO(connect_timeout, tmod, req, vs->vrt);
tmo = (int)(tmod * 1000.0);
@@ -137,7 +137,7 @@ vbe_TryConnect(const struct sess *sp, int pf, const struct sockaddr_storage *sa,
/*--------------------------------------------------------------------*/
static void
-bes_conn_try(const struct sess *sp, struct vbc *vc, const struct vdi_simple *vs)
+bes_conn_try(struct req *req, struct vbc *vc, const struct vdi_simple *vs)
{
int s;
struct backend *bp = vs->backend;
@@ -157,17 +157,17 @@ bes_conn_try(const struct sess *sp, struct vbc *vc, const struct vdi_simple *vs)
/* release lock during stuff that can take a long time */
if (cache_param->prefer_ipv6 && bp->ipv6 != NULL) {
- s = vbe_TryConnect(sp, PF_INET6, bp->ipv6, bp->ipv6len, vs);
+ s = vbe_TryConnect(req, PF_INET6, bp->ipv6, bp->ipv6len, vs);
vc->addr = bp->ipv6;
vc->addrlen = bp->ipv6len;
}
if (s == -1 && bp->ipv4 != NULL) {
- s = vbe_TryConnect(sp, PF_INET, bp->ipv4, bp->ipv4len, vs);
+ s = vbe_TryConnect(req, PF_INET, bp->ipv4, bp->ipv4len, vs);
vc->addr = bp->ipv4;
vc->addrlen = bp->ipv4len;
}
if (s == -1 && !cache_param->prefer_ipv6 && bp->ipv6 != NULL) {
- s = vbe_TryConnect(sp, PF_INET6, bp->ipv6, bp->ipv6len, vs);
+ s = vbe_TryConnect(req, PF_INET6, bp->ipv6, bp->ipv6len, vs);
vc->addr = bp->ipv6;
vc->addrlen = bp->ipv6len;
}
@@ -181,10 +181,9 @@ bes_conn_try(const struct sess *sp, struct vbc *vc, const struct vdi_simple *vs)
vc->addr = NULL;
vc->addrlen = 0;
} else {
- vc->vsl_id = s | VSL_BACKENDMARKER;
VTCP_myname(s, abuf1, sizeof abuf1, pbuf1, sizeof pbuf1);
- WSL(sp->wrk->vsl, SLT_BackendOpen, vc->vsl_id, "%s %s %s ",
- vs->backend->display_name, abuf1, pbuf1);
+ VSLb(req->vsl, SLT_BackendOpen, "%d %s %s %s ",
+ vc->fd, vs->backend->display_name, abuf1, pbuf1);
}
}
@@ -226,7 +225,7 @@ vbe_NewConn(void)
/*--------------------------------------------------------------------
* It evaluates if a backend is healthy _for_a_specific_object_.
- * That means that it relies on sp->req->objcore->objhead. This is mainly for
+ * That means that it relies on req->objcore->objhead. This is mainly for
* saint-mode, but also takes backend->healthy into account. If
* cache_param->saintmode_threshold is 0, this is basically just a test of
* backend->healthy.
@@ -236,7 +235,7 @@ vbe_NewConn(void)
*/
static unsigned int
-vbe_Healthy(const struct vdi_simple *vs, const struct sess *sp)
+vbe_Healthy(const struct vdi_simple *vs, const struct req *req)
{
struct trouble *tr;
struct trouble *tr2;
@@ -244,10 +243,9 @@ vbe_Healthy(const struct vdi_simple *vs, const struct sess *sp)
unsigned i = 0, retval;
unsigned int threshold;
struct backend *backend;
- uintptr_t target;
double now;
- CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+ CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
CHECK_OBJ_NOTNULL(vs, VDI_SIMPLE_MAGIC);
backend = vs->backend;
CHECK_OBJ_NOTNULL(backend, BACKEND_MAGIC);
@@ -261,23 +259,18 @@ vbe_Healthy(const struct vdi_simple *vs, const struct sess *sp)
/* VRT/VCC sets threshold to UINT_MAX to mark that it's not
* specified by VCL (thus use param).
*/
- if (vs->vrt->saintmode_threshold == UINT_MAX)
+ threshold = vs->vrt->saintmode_threshold;
+ if (threshold == UINT_MAX)
threshold = cache_param->saintmode_threshold;
- else
- threshold = vs->vrt->saintmode_threshold;
if (backend->admin_health == ah_healthy)
threshold = UINT_MAX;
- /* Saintmode is disabled */
- if (threshold == 0)
+ /* Saintmode is disabled, or list is empty */
+ if (threshold == 0 || VTAILQ_EMPTY(&backend->troublelist))
return (1);
- if (sp->req->objcore == NULL)
- return (1);
-
- now = sp->t_req;
- target = (uintptr_t)(sp->req->objcore->objhead);
+ now = req->t_req;
old = NULL;
retval = 1;
@@ -292,7 +285,7 @@ vbe_Healthy(const struct vdi_simple *vs, const struct sess *sp)
break;
}
- if (tr->target == target) {
+ if (!memcmp(tr->digest, req->digest, sizeof tr->digest)) {
retval = 0;
break;
}
@@ -319,12 +312,12 @@ vbe_Healthy(const struct vdi_simple *vs, const struct sess *sp)
*/
static struct vbc *
-vbe_GetVbe(const struct sess *sp, struct vdi_simple *vs)
+vbe_GetVbe(struct req *req, struct vdi_simple *vs)
{
struct vbc *vc;
struct backend *bp;
- CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+ CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
CHECK_OBJ_NOTNULL(vs, VDI_SIMPLE_MAGIC);
bp = vs->backend;
CHECK_OBJ_NOTNULL(bp, BACKEND_MAGIC);
@@ -346,20 +339,20 @@ vbe_GetVbe(const struct sess *sp, struct vdi_simple *vs)
if (vbe_CheckFd(vc->fd)) {
/* XXX locking of stats */
VSC_C_main->backend_reuse += 1;
- WSP(sp, SLT_Backend, "%d %s %s",
- vc->fd, sp->req->director->vcl_name,
+ VSLb(req->vsl, SLT_Backend, "%d %s %s",
+ vc->fd, req->director->vcl_name,
bp->display_name);
vc->vdis = vs;
vc->recycled = 1;
return (vc);
}
VSC_C_main->backend_toolate++;
- WSL(sp->wrk->vsl, SLT_BackendClose, vc->vsl_id, "%s",
- bp->display_name);
+ VSLb(req->vsl, SLT_BackendClose, "%d %s toolate",
+ vc->fd, bp->display_name);
/* Checkpoint log to flush all info related to this connection
before the OS reuses the FD */
- WSL_Flush(sp->wrk->vsl, 0);
+ VSL_Flush(req->vsl, 0);
VTCP_close(&vc->fd);
VBE_DropRefConn(bp);
@@ -367,7 +360,7 @@ vbe_GetVbe(const struct sess *sp, struct vdi_simple *vs)
VBE_ReleaseConn(vc);
}
- if (!vbe_Healthy(vs, sp)) {
+ if (!vbe_Healthy(vs, req)) {
VSC_C_main->backend_unhealthy++;
return (NULL);
}
@@ -381,7 +374,7 @@ vbe_GetVbe(const struct sess *sp, struct vdi_simple *vs)
vc = vbe_NewConn();
assert(vc->fd == -1);
AZ(vc->backend);
- bes_conn_try(sp, vc, vs);
+ bes_conn_try(req, vc, vs);
if (vc->fd < 0) {
VBE_ReleaseConn(vc);
VSC_C_main->backend_fail++;
@@ -389,8 +382,8 @@ vbe_GetVbe(const struct sess *sp, struct vdi_simple *vs)
}
vc->backend = bp;
VSC_C_main->backend_conn++;
- WSP(sp, SLT_Backend, "%d %s %s",
- vc->fd, sp->req->director->vcl_name, bp->display_name);
+ VSLb(req->vsl, SLT_Backend, "%d %s %s",
+ vc->fd, req->director->vcl_name, bp->display_name);
vc->vdis = vs;
return (vc);
}
@@ -438,33 +431,52 @@ VBE_UseHealth(const struct director *vdi)
*
*/
+void
+VBE_DiscardHealth(const struct director *vdi)
+{
+ struct vdi_simple *vs;
+
+ ASSERT_CLI();
+
+ if (strcmp(vdi->name, "simple"))
+ return;
+ CAST_OBJ_NOTNULL(vs, vdi->priv, VDI_SIMPLE_MAGIC);
+ if (vs->vrt->probe == NULL)
+ return;
+ VBP_Remove(vs->backend, vs->vrt->probe);
+}
+
+/*--------------------------------------------------------------------
+ *
+ */
+
static struct vbc * __match_proto__(vdi_getfd_f)
-vdi_simple_getfd(const struct director *d, struct sess *sp)
+vdi_simple_getfd(const struct director *d, struct req *req)
{
struct vdi_simple *vs;
struct vbc *vc;
- CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+ CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC);
CAST_OBJ_NOTNULL(vs, d->priv, VDI_SIMPLE_MAGIC);
- vc = vbe_GetVbe(sp, vs);
+ vc = vbe_GetVbe(req, vs);
if (vc != NULL) {
FIND_TMO(first_byte_timeout,
- vc->first_byte_timeout, sp, vs->vrt);
+ vc->first_byte_timeout, req, vs->vrt);
FIND_TMO(between_bytes_timeout,
- vc->between_bytes_timeout, sp, vs->vrt);
+ vc->between_bytes_timeout, req, vs->vrt);
}
return (vc);
}
static unsigned
-vdi_simple_healthy(const struct director *d, const struct sess *sp)
+vdi_simple_healthy(const struct director *d, const struct req *req)
{
struct vdi_simple *vs;
CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC);
CAST_OBJ_NOTNULL(vs, d->priv, VDI_SIMPLE_MAGIC);
- return (vbe_Healthy(vs, sp));
+ return (vbe_Healthy(vs, req));
}
static void
@@ -476,8 +488,6 @@ vdi_simple_fini(const struct director *d)
CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC);
CAST_OBJ_NOTNULL(vs, d->priv, VDI_SIMPLE_MAGIC);
- if (vs->vrt->probe != NULL)
- VBP_Remove(vs->backend, vs->vrt->probe);
VBE_DropRefVcl(vs->backend);
free(vs->dir.vcl_name);
vs->dir.magic = 0;
View
8 bin/varnishd/cache/cache_backend.h
@@ -75,9 +75,9 @@ struct vrt_backend_probe;
* backends to use.
*/
-typedef struct vbc *vdi_getfd_f(const struct director *, struct sess *sp);
+typedef struct vbc *vdi_getfd_f(const struct director *, struct req *);
typedef void vdi_fini_f(const struct director *);
-typedef unsigned vdi_healthy(const struct director *, const struct sess *sp);
+typedef unsigned vdi_healthy(const struct director *, const struct req *);
struct director {
unsigned magic;
@@ -97,7 +97,7 @@ struct director {
struct trouble {
unsigned magic;
#define TROUBLE_MAGIC 0x4211ab21
- uintptr_t target;
+ unsigned char digest[DIGEST_LEN];
double timeout;
VTAILQ_ENTRY(trouble) list;
};
@@ -153,8 +153,6 @@ struct vbc {
struct backend *backend;
struct vdi_simple *vdis;
struct vsl_log *vsl;
- unsigned orig_vsl_id;
- unsigned vsl_id;
int fd;
struct sockaddr_storage *addr;
View
4 bin/varnishd/cache/cache_backend_cfg.c
@@ -487,9 +487,9 @@ cli_backend_set_health(struct cli *cli, const char * const *av, void *priv)
static struct cli_proto backend_cmds[] = {
{ "backend.list", "backend.list",
- "\tList all backends\n", 0, 1, "d", cli_backend_list },
+ "\tList all backends\n", 0, 1, "", cli_backend_list },
{ "backend.set_health", "backend.set_health matcher state",
- "\tShow a backend\n", 2, 2, "d", cli_backend_set_health },
+ "\tSet health status on a backend\n", 2, 2, "", cli_backend_set_health },
{ NULL }
};
View
2  bin/varnishd/cache/cache_backend_poll.c
@@ -500,7 +500,7 @@ VBP_Insert(struct backend *b, const struct vrt_backend_probe *p,
}
VTAILQ_FOREACH(vcl, &vt->vcls, list)
- assert (vcl->probep != p);
+ assert(vcl->probep != p);
vcl = vbp_new_vcl(p, hosthdr);
Lck_Lock(&vbp_mtx);
View
87 bin/varnishd/cache/cache_ban.c
@@ -447,6 +447,7 @@ BAN_NewObjCore(struct objcore *oc)
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
AZ(oc->ban);
+ AN(oc->objhead);
Lck_Lock(&ban_mtx);
oc->ban = ban_start;
ban_start->refcount++;
@@ -525,7 +526,7 @@ BAN_Reload(const uint8_t *ban, unsigned len)
VTAILQ_FOREACH(b, &ban_head, list) {
t1 = ban_time(b->spec);
- assert (t1 < t2);
+ assert(t1 < t2);
t2 = t1;
if (t1 == t0) {
Lck_Unlock(&ban_mtx);
@@ -677,16 +678,16 @@ ban_evaluate(const uint8_t *bs, const struct http *objhttp,
*/
static int
-ban_check_object(struct object *o, const struct sess *sp, int has_req)
+ban_check_object(struct object *o, struct vsl_log *vsl,
+ const struct http *req_http)
{
struct ban *b;
struct objcore *oc;
struct ban * volatile b0;
unsigned tests, skipped;
- struct http *http;
- CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
+ CHECK_OBJ_ORNULL(req_http, HTTP_MAGIC);
oc = o->objcore;
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
CHECK_OBJ_NOTNULL(oc->ban, BAN_MAGIC);
@@ -697,11 +698,6 @@ ban_check_object(struct object *o, const struct sess *sp, int has_req)
if (b0 == oc->ban)
return (0);
- if (has_req)
- http = sp->req->http;
- else
- http = NULL;
-
/*
* This loop is safe without locks, because we know we hold
* a refcount on a ban somewhere in the list and we do not
@@ -719,13 +715,13 @@ ban_check_object(struct object *o, const struct sess *sp, int has_req)
/* Lurker already tested this */
continue;
}
- if (!has_req && (b->flags & BAN_F_REQ)) {
+ if (req_http == NULL && (b->flags & BAN_F_REQ)) {
/*
* We cannot test this one, but there might
* be other bans that match, so we soldier on
*/
skipped++;
- } else if (ban_evaluate(b->spec, o->http, http, &tests))
+ } else if (ban_evaluate(b->spec, o->http, req_http, &tests))
break;
}
@@ -734,7 +730,7 @@ ban_check_object(struct object *o, const struct sess *sp, int has_req)
VSC_C_main->bans_tests_tested += tests;
if (b == oc->ban && skipped > 0) {
- AZ(has_req);
+ AZ(req_http);
Lck_Unlock(&ban_mtx);
/*
* Not banned, but some tests were skipped, so we cannot know
@@ -761,17 +757,18 @@ ban_check_object(struct object *o, const struct sess *sp, int has_req)
oc->ban = NULL;
oc_updatemeta(oc);
/* BAN also changed, but that is not important any more */
- WSP(sp, SLT_ExpBan, "%u was banned", o->xid);
+ /* XXX: no req in lurker */
+ VSLb(vsl, SLT_ExpBan, "%u was banned", o->vxid);
EXP_Rearm(o);
return (1);
}
}
int
-BAN_CheckObject(struct object *o, const struct sess *sp)
+BAN_CheckObject(struct object *o, struct req *req)
{
- return (ban_check_object(o, sp, 1) > 0);
+ return (ban_check_object(o, req->vsl, req->http) > 0);
}
static struct ban *
@@ -800,7 +797,7 @@ ban_CheckLast(void)
*/
static int
-ban_lurker_work(const struct sess *sp, unsigned pass)
+ban_lurker_work(struct worker *wrk, struct vsl_log *vsl, unsigned pass)
{
struct ban *b, *b0, *b2;
struct objhead *oh;
@@ -839,14 +836,14 @@ ban_lurker_work(const struct sess *sp, unsigned pass)
b->flags &= ~BAN_F_LURK;
b->flags |= pass;
}
- if (cache_param->diag_bitmap & 0x80000)
- VSL(SLT_Debug, 0, "lurker: %d actionable bans", i);
+ if (DO_DEBUG(DBG_LURKER))
+ VSLb(vsl, SLT_Debug, "lurker: %d actionable bans", i);
if (i == 0)
return (0);
VTAILQ_FOREACH_REVERSE(b, &ban_head, banhead_s, list) {
- if (cache_param->diag_bitmap & 0x80000)
- VSL(SLT_Debug, 0, "lurker doing %f %d",
+ if (DO_DEBUG(DBG_LURKER))
+ VSLb(vsl, SLT_Debug, "lurker doing %f %d",
ban_time(b->spec), b->refcount);
while (1) {
Lck_Lock(&ban_mtx);
@@ -854,8 +851,8 @@ ban_lurker_work(const struct sess *sp, unsigned pass)
if (oc == NULL)
break;
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
- if (cache_param->diag_bitmap & 0x80000)
- VSL(SLT_Debug, 0, "test: %p %u %u",
+ if (DO_DEBUG(DBG_LURKER))
+ VSLb(vsl, SLT_Debug, "test: %p %u %u",
oc, oc->flags & OC_F_LURK, pass);
if ((oc->flags & OC_F_LURK) == pass)
break;
@@ -863,6 +860,7 @@ ban_lurker_work(const struct sess *sp, unsigned pass)
CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC);
if (Lck_Trylock(&oh->mtx)) {
Lck_Unlock(&ban_mtx);
+ VSL_Flush(vsl, 0);
VTIM_sleep(cache_param->ban_lurker_sleep);
continue;
}
@@ -881,6 +879,18 @@ ban_lurker_work(const struct sess *sp, unsigned pass)
continue;
}
/*
+ * If the object is busy, we can't touch
+ * it. Defer it to a later run.
+ */
+ if (oc->flags & OC_F_BUSY) {
+ oc->flags |= pass;
+ VTAILQ_REMOVE(&b->objcore, oc, ban_list);
+ VTAILQ_INSERT_TAIL(&b->objcore, oc, ban_list);
+ Lck_Unlock(&oh->mtx);
+ Lck_Unlock(&ban_mtx);
+ continue;
+ }
+ /*
* Grab a reference to the OC and we can let go of
* the BAN mutex
*/
@@ -891,10 +901,10 @@ ban_lurker_work(const struct sess *sp, unsigned pass)
/*
* Get the object and check it against all relevant bans
*/
- o = oc_getobj(&sp->wrk->stats, oc);
- i = ban_check_object(o, sp, 0);
- if (cache_param->diag_bitmap & 0x80000)
- VSL(SLT_Debug, 0, "lurker got: %p %d",
+ o = oc_getobj(&wrk->stats, oc);
+ i = ban_check_object(o, vsl, NULL);
+ if (DO_DEBUG(DBG_LURKER))
+ VSLb(vsl, SLT_Debug, "lurker got: %p %d",
oc, i);
if (i == -1) {
/* Not banned, not moved */
@@ -905,10 +915,10 @@ ban_lurker_work(const struct sess *sp, unsigned pass)
Lck_Unlock(&ban_mtx);
}
Lck_Unlock(&oh->mtx);
- if (cache_param->diag_bitmap & 0x80000)
- VSL(SLT_Debug, 0, "lurker done: %p %u %u",
+ if (DO_DEBUG(DBG_LURKER))
+ VSLb(vsl, SLT_Debug, "lurker done: %p %u %u",
oc, oc->flags & OC_F_LURK, pass);
- (void)HSH_Deref(&sp->wrk->stats, NULL, &o);
+ (void)HSH_Deref(&wrk->stats, NULL, &o);
VTIM_sleep(cache_param->ban_lurker_sleep);
}
Lck_AssertHeld(&ban_mtx);
@@ -917,8 +927,8 @@ ban_lurker_work(const struct sess *sp, unsigned pass)
b->flags |= BAN_F_GONE;
VSC_C_main->bans_gone++;
}
- if (cache_param->diag_bitmap & 0x80000)
- VSL(SLT_Debug, 0, "lurker BAN %f now gone",
+ if (DO_DEBUG(DBG_LURKER))
+ VSLb(vsl, SLT_Debug, "lurker BAN %f now gone",
ban_time(b->spec));
}
Lck_Unlock(&ban_mtx);
@@ -930,12 +940,15 @@ ban_lurker_work(const struct sess *sp, unsigned pass)
}
static void * __match_proto__(bgthread_t)
-ban_lurker(struct sess *sp, void *priv)
+ban_lurker(struct worker *wrk, void *priv)
{
struct ban *bf;
unsigned pass = (1 << LURK_SHIFT);
+ struct vsl_log vsl;
int i = 0;
+ VSL_Setup(&vsl, NULL, 0);
+
(void)priv;
while (1) {
@@ -953,9 +966,9 @@ ban_lurker(struct sess *sp, void *priv)
VTIM_sleep(1.0);
}
- i = ban_lurker_work(sp, pass);
- WSL_Flush(sp->wrk->vsl, 0);
- WRK_SumStat(sp->wrk);
+ i = ban_lurker_work(wrk, &vsl, pass);
+ VSL_Flush(&vsl, 0);
+ WRK_SumStat(wrk);
if (i) {
pass += (1 << LURK_SHIFT);
pass &= BAN_F_LURK;
@@ -1078,7 +1091,7 @@ ccf_ban_list(struct cli *cli, const char * const *av, void *priv)
VCLI_Out(cli, "Present bans:\n");
VTAILQ_FOREACH(b, &ban_head, list) {
- if (b == bl && !(cache_param->diag_bitmap & 0x80000))
+ if (b == bl && !DO_DEBUG(DBG_LURKER))
break;
VCLI_Out(cli, "%10.6f %5u%s\t", ban_time(b->spec),
bl == b ? b->refcount - 1 : b->refcount,
@@ -1087,7 +1100,7 @@ ccf_ban_list(struct cli *cli, const char * const *av, void *priv)
VCLI_Out(cli, "\n");
if (VCLI_Overflow(cli))
break;
- if (cache_param->diag_bitmap & 0x80000) {
+ if (DO_DEBUG(DBG_LURKER)) {
Lck_Lock(&ban_mtx);
struct objcore *oc;
VTAILQ_FOREACH(oc, &b->objcore, ban_list)
View
149 bin/varnishd/cache/cache_busyobj.c
@@ -38,16 +38,9 @@
#include "cache.h"
-static struct mempool *vbopool;
+#include "hash/hash_slinger.h"
-struct vbo {
- unsigned magic;
-#define VBO_MAGIC 0xde3d8223
- struct lock mtx;
- unsigned refcount;
- char *end;
- struct busyobj bo;
-};
+static struct mempool *vbopool;
/*--------------------------------------------------------------------
*/
@@ -56,7 +49,7 @@ void
VBO_Init(void)
{
- vbopool = MPL_New("vbo", &cache_param->vbo_pool,
+ vbopool = MPL_New("busyobj", &cache_param->vbo_pool,
&cache_param->workspace_backend);
AN(vbopool);
}
@@ -65,130 +58,132 @@ VBO_Init(void)
* BusyObj handling
*/
-static struct vbo *
+static struct busyobj *
vbo_New(void)
{
- struct vbo *vbo;
+ struct busyobj *bo;
unsigned sz;
- vbo = MPL_Get(vbopool, &sz);
- AN(vbo);
- vbo->magic = VBO_MAGIC;
- vbo->end = (char *)vbo + sz;
- Lck_New(&vbo->mtx, lck_busyobj);
- return (vbo);
+ bo = MPL_Get(vbopool, &sz);
+ XXXAN(bo);
+ bo->magic = BUSYOBJ_MAGIC;
+ bo->end = (char *)bo + sz;
+ Lck_New(&bo->mtx, lck_busyobj);
+ return (bo);
}
void
-VBO_Free(struct vbo **vbop)
+VBO_Free(struct busyobj **bop)
{
- struct vbo *vbo;
-
- AN(vbop);
- vbo = *vbop;
- *vbop = NULL;
- CHECK_OBJ_NOTNULL(vbo, VBO_MAGIC);
- AZ(vbo->refcount);
- Lck_Delete(&vbo->mtx);
- MPL_Free(vbopool, vbo);
+ struct busyobj *bo;
+
+ AN(bop);
+ bo = *bop;
+ *bop = NULL;