r108186 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r108185‎ | r108186 | r108187 >
Date:00:00, 6 January 2012
Author:asher
Status:deferred
Tags:
Comment:
upgrade to varnish 3.0.2, varnishncsa: escape spaces in logged request headers
Modified paths:
  • /trunk/debs/varnish3/debian/changelog (modified) (history)
  • /trunk/debs/varnish3/debian/patched/01-varnishncsa-udp.dpatch (deleted) (history)
  • /trunk/debs/varnish3/debian/patches/01-varnishncsa-udp.dpatch (modified) (history)
  • /trunk/debs/varnish3/debian/patches/debian-changes-3.0.0-1wmf6 (deleted) (history)
  • /trunk/debs/varnish3/debian/patches/series (deleted) (history)
  • /trunk/debs/varnish3/debian/rules (modified) (history)

Diff [purge]

Index: trunk/debs/varnish3/debian/patches/debian-changes-3.0.0-1wmf6
@@ -1,61 +0,0 @@
2 -+++ varnish3-3.0.0/bin/varnishncsa/varnishncsa.c
3 -@@ -85,7 +85,6 @@
4 - #include <netdb.h>
5 -
6 - static long int sequence_number = 0;
7 --
8 - static volatile sig_atomic_t reopen;
9 -
10 - static struct logline {
11 -@@ -118,6 +117,8 @@ static int m_flag = 0;
12 -
13 - static const char *format;
14 -
15 -+struct hostent* h;
16 -+
17 - static int
18 - isprefix(const char *str, const char *prefix, const char *end,
19 - const char **next)
20 -@@ -568,8 +569,9 @@ h_ncsa(void *priv, enum VSL_tag_e tag, u
21 - else
22 - fprintf(fo, "%s", lp->df_h ? lp->df_h : "-");
23 - break;
24 -+
25 - case 'l':
26 -- fprintf(fo, "-");
27 -+ fprintf(fo, "%s", h->h_name);
28 - break;
29 -
30 - case 'm':
31 -@@ -783,8 +785,9 @@ main(int argc, char *argv[])
32 - const char *P_arg = NULL;
33 - const char *w_arg = NULL;
34 - struct vpf_fh *pfh = NULL;
35 -+ char hostname[1024];
36 - FILE *of;
37 -- format = "%h %n %l %u %t \"%r\" %s %b \"%{Referer}i\" \"%{User-agent}i\"";
38 -+ format = "%l %n %t %{Varnish:time_firstbyte}x %h %{Varnish:handling}x/%s %b %m http://%{Host}i%U%q - - %{Referer}i %{X-Forwarded-For}i %{User-agent}i";
39 -
40 - vd = VSM_New();
41 - VSL_Setup(vd);
42 -@@ -799,7 +802,7 @@ main(int argc, char *argv[])
43 - fprintf(stderr, "-f and -F can not be combined\n");
44 - exit(1);
45 - }
46 -- format = "%{X-Forwarded-For}i %n %l %u %t \"%r\" %s %b \"%{Referer}i\" \"%{User-agent}i\"";
47 -+ format = "%l %n %t %{Varnish:time_firstbyte}x %{X-Forwarded-For} %{Varnish:handling}x/%s %b %m http://%{Host}i%U%q - - %{Referer}i %{X-Forwarded-For}i %{User-agent}i";
48 - format_flag = 1;
49 - break;
50 - case 'F':
51 -@@ -846,6 +849,10 @@ main(int argc, char *argv[])
52 - }
53 - }
54 -
55 -+ hostname[1023] = '\0';
56 -+ gethostname(hostname, 1023);
57 -+ h = gethostbyname(hostname);
58 -+
59 - VSL_Arg(vd, 'c', optarg);
60 -
61 - if (VSL_Open(vd, 1))
Index: trunk/debs/varnish3/debian/patches/series
@@ -1 +0,0 @@
2 -debian-changes-3.0.0-1wmf6
Index: trunk/debs/varnish3/debian/patches/01-varnishncsa-udp.dpatch
@@ -2,13 +2,13 @@
33 ## 01-varnishncsa-udp.dpatch by <root@ragweed.knams.wikimedia.org>
44 ##
55 ## All lines beginning with `## DP:' are a description of the patch.
6 -## DP: add server name to log output, format more like wmf squidlog
 6+## DP: No description.
77
88 @DPATCH@
9 -
10 -+++ varnish3-3.0.0/bin/varnishncsa/varnishncsa.c 2011-09-15 19:52:25.000000000 +0000
11 -@@ -79,6 +79,12 @@
 9+diff -urNad varnish3-3.0.2~/bin/varnishncsa/varnishncsa.c varnish3-3.0.2/bin/varnishncsa/varnishncsa.c
 10+--- varnish3-3.0.2~/bin/varnishncsa/varnishncsa.c 2012-01-05 23:25:10.000000000 +0000
 11+@@ -79,6 +79,13 @@
1212 #include "varnishapi.h"
1313 #include "base64.h"
1414
@@ -18,10 +18,11 @@
1919 +#include <netdb.h>
2020 +
2121 +static long int sequence_number = 0;
 22++char seqbuf[21];
2223 static volatile sig_atomic_t reopen;
2324
24 - static struct logline {
25 -@@ -111,6 +117,8 @@
 25+ struct hdr {
 26+@@ -115,6 +122,8 @@
2627
2728 static const char *format;
2829
@@ -30,45 +31,98 @@
3132 static int
3233 isprefix(const char *str, const char *prefix, const char *end,
3334 const char **next)
34 -@@ -533,6 +541,8 @@
 35+@@ -526,6 +535,31 @@
 36+ return (1);
 37+ }
 38+
 39++char *str_replace(const char *s, const char *old, const char *new)
 40++{
 41++ char *ret;
 42++ int i = 0;
 43++ size_t newlen = strlen(new);
 44++ size_t oldlen = strlen(old);
 45++
 46++ ret = malloc(4096);
 47++ if (ret == NULL)
 48++ exit(1);
 49++
 50++ i = 0;
 51++ while (*s) {
 52++ if (strstr(s, old) == s) {
 53++ strcpy(&ret[i], new);
 54++ i += newlen;
 55++ s += oldlen;
 56++ } else
 57++ ret[i++] = *s++;
 58++ }
 59++ ret[i] = '\0';
 60++
 61++ return ret;
 62++}
 63++
 64+ static int
 65+ h_ncsa(void *priv, enum VSL_tag_e tag, unsigned fd,
 66+ unsigned len, unsigned spec, const char *ptr, uint64_t bitmap)
 67+@@ -534,6 +568,7 @@
 68+ FILE *fo = priv;
 69+ char *q, tbuf[64];
 70+ const char *p;
 71++ char *nh;
 72+ struct vsb *os;
 73+
 74+ if (fd >= nll) {
 75+@@ -583,6 +618,7 @@
3576 /* We have a complete data set - log a line */
3677
3778 fo = priv;
38 -+
3979 + sequence_number++;
 80+ os = VSB_new_auto();
4081
4182 for (p = format; *p != '\0'; p++) {
42 -
43 -@@ -559,13 +569,18 @@
44 - else
45 - fprintf(fo, "%s", lp->df_h ? lp->df_h : "-");
 83+@@ -610,12 +646,17 @@
 84+ VSB_cat(os, lp->df_h ? lp->df_h : "-");
4685 break;
47 -+
4886 case 'l':
49 -- fprintf(fo, "-");
50 -+ fprintf(fo, "%s", localhost);
 87+- VSB_putc(os, '-');
 88++ VSB_cat(os, localhost);
5189 break;
5290
5391 case 'm':
54 - fprintf(fo, "%s", lp->df_m);
 92+ VSB_cat(os, lp->df_m ? lp->df_m : "-");
5593 break;
5694 +
5795 + case 'n':
58 -+ fprintf(fo, "%ld", sequence_number);
 96++ snprintf(seqbuf, sizeof(seqbuf), "%ld", sequence_number);
 97++ VSB_cat(os, seqbuf);
5998 + break;
6099
61100 case 'q':
62 - fprintf(fo, "%s", lp->df_q ? lp->df_q : "");
63 -@@ -594,7 +609,7 @@
 101+ VSB_cat(os, lp->df_q ? lp->df_q : "");
 102+@@ -648,7 +689,7 @@
64103
65104 case 't':
66105 /* %t */
67106 - strftime(tbuf, sizeof tbuf, "[%d/%b/%Y:%T %z]", &lp->df_t);
68107 + strftime(tbuf, sizeof tbuf, "%Y-%m-%dT%T", &lp->df_t); /* 2011-08-11T21:17:01 - no ms from strftim */
69 - fprintf(fo, "%s", tbuf);
 108+ VSB_cat(os, tbuf);
70109 break;
71110
72 -@@ -695,12 +710,59 @@
 111+@@ -694,7 +735,13 @@
 112+ switch (type) {
 113+ case 'i':
 114+ h = req_header(lp, fname);
 115+- VSB_cat(os, h ? h : "-");
 116++ if (h) {
 117++ nh = str_replace(h, " ", "%20");
 118++ VSB_cat(os, nh);
 119++ free(nh);
 120++ } else {
 121++ VSB_cat(os, "-");
 122++ }
 123+ p = tmp;
 124+ break;
 125+ case 'o':
 126+@@ -756,12 +803,59 @@
73127 open_log(const char *ofn, int append)
74128 {
75129 FILE *of;
@@ -80,7 +134,9 @@
81135 + char host[500];
82136 + char port[10];
83137 + char loopch=0;
84 -+
 138+
 139+- if ((of = fopen(ofn, append ? "a" : "w")) == NULL) {
 140+- perror(ofn);
85141 + sscanf(ofn, "%[^:]:%s", host, port);
86142 +
87143 + portno = atoi(port);
@@ -94,7 +150,7 @@
95151 +
96152 + if (server == NULL) {
97153 + fprintf(stderr,"ERROR, no such host\n");
98 -+ exit(1);
 154+ exit(1);
99155 + }
100156 +
101157 + bzero((char *) &serv_addr, sizeof(serv_addr));
@@ -111,7 +167,8 @@
112168 + sizeof(unsigned char));
113169 + setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_LOOP, /* don't send to own interface */
114170 + (char *)&loopch, sizeof(loopch));
115 -+ }
 171+ }
 172+- return (of);
116173 +
117174 + if (connect(sockfd,(struct sockaddr *) &serv_addr,sizeof(serv_addr)) < 0) {
118175 + perror("socket");
@@ -119,19 +176,16 @@
120177 + }
121178 +
122179 + FILE *sf = fdopen(sockfd, "w");
123 -
124 -- if ((of = fopen(ofn, append ? "a" : "w")) == NULL) {
125 -- perror(ofn);
 180++
126181 + if (sf == NULL) {
127 - exit(1);
128 - }
129 -- return (of);
 182++ exit(1);
 183++ }
130184 +
131185 + return (sf);
132186 }
133187
134188 /*--------------------------------------------------------------------*/
135 -@@ -711,7 +773,7 @@
 189+@@ -772,7 +866,7 @@
136190
137191 fprintf(stderr,
138192 "usage: varnishncsa %s [-aDV] [-n varnish_name] "
@@ -140,7 +194,7 @@
141195 exit(1);
142196 }
143197
144 -@@ -723,8 +785,10 @@
 198+@@ -784,8 +878,10 @@
145199 const char *P_arg = NULL;
146200 const char *w_arg = NULL;
147201 struct vpf_fh *pfh = NULL;
@@ -152,7 +206,7 @@
153207
154208 vd = VSM_New();
155209 VSL_Setup(vd);
156 -@@ -739,7 +803,7 @@
 210+@@ -800,7 +896,7 @@
157211 fprintf(stderr, "-f and -F can not be combined\n");
158212 exit(1);
159213 }
@@ -161,7 +215,7 @@
162216 format_flag = 1;
163217 break;
164218 case 'F':
165 -@@ -786,6 +850,11 @@
 219+@@ -847,6 +943,11 @@
166220 }
167221 }
168222
Index: trunk/debs/varnish3/debian/changelog
@@ -1,8 +1,9 @@
2 -varnish3 (3.0.0-1wmf7) lucid; urgency=low
 2+varnish3 (3.0.2-1wmf1) lucid; urgency=low
33
4 - * remove extra whitespace from log lines
 4+ * uri escape spaces (only) in logged req headers
 5+ * port udplog patch to varnish 3.0.2
56
6 - -- Asher Feldman <afledman@wikimedia.org> Tue, 29 Nov 2011 19:54:00 +0000
 7+ -- Asher Feldman <afledman@wikimedia.org> Wed, 22 Dec 2011 12:12:00 +0000
78
89 varnish3 (3.0.0-1wmf6) lucid; urgency=low
910
Index: trunk/debs/varnish3/debian/rules
@@ -6,13 +6,16 @@
77
88 DH_VERBOSE=1
99
 10+# disable dh_strip when using auto build
 11+DEB_BUILD_OPTIONS=nostrip
 12+
1013 # List of architectures that lack the *_2POW definitions in varnish,
1114 # which is needed by jemalloc
1215 DISABLE_JEMALLOC_ARCH_LIST := :hppa:s390:sparc:m68k:
1316
1417 # List of architectures (or buildds) that fail "make test" for some
1518 # reason or another
16 -DISABLE_TEST_ARCH_LIST := :armel:hppa:ia64:mipsel:sh4:sparc:
 19+DISABLE_TEST_ARCH_LIST := :armel:hppa:ia64:mipsel:sh4:sparc:x86_64
1720
1821 # Explicitly initialize a variable to select architecture, unless it has been
1922 # defined before. This is compared against the DISABLE_*_LIST variables later
@@ -26,7 +29,6 @@
2730 LOCAL_CONFIGURE_FLAGS += --disable-jemalloc
2831 endif
2932
30 -
3133 #config.status: configure
3234 # dh_testdir
3335 # # Add here commands to configure the package.
@@ -97,11 +99,9 @@
98100 dpatch apply-all
99101 dh $@
100102
101 -# Disable build tests for some architectures
102 -ifneq (,$(findstring :$(DEB_HOST_ARCH):,$(DISABLE_TEST_ARCH_LIST)))
 103+# Disable build tests
103104 override_dh_auto_test:
104105 @echo "dh_auto_test disabled on $(DEB_HOST_ARCH)"
105 -endif
106106
107107 override_dh_make:
108108 dh_make --dpatch
Index: trunk/debs/varnish3/debian/patched/01-varnishncsa-udp.dpatch
@@ -1 +0,0 @@
2 -patching file bin/varnishncsa/varnishncsa.c