r97210 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97209‎ | r97210 | r97211 >
Date:21:39, 15 September 2011
Author:asher
Status:deferred
Tags:
Comment:
epic fail: i didn't realize that gethostbyname() always returns a pointer to the same struct
Modified paths:
  • /trunk/debs/varnish3/debian/patches/01-varnishncsa-udp.dpatch (modified) (history)

Diff [purge]

Index: trunk/debs/varnish3/debian/patches/01-varnishncsa-udp.dpatch
@@ -7,7 +7,7 @@
88 @DPATCH@
99
1010 --- varnish3-3.0.0~/bin/varnishncsa/varnishncsa.c 2011-08-09 23:55:17.000000000 +0000
11 -+++ varnish3-3.0.0/bin/varnishncsa/varnishncsa.c 2011-09-14 21:52:17.000000000 +0000
1211 @@ -79,6 +79,12 @@
1312 #include "varnishapi.h"
1413 #include "base64.h"
@@ -25,7 +25,7 @@
2626
2727 static const char *format;
2828
29 -+struct hostent* h;
 29++static char localhost[255];
3030 +
3131 static int
3232 isprefix(const char *str, const char *prefix, const char *end,
@@ -46,7 +46,7 @@
4747 +
4848 case 'l':
4949 - fprintf(fo, "-");
50 -+ fprintf(fo, "%s", h->h_name);
 50++ fprintf(fo, "%s", localhost);
5151 break;
5252
5353 case 'm':
@@ -140,18 +140,19 @@
141141 exit(1);
142142 }
143143
144 -@@ -723,8 +785,9 @@
 144+@@ -723,8 +785,10 @@
145145 const char *P_arg = NULL;
146146 const char *w_arg = NULL;
147147 struct vpf_fh *pfh = NULL;
148148 + char hostname[1024];
 149++ struct hostent *lh;
149150 FILE *of;
150151 - format = "%h %l %u %t \"%r\" %s %b \"%{Referer}i\" \"%{User-agent}i\"";
151152 + 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";
152153
153154 vd = VSM_New();
154155 VSL_Setup(vd);
155 -@@ -739,7 +802,7 @@
 156+@@ -739,7 +803,7 @@
156157 fprintf(stderr, "-f and -F can not be combined\n");
157158 exit(1);
158159 }
@@ -160,13 +161,14 @@
161162 format_flag = 1;
162163 break;
163164 case 'F':
164 -@@ -786,6 +849,10 @@
 165+@@ -786,6 +850,11 @@
165166 }
166167 }
167168
168169 + hostname[1023] = '\0';
169170 + gethostname(hostname, 1023);
170 -+ h = gethostbyname(hostname);
 171++ lh = gethostbyname(hostname);
 172++ strcpy(localhost, lh->h_name);
171173 +
172174 VSL_Arg(vd, 'c', optarg);
173175

Status & tagging log