Index: trunk/loreley/configure.in |
— | — | @@ -203,7 +203,7 @@ |
204 | 204 | if test "$solio" = "no"; then |
205 | 205 | AC_SEARCH_LIBS(event_add, event,,AC_MSG_ERROR([libevent not found (maybe you need --with-libevent)])) |
206 | 206 | fi |
207 | | -AC_SEARCH_LIBS(db_create, db-4.5 db-4.4 db-4.3 db-4.2,,AC_MSG_ERROR([Berkeley DB not found])) |
| 207 | +AC_SEARCH_LIBS(db_create, db-4.5 db-4.4 db-4.3 db-4.2,,[AC_DEFINE([NO_BDB],,[Berkeley DB is not available])]) |
208 | 208 | |
209 | 209 | AC_CHECK_TYPES([u_int8_t, u_int16_t, u_int32_t, u_int64_t]) |
210 | 210 | |
Index: trunk/loreley/src/include/cache.h |
— | — | @@ -24,6 +24,7 @@ |
25 | 25 | #include "http_header.h" |
26 | 26 | #include "dbwrap.h" |
27 | 27 | |
| 28 | +#ifndef NO_BDB |
28 | 29 | struct caching_filter; |
29 | 30 | struct cached_spigot; |
30 | 31 | struct cachefile; |
— | — | @@ -570,4 +571,5 @@ |
571 | 572 | |
572 | 573 | extern httpcache entitycache; |
573 | 574 | |
574 | | -#endif |
| 575 | +#endif /* !NO_BDB */ |
| 576 | +#endif /* CACHE_H */ |
Index: trunk/loreley/src/include/dbwrap.h |
— | — | @@ -17,6 +17,8 @@ |
18 | 18 | using std::make_pair; |
19 | 19 | using std::back_inserter; |
20 | 20 | |
| 21 | +#ifndef NO_BDB |
| 22 | + |
21 | 23 | #include <db.h> |
22 | 24 | |
23 | 25 | #include "loreley.h" |
— | — | @@ -376,4 +378,5 @@ |
377 | 379 | |
378 | 380 | } // namespace db |
379 | 381 | |
380 | | -#endif |
| 382 | +#endif /* !NO_BDB */ |
| 383 | +#endif /* !DBWRAP_H */ |
Index: trunk/loreley/src/include/stdinc.h |
— | — | @@ -99,6 +99,8 @@ |
100 | 100 | #include <pwd.h> |
101 | 101 | #include <grp.h> |
102 | 102 | |
103 | | -#include <db.h> |
| 103 | +#ifndef NO_BDB |
| 104 | +# include <db.h> |
| 105 | +#endif |
104 | 106 | |
105 | 107 | #endif /* STDINC_H */ |
Index: trunk/loreley/src/loreley/htcp.cc |
— | — | @@ -112,7 +112,11 @@ |
113 | 113 | htcp_opdata_tst const *opd = static_cast<htcp_opdata_tst const *>(ip.opdata()); |
114 | 114 | WDEBUG(format("HTCP: TST: url=[%s]") |
115 | 115 | % opd->tst_specifier.hs_url); |
| 116 | +#ifndef NO_BDB |
116 | 117 | bool cached = entitycache.cached(opd->tst_specifier.hs_url); |
| 118 | +#else |
| 119 | + bool cached = false; |
| 120 | +#endif |
117 | 121 | htcp_opdata_tst_resp_found tf; |
118 | 122 | htcp_opdata_tst_resp_notfound tnf; |
119 | 123 | |
— | — | @@ -133,7 +137,11 @@ |
134 | 138 | case htcp_op_clr: { |
135 | 139 | htcp_opdata_clr const *opd = static_cast<htcp_opdata_clr const *>(ip.opdata()); |
136 | 140 | htcp_opdata_clr_resp rd; |
| 141 | +#ifndef NO_BDB |
137 | 142 | bool wascached = entitycache.purge(opd->clr_specifier.hs_url); |
| 143 | +#else |
| 144 | + bool wascached = false; |
| 145 | +#endif |
138 | 146 | |
139 | 147 | if (!ip.rd()) |
140 | 148 | break; |
Index: trunk/loreley/src/loreley/a_cachedir.cc |
— | — | @@ -17,6 +17,8 @@ |
18 | 18 | |
19 | 19 | #include "cache.h" |
20 | 20 | |
| 21 | +#ifndef NO_BDB |
| 22 | + |
21 | 23 | a_cachedir::a_cachedir(imstring const &path, int num) |
22 | 24 | : _path(path) |
23 | 25 | , _dnum(num) |
— | — | @@ -38,3 +40,5 @@ |
39 | 41 | imstring path = (format("%s/%d") % _path % n).str(); |
40 | 42 | return new cachefile(path, _dnum, n, true); |
41 | 43 | } |
| 44 | + |
| 45 | +#endif /* NO_BDB */ |
Index: trunk/loreley/src/loreley/cache.cc |
— | — | @@ -21,6 +21,8 @@ |
22 | 22 | #include "cache.h" |
23 | 23 | #include "config.h" |
24 | 24 | |
| 25 | +#ifndef NO_BDB |
| 26 | + |
25 | 27 | httpcache entitycache; |
26 | 28 | |
27 | 29 | httpcache::httpcache(void) |
— | — | @@ -310,3 +312,4 @@ |
311 | 313 | return _store->open(dirn, num); |
312 | 314 | } |
313 | 315 | |
| 316 | +#endif /* NO_BDB */ |
Index: trunk/loreley/src/loreley/cachedentity.cc |
— | — | @@ -21,6 +21,8 @@ |
22 | 22 | #include "mbuffer.h" |
23 | 23 | #include "config.h" |
24 | 24 | |
| 25 | +#ifndef NO_BDB |
| 26 | + |
25 | 27 | cachedentity::cachedentity(imstring const &url, size_t hint) |
26 | 28 | : _url(url) |
27 | 29 | , _data(hint ? hint : 4096) |
— | — | @@ -256,3 +258,5 @@ |
257 | 259 | _cachefile = f->filenum(); |
258 | 260 | return true; |
259 | 261 | } |
| 262 | + |
| 263 | +#endif /* NO_BDB */ |
Index: trunk/loreley/src/loreley/cachedir_data_store.cc |
— | — | @@ -18,6 +18,8 @@ |
19 | 19 | #include "cache.h" |
20 | 20 | #include "config.h" |
21 | 21 | |
| 22 | +#ifndef NO_BDB |
| 23 | + |
22 | 24 | /* |
23 | 25 | * Create the cachedir list. |
24 | 26 | */ |
— | — | @@ -109,3 +111,5 @@ |
110 | 112 | delete f; |
111 | 113 | return ret; |
112 | 114 | } |
| 115 | + |
| 116 | +#endif /* !NO_BDB */ |
Index: trunk/loreley/src/loreley/loreley.cc |
— | — | @@ -158,11 +158,13 @@ |
159 | 159 | if (!wlog.open()) |
160 | 160 | return 1; |
161 | 161 | |
| 162 | +#ifndef NO_BDB |
162 | 163 | if (zflag) { |
163 | 164 | if (!entitycache.create()) |
164 | 165 | return 1; |
165 | 166 | return 0; |
166 | 167 | } |
| 168 | +#endif |
167 | 169 | |
168 | 170 | if (!config.pidfile.empty()) { |
169 | 171 | struct stat sb; |
— | — | @@ -194,8 +196,10 @@ |
195 | 197 | |
196 | 198 | make_event_base(); |
197 | 199 | ioloop = new ioloop_t; |
| 200 | +#ifndef NO_BDB |
198 | 201 | if (!entitycache.open()) |
199 | 202 | return 1; |
| 203 | +#endif |
200 | 204 | |
201 | 205 | whttp_init(); |
202 | 206 | stats_init(); |
— | — | @@ -221,7 +225,9 @@ |
222 | 226 | wlog.notice("shutting down"); |
223 | 227 | wlog.close(); |
224 | 228 | whttp_shutdown(); |
| 229 | +#ifndef NO_BDB |
225 | 230 | entitycache.close(); |
| 231 | +#endif |
226 | 232 | |
227 | 233 | pthread_exit(NULL); |
228 | 234 | return EXIT_SUCCESS; |
Index: trunk/loreley/src/loreley/dbwrap.cc |
— | — | @@ -18,6 +18,7 @@ |
19 | 19 | #include "dbwrap.h" |
20 | 20 | #include "mbuffer.h" |
21 | 21 | |
| 22 | +#ifndef NO_BDB |
22 | 23 | namespace db { |
23 | 24 | |
24 | 25 | environment * |
— | — | @@ -128,3 +129,4 @@ |
129 | 130 | } |
130 | 131 | |
131 | 132 | } // namespace db |
| 133 | +#endif /* NO_BDB */ |
Index: trunk/loreley/src/loreley/http.cc |
— | — | @@ -124,7 +124,6 @@ |
125 | 125 | void error_send_done (void); |
126 | 126 | |
127 | 127 | void send_error(int, char const *, int, char const *); |
128 | | - void send_cached(void); |
129 | 128 | void log_request (void); |
130 | 129 | |
131 | 130 | wsocket *_client_socket; |
— | — | @@ -143,9 +142,15 @@ |
144 | 143 | error_transform_filter *_error_filter; |
145 | 144 | chunking_filter *_chunking_filter; |
146 | 145 | io::size_limiting_filter *_size_limit; |
| 146 | + |
| 147 | +#ifndef NO_BDB |
| 148 | + void send_cached(void); |
| 149 | + |
147 | 150 | shared_ptr<cachedentity> _cachedent; |
148 | 151 | caching_filter *_cache_filter; |
149 | 152 | cached_spigot *_cache_spigot; |
| 153 | + bool _validating; |
| 154 | +#endif |
150 | 155 | |
151 | 156 | backend_list *_blist; |
152 | 157 | enum { |
— | — | @@ -158,7 +163,6 @@ |
159 | 164 | imstring _request_host; |
160 | 165 | imstring _request_path; |
161 | 166 | int _nredir; |
162 | | - bool _validating; |
163 | 167 | |
164 | 168 | private: |
165 | 169 | httpcllr(const httpcllr &); |
— | — | @@ -180,14 +184,16 @@ |
181 | 185 | , _error_filter(NULL) |
182 | 186 | , _chunking_filter(NULL) |
183 | 187 | , _size_limit(NULL) |
| 188 | +#ifndef NO_BDB |
184 | 189 | , _cache_filter(NULL) |
185 | 190 | , _cache_spigot(NULL) |
| 191 | + , _validating(false) |
| 192 | +#endif |
186 | 193 | , _blist(NULL) |
187 | 194 | , _denied(denied_no) |
188 | 195 | , _group(gr) |
189 | 196 | , _response(0) |
190 | 197 | , _nredir(0) |
191 | | - , _validating(false) |
192 | 198 | { |
193 | 199 | /* |
194 | 200 | * Check access controls. |
— | — | @@ -270,6 +276,7 @@ |
271 | 277 | _chunking_filter = NULL; |
272 | 278 | delete _size_limit; |
273 | 279 | _size_limit = NULL; |
| 280 | +#ifndef NO_BDB |
274 | 281 | delete _cache_filter; |
275 | 282 | _cache_filter = NULL; |
276 | 283 | delete _cache_spigot; |
— | — | @@ -277,6 +284,7 @@ |
278 | 285 | if (_cachedent) |
279 | 286 | entitycache.release(_cachedent); |
280 | 287 | _cachedent.reset(); |
| 288 | +#endif |
281 | 289 | |
282 | 290 | /* |
283 | 291 | * Return the backend to the keepalive pool, if we can. |
— | — | @@ -329,13 +337,16 @@ |
330 | 338 | delete _error_body; |
331 | 339 | delete _chunking_filter; |
332 | 340 | delete _size_limit; |
| 341 | + delete _blist; |
| 342 | +#ifndef NO_BDB |
333 | 343 | delete _cache_filter; |
334 | | - delete _blist; |
335 | 344 | delete _cache_spigot; |
| 345 | +#endif |
336 | 346 | delete _client_spigot; |
337 | 347 | delete _client_socket; |
338 | 348 | } |
339 | 349 | |
| 350 | +#ifndef NO_BDB |
340 | 351 | void |
341 | 352 | httpcllr::send_cached(void) |
342 | 353 | { |
— | — | @@ -361,6 +372,7 @@ |
362 | 373 | _cache_spigot->sp_uncork(); |
363 | 374 | return; |
364 | 375 | } |
| 376 | +#endif |
365 | 377 | |
366 | 378 | void |
367 | 379 | httpcllr::header_read_complete(void) |
— | — | @@ -399,6 +411,7 @@ |
400 | 412 | /* |
401 | 413 | * See if this entity has been cached. |
402 | 414 | */ |
| 415 | +#ifndef NO_BDB |
403 | 416 | if (_header_parser->_http_reqtype != REQTYPE_POST) { |
404 | 417 | bool created = false; |
405 | 418 | string url = str(format("http://%s%s") % _header_parser->_http_host |
— | — | @@ -440,6 +453,7 @@ |
441 | 454 | } |
442 | 455 | } |
443 | 456 | } |
| 457 | +#endif |
444 | 458 | |
445 | 459 | /* |
446 | 460 | * If we get here for a PURGE request, it means that the requested |
— | — | @@ -634,12 +648,14 @@ |
635 | 649 | _response = _backend_headers->_response; |
636 | 650 | stats.tcur->n_httpresp_ok++; |
637 | 651 | |
| 652 | +#ifndef NO_BDB |
638 | 653 | if (_validating && _response == 304) { |
639 | 654 | /* Our cached entity was still valid */ |
640 | 655 | _cachedent->revalidated(); |
641 | 656 | send_cached(); |
642 | 657 | return; |
643 | 658 | } |
| 659 | +#endif |
644 | 660 | |
645 | 661 | /* |
646 | 662 | * Check for X-Loreley-Follow-Redirect header, which means we should |
— | — | @@ -659,6 +675,7 @@ |
660 | 676 | return; |
661 | 677 | } |
662 | 678 | |
| 679 | +#ifndef NO_BDB |
663 | 680 | /* |
664 | 681 | * If we're caching this entity, store the headers. |
665 | 682 | */ |
— | — | @@ -668,6 +685,7 @@ |
669 | 686 | _cachedent->store_status(status, _backend_headers->_response); |
670 | 687 | _cachedent->store_headers(_backend_headers->_headers); |
671 | 688 | } |
| 689 | +#endif |
672 | 690 | |
673 | 691 | /* |
674 | 692 | * If the client is HTTP/1.0 or MSIE, we need to dechunk. |
— | — | @@ -728,10 +746,12 @@ |
729 | 747 | /* |
730 | 748 | * See if we can cache this entity. |
731 | 749 | */ |
| 750 | +#ifndef NO_BDB |
732 | 751 | if (_cachedent) { |
733 | 752 | cache = true; |
734 | 753 | _cache_filter = new caching_filter(_cachedent); |
735 | 754 | } |
| 755 | +#endif |
736 | 756 | |
737 | 757 | _backend_spigot->sp_disconnect(); |
738 | 758 | |
— | — | @@ -767,6 +787,7 @@ |
768 | 788 | } |
769 | 789 | |
770 | 790 | /* if we're caching, insert the caching filter */ |
| 791 | +#ifndef NO_BDB |
771 | 792 | if (cache) { |
772 | 793 | cur = &(*cur >> *_cache_filter); |
773 | 794 | /* if we dechunked it to cache, rechunk now */ |
— | — | @@ -775,6 +796,7 @@ |
776 | 797 | cur = &(*cur >> *_chunking_filter); |
777 | 798 | } |
778 | 799 | } |
| 800 | +#endif |
779 | 801 | |
780 | 802 | /* finally, connect to the client */ |
781 | 803 | *cur >> *_client_sink; |
— | — | @@ -1178,7 +1200,11 @@ |
1179 | 1201 | % size |
1180 | 1202 | % _response |
1181 | 1203 | % (_backend ? _backend->be_name : string("-")) |
| 1204 | +#ifndef NO_BDB |
1182 | 1205 | % ((_cachedent && !_backend) ? "HIT" : "MISS")); |
| 1206 | +#else |
| 1207 | + % "MISS"); |
| 1208 | +#endif |
1183 | 1209 | |
1184 | 1210 | if (!(alf << line << endl)) { |
1185 | 1211 | wlog.error(format( |
— | — | @@ -1217,7 +1243,11 @@ |
1218 | 1244 | ADD_STRING(bufp, _request_path, endp); |
1219 | 1245 | ADD_UINT16(bufp, _response, endp); |
1220 | 1246 | ADD_STRING(bufp, string(_backend ? _backend->be_name : "-"), endp); |
| 1247 | +#ifndef NO_BDB |
1221 | 1248 | ADD_UINT8(bufp, (_cachedent && !_backend) ? 1 : 0, endp); |
| 1249 | +#else |
| 1250 | + ADD_UINT8(bufp, 0, endp); |
| 1251 | +#endif |
1222 | 1252 | ADD_UINT32(bufp, size, endp); |
1223 | 1253 | udplog_sock->write(buf, bufp - buf); |
1224 | 1254 | } |
Index: trunk/loreley/src/loreley/net_solaris.cc |
— | — | @@ -585,6 +585,7 @@ |
586 | 586 | : _addr(a) |
587 | 587 | , _desc(desc) |
588 | 588 | , _prio(p) |
| 589 | + , _queue(0) |
589 | 590 | { |
590 | 591 | _s = s; |
591 | 592 | } |
— | — | @@ -593,6 +594,7 @@ |
594 | 595 | : _addr(a) |
595 | 596 | , _desc(desc) |
596 | 597 | , _prio(p) |
| 598 | + , _queue(0) |
597 | 599 | { |
598 | 600 | _s = ::socket(_addr.family(), _addr.socktype(), _addr.protocol()); |
599 | 601 | if (_s == -1) |
— | — | @@ -618,7 +620,8 @@ |
619 | 621 | socket::~socket(void) |
620 | 622 | { |
621 | 623 | WDEBUG("closing socket"); |
622 | | - port_dissociate(_queue->portfd, PORT_SOURCE_FD, _s); |
| 624 | + if (_queue) |
| 625 | + port_dissociate(_queue->portfd, PORT_SOURCE_FD, _s); |
623 | 626 | close(_s); |
624 | 627 | } |
625 | 628 | |
— | — | @@ -730,7 +733,7 @@ |
731 | 734 | port_event_t ev; |
732 | 735 | net::socket *sk; |
733 | 736 | |
734 | | - while (port_get(eq->portfd, &ev, NULL)) { |
| 737 | + while (port_get(eq->portfd, &ev, NULL) == 0) { |
735 | 738 | WDEBUG(format("[%d] thread_run: waiting for event, eq=%p") |
736 | 739 | % pthread_self() % eq); |
737 | 740 | |