From ad9aa5df329893e23b87c18f9f6eb729e86db008 Mon Sep 17 00:00:00 2001 From: Per Hedbor <ph@opera.com> Date: Wed, 4 Aug 1999 21:11:31 +0200 Subject: [PATCH] Fixed a fallback when not using threaded calls Rev: lib/modules/Remote.pmod/connection.pike:1.14 --- lib/modules/Remote.pmod/connection.pike | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/modules/Remote.pmod/connection.pike b/lib/modules/Remote.pmod/connection.pike index ef9cce9c4e..f040b312aa 100644 --- a/lib/modules/Remote.pmod/connection.pike +++ b/lib/modules/Remote.pmod/connection.pike @@ -8,7 +8,7 @@ private static int _debug_conn_nr; #define DEBUGMSG(X) werror("<" + _debug_conn_nr + "> " + (X)) #endif -int closed, want_close, outstanding_calls; +int closed, want_close, outstanding_calls, do_calls_async; object con; object ctx; array(function) close_callbacks = ({ }); @@ -20,6 +20,7 @@ int nice; // don't throw from call_sync void create(void|int _nice) { nice=_nice; + call_out( lambda(){ do_calls_async=1; }, 0.1 ); // :-) } // - connect @@ -363,9 +364,15 @@ void read_some(int ignore, string s) case CTX_CALL_SYNC: case CTX_CALL_ASYNC: #if constant(thread_create) - if (outstanding_calls >= call_threads && call_threads < MAX_CALL_THREADS) - thread_create(call_thread); - calls->write(data); + if( do_calls_async ) + call_out( do_call, 0, data); + else + { + if (outstanding_calls >= call_threads && + call_threads < MAX_CALL_THREADS) + thread_create(call_thread); + calls->write(data); + } #else outstanding_calls++; do_call(data); @@ -455,7 +462,10 @@ void call_thread() if (!data) try_close(); else { outstanding_calls++; - do_call(data); + if( do_calls_async ) + call_out( do_call, 0,data); + else + do_call( data ); outstanding_calls--; } } -- GitLab