2003-11-03
2003-11-03 13:52:37 by Martin Stjernholm <mast@lysator.liu.se>
-
39202e4b857d41855823f4367cd18f93f81fb62d
(45 lines)
(+32/-13)
[
Show
| Annotate
]
Branch: 5.2
Added some extra sanity checks on threads and callbacks in debug mode.
roxen.handle exists even when threads aren't used.
Rev: server/protocols/http.pike:1.411
2:
// Modified by Francesco Chemolli to add throttling capabilities.
// Copyright © 1996 - 2001, Roxen IS.
- constant cvs_version = "$Id: http.pike,v 1.410 2003/11/03 13:49:19 mast Exp $";
+ constant cvs_version = "$Id: http.pike,v 1.411 2003/11/03 13:52:37 mast Exp $";
// #define REQUEST_DEBUG
#define MAGIC_ERROR
30: Inside #if defined(REQUEST_DEBUG)
#ifdef REQUEST_DEBUG
int footime, bartime;
- #define REQUEST_WERR(X) bartime = gethrtime()-footime; werror("%s (%d)\n", (X), bartime);footime=gethrtime()
+ #define REQUEST_WERR(X) do {bartime = gethrtime()-footime; werror("%s (%d)\n", (X), bartime);footime=gethrtime();} while (0)
#else
- #define REQUEST_WERR(X)
+ #define REQUEST_WERR(X) do {} while (0)
#endif
#ifdef FD_DEBUG
- #define MARK_FD(X) \
- catch{ \
- REQUEST_WERR("FD " + my_fd->query_fd() + ": " + (X)); \
- mark_fd(my_fd->query_fd(), (X)+" "+remoteaddr); \
- }
+ #define MARK_FD(X) do { \
+ int _fd = my_fd && my_fd->query_fd ? my_fd->query_fd() : -1; \
+ REQUEST_WERR("FD " + (_fd == -1 ? sprintf ("%O", my_fd) : _fd) + ": " + (X)); \
+ mark_fd(_fd, (X)+" "+remoteaddr); \
+ } while (0)
#else
- #define MARK_FD(X)
+ #define MARK_FD(X) do {} while (0)
#endif
#ifdef THROTTLING_DEBUG
63:
int kept_alive;
+ #ifdef DEBUG
+ #define CHECK_FD_SAFE_USE do { \
+ if (this_thread() != roxen->backend_thread && \
+ (my_fd->query_read_callback() || my_fd->query_write_callback() || \
+ my_fd->query_close_callback() || \
+ !zero_type (find_call_out (do_timeout)))) \
+ error ("Got callbacks but not called from backend thread.\n"); \
+ } while (0)
+ #else
+ #define CHECK_FD_SAFE_USE do {} while (0)
+ #endif
+
#include <roxen.h>
#include <module.h>
#include <variables.h>
342: Inside #if defined(OLD_RXML_CONFIG)
};
void do_send_reply( string what, string url ) {
+ CHECK_FD_SAFE_USE;
url = url_base() + url[1..];
my_fd->set_blocking();
my_fd->write( prot + " 302 Roxen config coming up\r\n"+
844:
if( conf )
conf->connection_drop( this_object() );
+ CHECK_FD_SAFE_USE;
+
#if constant(Parser.XML.Tree.XMLNSParser)
if (xml_data) {
mixed err = catch {
925:
MARK_FD("HTTP timeout");
end();
} else {
+ #ifdef DEBUG
+ error ("This shouldn't happen.\n");
+ #endif
// premature call_out... *¤#!"
call_out(do_timeout, 10);
MARK_FD("HTTP premature timeout");
1465:
{
TIMER_START(send_result);
+ CHECK_FD_SAFE_USE;
+
array err;
int tmp;
mapping heads;
2074:
conf->connection_add( this_object(), connection_stats );
conf->received += strlen(raw);
conf->requests++;
+
+ CHECK_FD_SAFE_USE;
my_fd->set_close_callback(0);
my_fd->set_read_callback(0);
if (my_fd->set_accept_callback) my_fd->set_accept_callback (0);
2186:
REQUEST_WERR(sprintf("HTTP: cooked cookies %O", cookies));
TIMER_END(parse_request);
- #ifdef THREADS
+
REQUEST_WERR("HTTP: Calling roxen.handle().");
roxen.handle(handle_request);
- #else
- handle_request();
- #endif
+
})
{
report_error("Internal server error: " + describe_backtrace(err));