Index: trunk/willow/src/willow/wnet.cc |
— | — | @@ -274,18 +274,9 @@ |
275 | 275 | { |
276 | 276 | struct wrtbuf *buf; |
277 | 277 | int i; |
278 | | -#ifdef WILLOW_DEBUG |
279 | | - char *p; |
280 | | -#endif |
281 | 278 | |
282 | 279 | buf = (wrtbuf *)e->fde_wdata; |
283 | 280 | while ((i = write(e->fde_fd, (char *)buf->wb_buf + buf->wb_done, buf->wb_size - buf->wb_done)) > -1) { |
284 | | -#ifdef WILLOW_DEBUG_no |
285 | | - (void)fprintf(stderr, "write buf: ["); |
286 | | - for (p = ((char *)buf->wb_buf + buf->wb_done); p < ((char *)buf->wb_buf + buf->wb_done + i); ++p) |
287 | | - (void)fputc(*p, stderr); |
288 | | - (void)fputs("]\n", stderr); |
289 | | -#endif |
290 | 281 | buf->wb_done += i; |
291 | 282 | WDEBUG((WLOG_DEBUG, "%d of %d done", buf->wb_done, buf->wb_size)); |
292 | 283 | if (buf->wb_done == (off_t)buf->wb_size) { |
Index: trunk/willow/src/willow/wbackend.cc |
— | — | @@ -37,7 +37,6 @@ |
38 | 38 | static struct backend *next_backend(string const &url); |
39 | 39 | static uint32_t carp_urlhash(string const &); |
40 | 40 | static uint32_t carp_hosthash(string const &); |
41 | | -static uint32_t carp_combine(string const &, uint32_t); |
42 | 41 | static void carp_recalc(string const &url); |
43 | 42 | static void carp_calc(void); |
44 | 43 | static int becarp_cmp(backend const *a, backend const *b); |
— | — | @@ -159,11 +158,10 @@ |
160 | 159 | wlog(WLOG_WARNING, "%s: [%d] %s; retry in %d seconds", |
161 | 160 | cbd->bc_backend->be_name.c_str(), error, strerror(error), config.backend_retry); |
162 | 161 | cbd->bc_backend->be_dead = 1; |
163 | | - cbd->bc_backend->be_time = time(NULL) + config.backend_retry; |
| 162 | + cbd->bc_backend->be_time = retry; |
164 | 163 | if (get_backend(cbd->bc_url, cbd->bc_func, cbd->bc_data, 0) == -1) { |
165 | 164 | cbd->bc_func(NULL, NULL, cbd->bc_data); |
166 | 165 | } |
167 | | - |
168 | 166 | wfree(cbd); |
169 | 167 | return; |
170 | 168 | } |
— | — | @@ -227,14 +225,6 @@ |
228 | 226 | return rotl(h, 21); |
229 | 227 | } |
230 | 228 | |
231 | | -static uint32_t |
232 | | -carp_combine(string const &url, uint32_t host) |
233 | | -{ |
234 | | - uint32_t c = carp_urlhash(url) ^ host; |
235 | | - c += c * 0x62531965; |
236 | | - return rotl(c, 21); |
237 | | -} |
238 | | - |
239 | 229 | static void |
240 | 230 | carp_calc(void) |
241 | 231 | { |
Index: trunk/willow/src/willow/confparse.cc |
— | — | @@ -117,8 +117,8 @@ |
118 | 118 | if_true(std::string const &if_) |
119 | 119 | { |
120 | 120 | if_entry *e; |
121 | | -char const *dir, *od; |
122 | | - dir = od = if_.c_str(); |
| 121 | +char const *dir; |
| 122 | + dir = if_.c_str(); |
123 | 123 | dir += sizeof("%if"); |
124 | 124 | while (isspace(*dir)) |
125 | 125 | dir++; |
— | — | @@ -202,9 +202,6 @@ |
203 | 203 | bool is_template |
204 | 204 | ) { |
205 | 205 | tree_entry *n, *e; |
206 | | -value *value; |
207 | | -void *pp = NULL; |
208 | | -const char *key; |
209 | 206 | if ((e = t.find(block, templatename)) == NULL) |
210 | 207 | return e; |
211 | 208 | n = t.find_or_new(block, name, pos, unnamed, true); |
— | — | @@ -217,9 +214,6 @@ |
218 | 215 | find_untouched(tree &t) |
219 | 216 | { |
220 | 217 | int i = 0; |
221 | | -const char *key; |
222 | | -value *val; |
223 | | -void *pp = NULL; |
224 | 218 | vector<tree_entry>::const_iterator it, end; |
225 | 219 | map<string, value>::const_iterator vit, vend; |
226 | 220 | for (it = t.entries.begin(), end = t.entries.end(); it != end; ++it) { |
— | — | @@ -264,7 +258,6 @@ |
265 | 259 | bool |
266 | 260 | tree::add(tree_entry const &item) |
267 | 261 | { |
268 | | -value *existing; |
269 | 262 | /* if the entry already exists, do nothing */ |
270 | 263 | if (find_item(item) != NULL) |
271 | 264 | return false; |
Index: trunk/willow/src/willow/wcache.cc |
— | — | @@ -30,7 +30,6 @@ |
31 | 31 | |
32 | 32 | #define CACHEDIR "__objects__" |
33 | 33 | |
34 | | -static void dberror(const char *, int); |
35 | 34 | static int cache_next_id(void); |
36 | 35 | static void run_expiry(int, short, void*); |
37 | 36 | static void wcache_evict(struct cache_object *); |
— | — | @@ -95,7 +94,6 @@ |
96 | 95 | { |
97 | 96 | char *path; |
98 | 97 | int plen; |
99 | | - int i; |
100 | 98 | |
101 | 99 | plen = strlen(config.caches[0].dir) + 1 + sizeof(CACHEDIR) + 1 + 6 + int_max_len; |
102 | 100 | path = (char *)wmalloc(plen + 1); |
— | — | @@ -113,7 +111,7 @@ |
114 | 112 | struct cache_state state; |
115 | 113 | |
116 | 114 | for (cd = config.caches; cd < config.caches + config.ncaches; ++cd) { |
117 | | - size_t len, dlen; |
| 115 | + size_t dlen; |
118 | 116 | char *dir; |
119 | 117 | |
120 | 118 | dlen = strlen(cd->dir) + sizeof(CACHEDIR) + 2 + 6 /* 0/1/2/ */; |
— | — | @@ -179,7 +177,6 @@ |
180 | 178 | wcache_init(int readstate) |
181 | 179 | { |
182 | 180 | struct cachedir *cd; |
183 | | - int i; |
184 | 181 | |
185 | 182 | if (config.ncaches == 0) { |
186 | 183 | wlog(WLOG_WARNING, "no cache directories specified"); |
— | — | @@ -289,11 +286,12 @@ |
290 | 287 | wlog(WLOG_WARNING, "opening cache dir %s: %s", stpath, strerror(errno)); |
291 | 288 | exit(8); |
292 | 289 | } |
293 | | - fprintf(stfil, "%lld %lld\n", state->cs_id, state->cs_size); |
| 290 | + fprintf(stfil, "%llu %llu\n", (w_size_t) state->cs_id, (w_size_t)state->cs_size); |
294 | 291 | TAILQ_FOREACH(obj, &objects, entries) { |
295 | 292 | if (!obj->co_complete) |
296 | 293 | continue; |
297 | | - fprintf(stfil, "%s %s %d %lu %lu %d %lu\n", obj->co_key, obj->co_path, obj->co_size, |
| 294 | + fprintf(stfil, "%s %s %lu %lu %lu %d %lu\n", obj->co_key, obj->co_path, |
| 295 | + (unsigned long) obj->co_size, |
298 | 296 | (unsigned long) obj->co_time, (unsigned long) obj->co_lru, obj->co_id, |
299 | 297 | (unsigned long) obj->co_expires); |
300 | 298 | } |
— | — | @@ -306,10 +304,7 @@ |
307 | 305 | FILE *stfil; |
308 | 306 | char *stpath; |
309 | 307 | int stlen; |
310 | | -struct cache_object *obj; |
311 | | - int i; |
312 | 308 | char *s; |
313 | | - size_t l; |
314 | 309 | |
315 | 310 | stlen = strlen(config.caches[0].dir) + 1 + 5 + 1; |
316 | 311 | if ((stpath = (char *)wmalloc(stlen)) == NULL) |
— | — | @@ -322,7 +317,7 @@ |
323 | 318 | return; |
324 | 319 | } |
325 | 320 | |
326 | | - if (fscanf(stfil, "%lld %lld\n", &state->cs_id, &state->cs_size) != 2) { |
| 321 | + if (fscanf(stfil, "%llu %llu\n", &state->cs_id, &state->cs_size) != 2) { |
327 | 322 | wlog(WLOG_ERROR, "data format error in cache state file %s", stpath); |
328 | 323 | exit(8); |
329 | 324 | } |
— | — | @@ -410,8 +405,6 @@ |
411 | 406 | run_expiry(int fd, short ev, void *data) |
412 | 407 | { |
413 | 408 | w_size_t wantsize; |
414 | | - int i; |
415 | | -struct cache_object *obj; |
416 | 409 | |
417 | 410 | WDEBUG((WLOG_DEBUG, "expire: start, run every %d, cache is %lld bytes large", |
418 | 411 | config.cache_expevery, state.cs_size)); |
Index: trunk/willow/src/willow/wconfig.cc |
— | — | @@ -59,7 +59,7 @@ |
60 | 60 | nl->port = port; |
61 | 61 | nl->name = e.item_key; |
62 | 62 | nl->addr.sin_family = AF_INET; |
63 | | - nl->addr.sin_port = htons(nl->port); |
| 63 | + nl->addr.sin_port = htons((unsigned short)nl->port); |
64 | 64 | nl->addr.sin_addr.s_addr = inet_addr(nl->name.c_str()); |
65 | 65 | wlog(WLOG_NOTICE, "listening on %s:%d", e.item_key.c_str(), port); |
66 | 66 | } |
— | — | @@ -89,8 +89,6 @@ |
90 | 90 | config.ncaches++; |
91 | 91 | } |
92 | 92 | |
93 | | -extern int parse_error; |
94 | | - |
95 | 93 | bool |
96 | 94 | read_config(string const &file) |
97 | 95 | { |
Index: trunk/willow/src/willow/whttp_entity.cc |
— | — | @@ -87,12 +87,7 @@ |
88 | 88 | static int write_zlib_eof(struct http_entity *); |
89 | 89 | static int write_data(struct http_entity *, void *buf, size_t len); |
90 | 90 | |
91 | | -static void entity_send_headers_done(struct fde *, void *, int); |
92 | | -static void entity_send_fde_write_done(struct fde *, void *, int); |
93 | | -static void entity_send_buf_done(struct fde *, void *, int); |
94 | | -static void entity_send_fde_read(struct fde *); |
95 | 91 | static void entity_send_file_done(struct fde *, void *, int); |
96 | | -static void entity_send_target_read(struct bufferevent *, void *); |
97 | 92 | static void entity_send_target_write(struct bufferevent *, void *); |
98 | 93 | static void entity_send_target_error(struct bufferevent *, short, void *); |
99 | 94 | |
— | — | @@ -104,6 +99,7 @@ |
105 | 100 | /* -4 */ "Invalid request type", |
106 | 101 | /* -5 */ "Too many headers", |
107 | 102 | /* -6 */ "Forwarding loop detected", |
| 103 | + /* -7 */ "Invalid Accept-Encoding", |
108 | 104 | }; |
109 | 105 | |
110 | 106 | const char *ent_encodings[] = { |
— | — | @@ -173,16 +169,11 @@ |
174 | 170 | entity_read_callback, NULL, entity_error_callback, entity); |
175 | 171 | bufferevent_disable(entity->_he_frombuf, EV_WRITE); |
176 | 172 | bufferevent_enable(entity->_he_frombuf, EV_READ); |
177 | | -// wnet_register(entity->he_source.fde.fde->fde_fd, FDE_READ, entity_read_callback, entity); |
178 | | - //entity_read_callback(entity->he_source.fde); |
179 | 173 | } |
180 | 174 | |
181 | 175 | void |
182 | 176 | entity_send(fde *fde, http_entity *entity, header_cb cb, void *data, int flags) |
183 | 177 | { |
184 | | - char status[4]; |
185 | | - int wn_flags = 0; |
186 | | - char *hdr; |
187 | 178 | struct header_list *hl; |
188 | 179 | int window = 15; |
189 | 180 | |
— | — | @@ -539,14 +530,6 @@ |
540 | 531 | } |
541 | 532 | |
542 | 533 | static void |
543 | | -entity_send_target_read(struct bufferevent *buf, void *d) |
544 | | -{ |
545 | | - /* |
546 | | - * Read from target possible. This never happens. |
547 | | - */ |
548 | | -} |
549 | | - |
550 | | -static void |
551 | 534 | entity_send_target_write(struct bufferevent *buf, void *d) |
552 | 535 | { |
553 | 536 | struct http_entity *entity = (http_entity *)d; |
— | — | @@ -873,13 +856,13 @@ |
874 | 857 | write(fd, &i, sizeof(i)); |
875 | 858 | |
876 | 859 | while (head->hl_next) { |
877 | | - int i, j; |
| 860 | + int j, k; |
878 | 861 | head = head->hl_next; |
879 | | - i = strlen(head->hl_name); |
880 | | - write(fd, &i, sizeof(i)); |
| 862 | + k = strlen(head->hl_name); |
| 863 | + write(fd, &k, sizeof(k)); |
881 | 864 | j = strlen(head->hl_value); |
882 | 865 | write(fd, &j, sizeof(j)); |
883 | | - write(fd, head->hl_name, i); |
| 866 | + write(fd, head->hl_name, k); |
884 | 867 | write(fd, head->hl_value, j); |
885 | 868 | } |
886 | 869 | } |
— | — | @@ -887,21 +870,21 @@ |
888 | 871 | int |
889 | 872 | header_undump(header_list *head, int fd, off_t *len) |
890 | 873 | { |
891 | | - int i = 0, j = 0, n = 0; |
| 874 | + int i = 0, j = 0, sz = 0; |
892 | 875 | struct header_list *it = head; |
893 | 876 | ssize_t r; |
894 | 877 | |
895 | 878 | *len = 0; |
896 | 879 | bzero(head, sizeof(*head)); |
897 | | - if ((r = read(fd, &n, sizeof(n))) < 0) { |
| 880 | + if ((r = read(fd, &sz, sizeof(sz))) < 0) { |
898 | 881 | wlog(WLOG_WARNING, "reading cache file: %s", strerror(errno)); |
899 | 882 | return -1; /* XXX */ |
900 | 883 | } |
901 | 884 | |
902 | 885 | *len += r; |
903 | | - WDEBUG((WLOG_DEBUG, "header_undump: %d entries", n)); |
| 886 | + WDEBUG((WLOG_DEBUG, "header_undump: %d entries", sz)); |
904 | 887 | |
905 | | - while (n--) { |
| 888 | + while (sz--) { |
906 | 889 | char *n, *v, *s; |
907 | 890 | int k; |
908 | 891 | |
— | — | @@ -967,7 +950,7 @@ |
968 | 951 | if (isspace(*line)) { |
969 | 952 | char *s = line; |
970 | 953 | if (!entity->he_headers.hl_next) { |
971 | | - error = -1; |
| 954 | + error = ENT_ERR_INVHDR; |
972 | 955 | goto error; |
973 | 956 | } |
974 | 957 | while (isspace(*s)) |
— | — | @@ -1022,7 +1005,7 @@ |
1023 | 1006 | } else if (!strcasecmp(hdr[0], "Accept-Encoding")) { |
1024 | 1007 | if (!entity->he_flags.response && |
1025 | 1008 | qvalue_parse(&entity->he_rdata.request.accept_encoding, value) == -1) { |
1026 | | - error = -1; |
| 1009 | + error = ENT_ERR_INVAE; |
1027 | 1010 | WDEBUG((WLOG_DEBUG, "a-e parse failed")); |
1028 | 1011 | goto error; |
1029 | 1012 | } |
— | — | @@ -1052,7 +1035,7 @@ |
1053 | 1036 | if (value) |
1054 | 1037 | wfree(value); |
1055 | 1038 | free(line); |
1056 | | - return -1; |
| 1039 | + return -error; |
1057 | 1040 | } |
1058 | 1041 | |
1059 | 1042 | free(line); |
Index: trunk/willow/src/willow/wnet_libevent.cc |
— | — | @@ -42,9 +42,11 @@ |
43 | 43 | |
44 | 44 | static void fde_ev_callback(int, short, void *); |
45 | 45 | |
46 | | -void sig_exit(int, short, void *); |
| 46 | +static void |
| 47 | +sig_exit(int, short, void *); |
47 | 48 | |
48 | | -void sig_exit(int sig, short what, void *d) |
| 49 | +void |
| 50 | +sig_exit(int sig, short what, void *d) |
49 | 51 | { |
50 | 52 | exit(0); |
51 | 53 | } |
— | — | @@ -52,8 +54,6 @@ |
53 | 55 | void |
54 | 56 | wnet_init_select(void) |
55 | 57 | { |
56 | | - int i; |
57 | | - |
58 | 58 | signal(SIGPIPE, SIG_IGN); |
59 | 59 | event_init(); |
60 | 60 | |
Index: trunk/willow/src/willow/whttp.cc |
— | — | @@ -91,9 +91,9 @@ |
92 | 92 | int cl_cfd; /* FD of cache file for writing, or 0 */ |
93 | 93 | struct cache_object *cl_co; /* Cache object */ |
94 | 94 | struct { |
95 | | - int f_cached:1; |
96 | | - int f_closed:1; |
97 | | - int f_http11:1; /* Client understands HTTP/1.1 */ |
| 95 | + unsigned int f_cached:1; |
| 96 | + unsigned int f_closed:1; |
| 97 | + unsigned int f_http11:1; /* Client understands HTTP/1.1 */ |
98 | 98 | } cl_flags; |
99 | 99 | size_t cl_dsize; /* Object size */ |
100 | 100 | enum encoding cl_enc; |
— | — | @@ -101,7 +101,6 @@ |
102 | 102 | }; |
103 | 103 | |
104 | 104 | static struct http_client freelist; |
105 | | -static struct http_client deadlist; |
106 | 105 | |
107 | 106 | static void client_close(struct http_client *); |
108 | 107 | static void proxy_start_backend(struct backend *, struct fde *, void *); |
— | — | @@ -239,7 +238,6 @@ |
240 | 239 | client_read_done(http_entity *entity, void *data, int res) |
241 | 240 | { |
242 | 241 | struct http_client *client = (http_client *)data; |
243 | | -struct cache_object *cobj; |
244 | 242 | char *pragma, *cache_control, *ifmod; |
245 | 243 | struct qvalue_head *acceptenc; |
246 | 244 | struct qvalue *val; |
— | — | @@ -464,8 +462,6 @@ |
465 | 463 | client_headers_done(http_entity *entity, void *data, int res) |
466 | 464 | { |
467 | 465 | struct http_client *client = (http_client *)data; |
468 | | - char *cache_path; |
469 | | - size_t plen; |
470 | 466 | |
471 | 467 | WDEBUG((WLOG_DEBUG, "client_headers_done: called")); |
472 | 468 | |
— | — | @@ -499,9 +495,9 @@ |
500 | 496 | */ |
501 | 497 | if ((lastmod = entity->he_h_last_modified) != NULL) { |
502 | 498 | struct tm tim; |
503 | | - char *res; |
504 | | - res = strptime(lastmod, "%a, %d %b %Y %H:%M:%S", &tim); |
505 | | - if (res) { |
| 499 | + char *lm; |
| 500 | + lm = strptime(lastmod, "%a, %d %b %Y %H:%M:%S", &tim); |
| 501 | + if (lm) { |
506 | 502 | WDEBUG((WLOG_DEBUG, "last-modified: %d", mktime(&tim))); |
507 | 503 | client->cl_co->co_time = mktime(&tim); |
508 | 504 | } |
— | — | @@ -552,7 +548,7 @@ |
553 | 549 | header_add(&client->cl_entity.he_headers, wstrdup("Via"), wstrdup(via_hdr)); |
554 | 550 | header_add(&client->cl_entity.he_headers, wstrdup("X-Cache"), wstrdup(cache_hit_hdr)); |
555 | 551 | if (!client->cl_enc && !header_find(&client->cl_entity.he_headers, "Content-Length")) { |
556 | | - snprintf(size, sizeof(size), "%d", client->cl_co->co_size); |
| 552 | + snprintf(size, sizeof(size), "%lu", (unsigned long) client->cl_co->co_size); |
557 | 553 | header_add(&client->cl_entity.he_headers, wstrdup("Content-Length"), wstrdup(size)); |
558 | 554 | } |
559 | 555 | |
Index: trunk/willow/src/include/willow.h |
— | — | @@ -16,6 +16,10 @@ |
17 | 17 | |
18 | 18 | #include <sstream> |
19 | 19 | |
| 20 | +#ifdef __INTEL_COMPILER |
| 21 | +# pragma warning (disable: 869 981 304 383 1418 1469 810) |
| 22 | +#endif |
| 23 | + |
20 | 24 | template<typename To, typename From> |
21 | 25 | To lexical_cast(From const &f) |
22 | 26 | { |
— | — | @@ -25,7 +29,7 @@ |
26 | 30 | strm >> t; |
27 | 31 | return t; |
28 | 32 | } |
29 | | - |
| 33 | + |
30 | 34 | typedef unsigned long long w_size_t; |
31 | 35 | |
32 | 36 | #ifdef WDEBUG_ALLOC |
Index: trunk/willow/src/include/wnet.h |
— | — | @@ -62,9 +62,9 @@ |
63 | 63 | int fde_epflags; |
64 | 64 | struct readbuf fde_readbuf; |
65 | 65 | struct { |
66 | | - int open:1; |
67 | | - int held:1; |
68 | | - int pend:1; |
| 66 | + unsigned int open:1; |
| 67 | + unsigned int held:1; |
| 68 | + unsigned int pend:1; |
69 | 69 | } fde_flags; |
70 | 70 | struct event fde_ev; |
71 | 71 | }; |
Index: trunk/willow/src/include/whttp_entity.h |
— | — | @@ -35,6 +35,7 @@ |
36 | 36 | #define ENT_ERR_INVREQ -4 /* invalid request type */ |
37 | 37 | #define ENT_ERR_2MANY -5 /* too many headers */ |
38 | 38 | #define ENT_ERR_LOOP -6 /* forwarding loop detected */ |
| 39 | +#define ENT_ERR_INVAE -7 /* invalid accept-encoding */ |
39 | 40 | |
40 | 41 | #define TE_CHUNKED 0x1 /* Chunked encoding */ |
41 | 42 | |
— | — | @@ -77,7 +78,7 @@ |
78 | 79 | E_DEFLATE, |
79 | 80 | E_X_DEFLATE, |
80 | 81 | E_GZIP, |
81 | | - E_X_GZIP, |
| 82 | + E_X_GZIP |
82 | 83 | }; |
83 | 84 | |
84 | 85 | struct http_entity { |
— | — | @@ -131,13 +132,13 @@ |
132 | 133 | } he_source; |
133 | 134 | |
134 | 135 | struct { |
135 | | - int cachable:1; |
136 | | - int response:1; |
137 | | - int error:1; |
138 | | - int hdr_only:1; |
139 | | - int eof:1; |
140 | | - int drained:1; |
141 | | - int chunked:1; |
| 136 | + unsigned int cachable:1; |
| 137 | + unsigned int response:1; |
| 138 | + unsigned int error:1; |
| 139 | + unsigned int hdr_only:1; |
| 140 | + unsigned int eof:1; |
| 141 | + unsigned int drained:1; |
| 142 | + unsigned int chunked:1; |
142 | 143 | } he_flags; |
143 | 144 | |
144 | 145 | int he_te; /* transfer encoding */ |