r17680 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r17679‎ | r17680 | r17681 >
Date:20:35, 14 November 2006
Author:river
Status:old
Tags:
Comment:
never try to send POST requests over a keepalive connection: if the connection has been broken, we can't retry, and sending an error to the client is lame.
fix gcc warnings
Modified paths:
  • /trunk/willow/src/include/flalloc.h (modified) (history)
  • /trunk/willow/src/include/ptalloc.h (modified) (history)
  • /trunk/willow/src/willow/flowio.cc (modified) (history)
  • /trunk/willow/src/willow/wbackend.cc (modified) (history)
  • /trunk/willow/src/willow/whttp.cc (modified) (history)
  • /trunk/willow/src/willow/whttp_header.cc (modified) (history)
  • /trunk/willow/src/willow/willow.cc (modified) (history)
  • /trunk/willow/src/willow/wnet.cc (modified) (history)

Diff [purge]

Index: trunk/willow/src/include/ptalloc.h
@@ -49,7 +49,7 @@
5050 struct pttsswrap {
5151 static void pttsswrapdtor(void *p) {
5252 pta_block **pt = (pta_block **)p, *n = *pt, *o;
53 - while (o = n) {
 53+ while ((o = n) != NULL) {
5454 n = n->next;
5555 free(o);
5656 }
Index: trunk/willow/src/include/flalloc.h
@@ -22,7 +22,7 @@
2323 flalloc_dtor(void *p)
2424 {
2525 T *n = (T *)p, *o;
26 - while (o = n) {
 26+ while ((o = n) != NULL) {
2727 n = n->_freelist_next;
2828 ::operator delete(o);
2929 }
Index: trunk/willow/src/willow/flowio.cc
@@ -118,7 +118,7 @@
119119 /* _off was increased by the previous send, reduce _saved
120120 * appropriately
121121 */
122 - if (_off >= _saved)
 122+ if (_off >= (ssize_t)_saved)
123123 _saved = _off = 0;
124124 else
125125 _saved -= _off;
@@ -139,7 +139,7 @@
140140 }
141141 }
142142
143 - if (_off >= _saved)
 143+ if (_off >= (ssize_t)_saved)
144144 _off = _saved = 0;
145145
146146 read = s->read(_savebuf + _off + _saved, DIOBUFSZ - (_off + _saved));
@@ -210,7 +210,7 @@
211211 discard += wrote;
212212 _counter += wrote;
213213
214 - if (len == wrote) {
 214+ if ((ssize_t)len == wrote) {
215215 return sink_result_okay;
216216 } else {
217217 _sink_spigot->sp_cork();
@@ -243,7 +243,7 @@
244244 discard += wrote;
245245 _counter += wrote;
246246
247 - if (len == wrote) {
 247+ if ((ssize_t)len == wrote) {
248248 return sink_result_okay;
249249 } else {
250250 _sink_spigot->sp_cork();
Index: trunk/willow/src/willow/whttp.cc
@@ -330,7 +330,6 @@
331331 }
332332 }
333333
334 - WDEBUG((WLOG_DEBUG, format("whttp: _group=%d") % _group));
335334 _client_spigot->sp_disconnect();
336335 map<string,int>::iterator it;
337336 map<imstring,int>::iterator mit;
@@ -376,7 +375,14 @@
377376 void
378377 httpcllr::start_backend_request(imstring const &host, imstring const &path)
379378 {
380 -pair<wsocket *, backend *> ke = bpools.find(_group)->second.get_keptalive();
 379+pair<wsocket *, backend *> ke;
 380+
 381+ /*
 382+ * Never try to send a POST request over keepalive - if the connection
 383+ * breaks we don't have the POST data anymore so we can't retry.
 384+ */
 385+ if (_header_parser->_http_reqtype != REQTYPE_POST)
 386+ ke = bpools.find(_group)->second.get_keptalive();
381387
382388 _request_host = host;
383389 _request_path = path;
@@ -463,6 +469,7 @@
464470 httpcllr::backend_write_headers_done(void)
465471 {
466472 if (_header_parser->_http_reqtype == REQTYPE_POST) {
 473+std::cout<<"POST "<<_header_parser->_content_length<<" bytes\n";
467474 /*
468475 * Connect the client to the backend and read the POST data.
469476 */
@@ -576,6 +583,13 @@
577584 * HTTP 1.0, insert a dechunking filter.
578585 */
579586 _backend_spigot->sp_disconnect();
 587+
 588+ if (_backend_headers->_response == 304 && _backend_headers->_content_length < 0) {
 589+ /* No body */
 590+ send_body_to_client_done();
 591+ return;
 592+ }
 593+
580594 if (_backend_headers->_flags.f_chunked && _header_parser->_http_vers == http10) {
581595 _dechunking_filter = new dechunking_filter;
582596 _backend_spigot->sp_connect(_dechunking_filter);
@@ -609,6 +623,7 @@
610624 }
611625 _client_sink->_counter = 0;
612626 }
 627+
613628 _backend_spigot->sp_uncork();
614629 }
615630
Index: trunk/willow/src/willow/wnet.cc
@@ -58,7 +58,7 @@
5959
6060 bool wnet_exit;
6161 vector<wsocket *> awaks;
62 -int cawak;
 62+size_t cawak;
6363
6464 void
6565 wnet_add_accept_wakeup(wsocket *s)
Index: trunk/willow/src/willow/willow.cc
@@ -88,11 +88,10 @@
8989 ptdealloc(void *p)
9090 {
9191 vector<pta_block *> *v = (vector<pta_block *> *)p;
92 -std::cout<<"ptdealloc\n";
9392 for (vector<pta_block *>::iterator it = v->begin(), end = v->end();
9493 it != end; ++it) {
9594 pta_block *n = *it, *o;
96 - while (o = n) {
 95+ while ((o = n) != NULL) {
9796 n = n->next;
9897 delete [] (char *)o->addr;
9998 free(o);
Index: trunk/willow/src/willow/whttp_header.cc
@@ -84,23 +84,23 @@
8585 static struct htypent {
8686 char *name;
8787 int n;
88 - int len;
 88+ size_t len;
8989 } list[] = {
90 - { "transfer-encoding", H_TRANSFER_ENCODING },
91 - { "content-length", H_CONTENT_LENGTH },
92 - { "user-agent", H_USER_AGENT },
93 - { "host", H_HOST },
94 - { "connection", H_CONNECTION },
95 - { "location", H_LOCATION },
96 - { "x-willow-backend-group", H_X_WILLOW_BACKEND_GROUP },
97 - { "x-willow-follow-redirect", H_X_WILLOW_FOLLOW_REDIRECT },
98 - { "keep-alive", H_IGNORE },
99 - { "te", H_IGNORE },
100 - { "trailers", H_IGNORE },
101 - { "upgrade", H_IGNORE },
102 - { "proxy-authenticate", H_IGNORE },
103 - { "proxy-connection", H_IGNORE },
104 - { 0, 0 }
 90+ { "transfer-encoding", H_TRANSFER_ENCODING, 0 },
 91+ { "content-length", H_CONTENT_LENGTH, 0 },
 92+ { "user-agent", H_USER_AGENT, 0 },
 93+ { "host", H_HOST, 0 },
 94+ { "connection", H_CONNECTION, 0 },
 95+ { "location", H_LOCATION, 0 },
 96+ { "x-willow-backend-group", H_X_WILLOW_BACKEND_GROUP, 0 },
 97+ { "x-willow-follow-redirect", H_X_WILLOW_FOLLOW_REDIRECT, 0 },
 98+ { "keep-alive", H_IGNORE, 0 },
 99+ { "te", H_IGNORE, 0 },
 100+ { "trailers", H_IGNORE, 0 },
 101+ { "upgrade", H_IGNORE, 0 },
 102+ { "proxy-authenticate", H_IGNORE, 0 },
 103+ { "proxy-connection", H_IGNORE, 0 },
 104+ { 0, 0, 0 }
105105 };
106106 void
107107 whttp_header_init(void)
Index: trunk/willow/src/willow/wbackend.cc
@@ -193,7 +193,7 @@
194194
195195 backend_pool::~backend_pool(void)
196196 {
197 - for (int i = 0; i < backends.size(); ++i)
 197+ for (size_t i = 0; i < backends.size(); ++i)
198198 delete backends[i];
199199 }
200200
@@ -277,7 +277,7 @@
278278
279279 if (!_keptalive)
280280 _keptalive = new vector<pair<wsocket *, backend *> >;
281 - else while (config.keepalive_max && (_keptalive->size() >= config.keepalive_max)) {
 281+ else while (config.keepalive_max && (_keptalive->size() >= (size_t)config.keepalive_max)) {
282282 delete _keptalive->begin()->first;
283283 _keptalive->erase(_keptalive->begin());
284284 }