...
 
Commits (6)
......@@ -31,6 +31,7 @@
//! the file.
#pike __REAL_VERSION__
#require constant(Thread.Thread)
#pragma dynamic_dot
......
......@@ -41,7 +41,9 @@ void set_delay( int t )
delay = t;
}
#if constant(all_threads)
protected object backend_thread = this_thread();
#endif
protected int delay, last_seen;
protected int expected_cpu_time;
protected array(function(void:void)) debug_funcs = ({});
......@@ -51,13 +53,18 @@ protected array(function(void:bool)) probes = ({});
//! debug information to stderr.
void print_debug()
{
#if constant(_disable_threads)
// Disable all threads to avoid potential locking problems while we
// have the backtraces. It also gives an atomic view of the state.
object threads_disabled = _disable_threads();
#else
object threads_disabled = 0;
#endif
gc();
Stdio.stderr.write("### Describing all Pike threads:\n\n");
int n;
#if constant(all_threads)
foreach( all_threads(), Thread.Thread t )
{
array bt = t->backtrace();
......@@ -66,6 +73,15 @@ void print_debug()
Stdio.stderr.write(describe_backtrace(bt) + "\n");
n++;
}
#else
{
array bt = backtrace();
Stdio.stderr.write("### Thread %O%s:\n",
UNDEFINED, " (backend thread)");
Stdio.stderr.write(describe_backtrace(bt) + "\n");
n++;
}
#endif
Stdio.stderr.write("Total %d Pike threads\n", n);
......
......@@ -3,6 +3,8 @@
// WebSocket testsuite
//
#if constant(Thread.Thread)
constant loopback = "127.0.0.1";
int successes;
......@@ -312,3 +314,12 @@ int main(int argc, array(string) argv)
Thread.thread_create(run_tests);
return -1;
}
#else
int main(int argc, array(string) argv)
{
Tools.Testsuite.report_result(0, 0, 1);
}
#endif
......@@ -247,12 +247,16 @@ define(run_sub_test, [[
]])
]])
cond_begin([[all_constants()->thread_create]])
dnl Displaced tests for SSL.File.
run_sub_test(({"SRCDIR../../../src/modules/_Stdio/async_tls_close_test.pike", "0", "0"}))
run_sub_test(({"SRCDIR../../../src/modules/_Stdio/async_tls_close_test.pike", "0", "1"}))
run_sub_test(({"SRCDIR../../../src/modules/_Stdio/async_tls_close_test.pike", "1", "0"}))
run_sub_test(({"SRCDIR../../../src/modules/_Stdio/async_tls_close_test.pike", "1", "1"}))
cond_end // thread_create
test_do([[
#define ASSERT(X) if(!(X)) error("Assertion failed.\n")
......@@ -403,6 +407,8 @@ test_do([[
#endif
]])
cond_begin([[all_constants()->thread_create]])
test_any([[
Stdio.File client_con = Stdio.File();
Stdio.File server_con =
......@@ -439,6 +445,8 @@ test_any([[
return has_prefix("GET / HTTP/1.0\r\n\r\n", cb_data);
]], 1)
cond_end // thread_create
test_do([[
add_constant("client_msg", random_string(65519));
]])
......
......@@ -461,7 +461,7 @@ int|object streaming_query(object|string q,
return big_query(q, bindings);
}
#else
#elif constant(Sql.pgsql)
/*
* If libpq wasn't available at compile time, the pgsql-module can provide
* near the same functionality as the postgres module.
......@@ -479,4 +479,6 @@ int|object streaming_query(object|string q,
//! @seealso
//! @[Sql.pgsql], @[Sql.Sql]
inherit Sql.pgsql;
#endif /* constant(Postgres.postgres) */
#else /* constant(Sql.pgsql) */
constant this_program_does_not_exist = 1;
#endif
......@@ -67,7 +67,11 @@ protected mapping(string:string) default_headers = ([
protected int _call_id = 0;
#if constant(this_thread)
#define IS_BACKEND_THREAD() (this_thread() == master()->backend_thread())
#else
#define IS_BACKEND_THREAD() (1)
#endif
//! Creates a new Api instance
//!
......