r19346 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r19345‎ | r19346 | r19347 >
Date:20:40, 16 January 2007
Author:river
Status:old
Tags:
Comment:
make bdb optional
net_solaris fixes
Modified paths:
  • /trunk/loreley/configure.in (modified) (history)
  • /trunk/loreley/src/include/cache.h (modified) (history)
  • /trunk/loreley/src/include/dbwrap.h (modified) (history)
  • /trunk/loreley/src/include/stdinc.h (modified) (history)
  • /trunk/loreley/src/loreley/a_cachedir.cc (modified) (history)
  • /trunk/loreley/src/loreley/cache.cc (modified) (history)
  • /trunk/loreley/src/loreley/cachedentity.cc (modified) (history)
  • /trunk/loreley/src/loreley/cachedir_data_store.cc (modified) (history)
  • /trunk/loreley/src/loreley/dbwrap.cc (modified) (history)
  • /trunk/loreley/src/loreley/htcp.cc (modified) (history)
  • /trunk/loreley/src/loreley/http.cc (modified) (history)
  • /trunk/loreley/src/loreley/loreley.cc (modified) (history)
  • /trunk/loreley/src/loreley/net_solaris.cc (modified) (history)

Diff [purge]

Index: trunk/loreley/configure.in
@@ -203,7 +203,7 @@
204204 if test "$solio" = "no"; then
205205 AC_SEARCH_LIBS(event_add, event,,AC_MSG_ERROR([libevent not found (maybe you need --with-libevent)]))
206206 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])])
208208
209209 AC_CHECK_TYPES([u_int8_t, u_int16_t, u_int32_t, u_int64_t])
210210
Index: trunk/loreley/src/include/cache.h
@@ -24,6 +24,7 @@
2525 #include "http_header.h"
2626 #include "dbwrap.h"
2727
 28+#ifndef NO_BDB
2829 struct caching_filter;
2930 struct cached_spigot;
3031 struct cachefile;
@@ -570,4 +571,5 @@
571572
572573 extern httpcache entitycache;
573574
574 -#endif
 575+#endif /* !NO_BDB */
 576+#endif /* CACHE_H */
Index: trunk/loreley/src/include/dbwrap.h
@@ -17,6 +17,8 @@
1818 using std::make_pair;
1919 using std::back_inserter;
2020
 21+#ifndef NO_BDB
 22+
2123 #include <db.h>
2224
2325 #include "loreley.h"
@@ -376,4 +378,5 @@
377379
378380 } // namespace db
379381
380 -#endif
 382+#endif /* !NO_BDB */
 383+#endif /* !DBWRAP_H */
Index: trunk/loreley/src/include/stdinc.h
@@ -99,6 +99,8 @@
100100 #include <pwd.h>
101101 #include <grp.h>
102102
103 -#include <db.h>
 103+#ifndef NO_BDB
 104+# include <db.h>
 105+#endif
104106
105107 #endif /* STDINC_H */
Index: trunk/loreley/src/loreley/htcp.cc
@@ -112,7 +112,11 @@
113113 htcp_opdata_tst const *opd = static_cast<htcp_opdata_tst const *>(ip.opdata());
114114 WDEBUG(format("HTCP: TST: url=[%s]")
115115 % opd->tst_specifier.hs_url);
 116+#ifndef NO_BDB
116117 bool cached = entitycache.cached(opd->tst_specifier.hs_url);
 118+#else
 119+ bool cached = false;
 120+#endif
117121 htcp_opdata_tst_resp_found tf;
118122 htcp_opdata_tst_resp_notfound tnf;
119123
@@ -133,7 +137,11 @@
134138 case htcp_op_clr: {
135139 htcp_opdata_clr const *opd = static_cast<htcp_opdata_clr const *>(ip.opdata());
136140 htcp_opdata_clr_resp rd;
 141+#ifndef NO_BDB
137142 bool wascached = entitycache.purge(opd->clr_specifier.hs_url);
 143+#else
 144+ bool wascached = false;
 145+#endif
138146
139147 if (!ip.rd())
140148 break;
Index: trunk/loreley/src/loreley/a_cachedir.cc
@@ -17,6 +17,8 @@
1818
1919 #include "cache.h"
2020
 21+#ifndef NO_BDB
 22+
2123 a_cachedir::a_cachedir(imstring const &path, int num)
2224 : _path(path)
2325 , _dnum(num)
@@ -38,3 +40,5 @@
3941 imstring path = (format("%s/%d") % _path % n).str();
4042 return new cachefile(path, _dnum, n, true);
4143 }
 44+
 45+#endif /* NO_BDB */
Index: trunk/loreley/src/loreley/cache.cc
@@ -21,6 +21,8 @@
2222 #include "cache.h"
2323 #include "config.h"
2424
 25+#ifndef NO_BDB
 26+
2527 httpcache entitycache;
2628
2729 httpcache::httpcache(void)
@@ -310,3 +312,4 @@
311313 return _store->open(dirn, num);
312314 }
313315
 316+#endif /* NO_BDB */
Index: trunk/loreley/src/loreley/cachedentity.cc
@@ -21,6 +21,8 @@
2222 #include "mbuffer.h"
2323 #include "config.h"
2424
 25+#ifndef NO_BDB
 26+
2527 cachedentity::cachedentity(imstring const &url, size_t hint)
2628 : _url(url)
2729 , _data(hint ? hint : 4096)
@@ -256,3 +258,5 @@
257259 _cachefile = f->filenum();
258260 return true;
259261 }
 262+
 263+#endif /* NO_BDB */
Index: trunk/loreley/src/loreley/cachedir_data_store.cc
@@ -18,6 +18,8 @@
1919 #include "cache.h"
2020 #include "config.h"
2121
 22+#ifndef NO_BDB
 23+
2224 /*
2325 * Create the cachedir list.
2426 */
@@ -109,3 +111,5 @@
110112 delete f;
111113 return ret;
112114 }
 115+
 116+#endif /* !NO_BDB */
Index: trunk/loreley/src/loreley/loreley.cc
@@ -158,11 +158,13 @@
159159 if (!wlog.open())
160160 return 1;
161161
 162+#ifndef NO_BDB
162163 if (zflag) {
163164 if (!entitycache.create())
164165 return 1;
165166 return 0;
166167 }
 168+#endif
167169
168170 if (!config.pidfile.empty()) {
169171 struct stat sb;
@@ -194,8 +196,10 @@
195197
196198 make_event_base();
197199 ioloop = new ioloop_t;
 200+#ifndef NO_BDB
198201 if (!entitycache.open())
199202 return 1;
 203+#endif
200204
201205 whttp_init();
202206 stats_init();
@@ -221,7 +225,9 @@
222226 wlog.notice("shutting down");
223227 wlog.close();
224228 whttp_shutdown();
 229+#ifndef NO_BDB
225230 entitycache.close();
 231+#endif
226232
227233 pthread_exit(NULL);
228234 return EXIT_SUCCESS;
Index: trunk/loreley/src/loreley/dbwrap.cc
@@ -18,6 +18,7 @@
1919 #include "dbwrap.h"
2020 #include "mbuffer.h"
2121
 22+#ifndef NO_BDB
2223 namespace db {
2324
2425 environment *
@@ -128,3 +129,4 @@
129130 }
130131
131132 } // namespace db
 133+#endif /* NO_BDB */
Index: trunk/loreley/src/loreley/http.cc
@@ -124,7 +124,6 @@
125125 void error_send_done (void);
126126
127127 void send_error(int, char const *, int, char const *);
128 - void send_cached(void);
129128 void log_request (void);
130129
131130 wsocket *_client_socket;
@@ -143,9 +142,15 @@
144143 error_transform_filter *_error_filter;
145144 chunking_filter *_chunking_filter;
146145 io::size_limiting_filter *_size_limit;
 146+
 147+#ifndef NO_BDB
 148+ void send_cached(void);
 149+
147150 shared_ptr<cachedentity> _cachedent;
148151 caching_filter *_cache_filter;
149152 cached_spigot *_cache_spigot;
 153+ bool _validating;
 154+#endif
150155
151156 backend_list *_blist;
152157 enum {
@@ -158,7 +163,6 @@
159164 imstring _request_host;
160165 imstring _request_path;
161166 int _nredir;
162 - bool _validating;
163167
164168 private:
165169 httpcllr(const httpcllr &);
@@ -180,14 +184,16 @@
181185 , _error_filter(NULL)
182186 , _chunking_filter(NULL)
183187 , _size_limit(NULL)
 188+#ifndef NO_BDB
184189 , _cache_filter(NULL)
185190 , _cache_spigot(NULL)
 191+ , _validating(false)
 192+#endif
186193 , _blist(NULL)
187194 , _denied(denied_no)
188195 , _group(gr)
189196 , _response(0)
190197 , _nredir(0)
191 - , _validating(false)
192198 {
193199 /*
194200 * Check access controls.
@@ -270,6 +276,7 @@
271277 _chunking_filter = NULL;
272278 delete _size_limit;
273279 _size_limit = NULL;
 280+#ifndef NO_BDB
274281 delete _cache_filter;
275282 _cache_filter = NULL;
276283 delete _cache_spigot;
@@ -277,6 +284,7 @@
278285 if (_cachedent)
279286 entitycache.release(_cachedent);
280287 _cachedent.reset();
 288+#endif
281289
282290 /*
283291 * Return the backend to the keepalive pool, if we can.
@@ -329,13 +337,16 @@
330338 delete _error_body;
331339 delete _chunking_filter;
332340 delete _size_limit;
 341+ delete _blist;
 342+#ifndef NO_BDB
333343 delete _cache_filter;
334 - delete _blist;
335344 delete _cache_spigot;
 345+#endif
336346 delete _client_spigot;
337347 delete _client_socket;
338348 }
339349
 350+#ifndef NO_BDB
340351 void
341352 httpcllr::send_cached(void)
342353 {
@@ -361,6 +372,7 @@
362373 _cache_spigot->sp_uncork();
363374 return;
364375 }
 376+#endif
365377
366378 void
367379 httpcllr::header_read_complete(void)
@@ -399,6 +411,7 @@
400412 /*
401413 * See if this entity has been cached.
402414 */
 415+#ifndef NO_BDB
403416 if (_header_parser->_http_reqtype != REQTYPE_POST) {
404417 bool created = false;
405418 string url = str(format("http://%s%s") % _header_parser->_http_host
@@ -440,6 +453,7 @@
441454 }
442455 }
443456 }
 457+#endif
444458
445459 /*
446460 * If we get here for a PURGE request, it means that the requested
@@ -634,12 +648,14 @@
635649 _response = _backend_headers->_response;
636650 stats.tcur->n_httpresp_ok++;
637651
 652+#ifndef NO_BDB
638653 if (_validating && _response == 304) {
639654 /* Our cached entity was still valid */
640655 _cachedent->revalidated();
641656 send_cached();
642657 return;
643658 }
 659+#endif
644660
645661 /*
646662 * Check for X-Loreley-Follow-Redirect header, which means we should
@@ -659,6 +675,7 @@
660676 return;
661677 }
662678
 679+#ifndef NO_BDB
663680 /*
664681 * If we're caching this entity, store the headers.
665682 */
@@ -668,6 +685,7 @@
669686 _cachedent->store_status(status, _backend_headers->_response);
670687 _cachedent->store_headers(_backend_headers->_headers);
671688 }
 689+#endif
672690
673691 /*
674692 * If the client is HTTP/1.0 or MSIE, we need to dechunk.
@@ -728,10 +746,12 @@
729747 /*
730748 * See if we can cache this entity.
731749 */
 750+#ifndef NO_BDB
732751 if (_cachedent) {
733752 cache = true;
734753 _cache_filter = new caching_filter(_cachedent);
735754 }
 755+#endif
736756
737757 _backend_spigot->sp_disconnect();
738758
@@ -767,6 +787,7 @@
768788 }
769789
770790 /* if we're caching, insert the caching filter */
 791+#ifndef NO_BDB
771792 if (cache) {
772793 cur = &(*cur >> *_cache_filter);
773794 /* if we dechunked it to cache, rechunk now */
@@ -775,6 +796,7 @@
776797 cur = &(*cur >> *_chunking_filter);
777798 }
778799 }
 800+#endif
779801
780802 /* finally, connect to the client */
781803 *cur >> *_client_sink;
@@ -1178,7 +1200,11 @@
11791201 % size
11801202 % _response
11811203 % (_backend ? _backend->be_name : string("-"))
 1204+#ifndef NO_BDB
11821205 % ((_cachedent && !_backend) ? "HIT" : "MISS"));
 1206+#else
 1207+ % "MISS");
 1208+#endif
11831209
11841210 if (!(alf << line << endl)) {
11851211 wlog.error(format(
@@ -1217,7 +1243,11 @@
12181244 ADD_STRING(bufp, _request_path, endp);
12191245 ADD_UINT16(bufp, _response, endp);
12201246 ADD_STRING(bufp, string(_backend ? _backend->be_name : "-"), endp);
 1247+#ifndef NO_BDB
12211248 ADD_UINT8(bufp, (_cachedent && !_backend) ? 1 : 0, endp);
 1249+#else
 1250+ ADD_UINT8(bufp, 0, endp);
 1251+#endif
12221252 ADD_UINT32(bufp, size, endp);
12231253 udplog_sock->write(buf, bufp - buf);
12241254 }
Index: trunk/loreley/src/loreley/net_solaris.cc
@@ -585,6 +585,7 @@
586586 : _addr(a)
587587 , _desc(desc)
588588 , _prio(p)
 589+ , _queue(0)
589590 {
590591 _s = s;
591592 }
@@ -593,6 +594,7 @@
594595 : _addr(a)
595596 , _desc(desc)
596597 , _prio(p)
 598+ , _queue(0)
597599 {
598600 _s = ::socket(_addr.family(), _addr.socktype(), _addr.protocol());
599601 if (_s == -1)
@@ -618,7 +620,8 @@
619621 socket::~socket(void)
620622 {
621623 WDEBUG("closing socket");
622 - port_dissociate(_queue->portfd, PORT_SOURCE_FD, _s);
 624+ if (_queue)
 625+ port_dissociate(_queue->portfd, PORT_SOURCE_FD, _s);
623626 close(_s);
624627 }
625628
@@ -730,7 +733,7 @@
731734 port_event_t ev;
732735 net::socket *sk;
733736
734 - while (port_get(eq->portfd, &ev, NULL)) {
 737+ while (port_get(eq->portfd, &ev, NULL) == 0) {
735738 WDEBUG(format("[%d] thread_run: waiting for event, eq=%p")
736739 % pthread_self() % eq);
737740