From 750299091819052990be856db19220b8ee5ae5ad Mon Sep 17 00:00:00 2001 From: "psyc://psyced.org/~lynX" <@> Date: Mon, 23 May 2011 13:02:04 +0200 Subject: [PATCH 1/2] are we going to have state implemented just by mistake? --- world/net/group/master.c | 21 +++++++++++++++++++++ world/net/psyc/parse.i | 7 ++++++- world/net/psyc/render.i | 5 +++-- world/net/spyc/circuit.c | 5 ----- world/net/spyc/common.h | 3 --- world/net/spyc/parse.c | 4 ---- world/net/spyc/psyc.h | 5 ++--- world/net/spyc/server.c | 5 ----- world/net/spyc/udp.c | 6 ------ 9 files changed, 32 insertions(+), 29 deletions(-) delete mode 100644 world/net/spyc/common.h diff --git a/world/net/group/master.c b/world/net/group/master.c index 4b2f188..2308ef3 100644 --- a/world/net/group/master.c +++ b/world/net/group/master.c @@ -55,10 +55,15 @@ volatile mapping _routes, _u; #endif #ifdef CONTEXT_STATE // {{{ +// why volatile.. that breaks the whole meaning of state volatile mapping _costate, _cmemory; volatile mapping ctemp, cunused; #endif // }}} +#ifdef USE_SPYC +mapping _state; // an alternative to ifdef CONTEXT_STATE ? +#endif + #ifdef PERSISTENT_SLAVES int revision; // persistent revision counter #endif @@ -85,6 +90,9 @@ create() { ctemp = ([ ]); _cmemory = m_allocate(0, 2); #endif // }}} +#ifdef USE_SPYC + _state = ([ ]); +#endif ::create(); } @@ -286,6 +294,19 @@ insert_member(source, origin) { P3(("%O -> _routes = %O\n", ME, _routes)) } +#ifdef USE_SPYC +get_state() { + PT(("cstate for %O picked up by %O: %O\n", ME, + previous_object(), _state)) + return _state; +} +commit_state() { + PT(("cstate for %O committed by %O: %O\n", ME, + previous_object(), _state)) + _state = ([ ]); +} +#endif + // code duplicaton is faster than others #ifdef CONTEXT_STATE // {{{ // diff --git a/world/net/psyc/parse.i b/world/net/psyc/parse.i index 0c9ad98..4a85c2b 100644 --- a/world/net/psyc/parse.i +++ b/world/net/psyc/parse.i @@ -1113,13 +1113,18 @@ protected int deliver(mixed ip, string host, string mc, string buffer, mapping c return 1; } -void peek(string data) { +// temporary new "lfun" called from driver's comm.c to peek into new connection +void connection_peek(string data) { P4((">> peek: %O\n", data)); #ifdef USE_SPYC +# if !__EFUN_DEFINED__(psyc_parse) +# echo New PSYC syntax will not work: Driver compiled without libpsyc! +# endif if (data[0] == C_GLYPH_NEW_PACKET_DELIMITER) { # if __EFUN_DEFINED__(enable_binary) enable_binary(ME); # else +# echo New PSYC syntax will not work: Driver compiled without enable_binary! raise_error("Driver compiled without enable_binary()"); # endif } diff --git a/world/net/psyc/render.i b/world/net/psyc/render.i index 127e048..08bf324 100644 --- a/world/net/psyc/render.i +++ b/world/net/psyc/render.i @@ -274,6 +274,7 @@ static varargs string render_psyc(mixed source, string mc, mixed data, if (mappingp(vars)) mapeach (key, val, vars) { + // psyc_isRoutingVar() would be faster here I presume routeMe = isRouting[key]; if ((routeMe &&! (routeMe & PSYC_ROUTING_RENDER)) || abbrev("_INTERNAL", key)) @@ -286,8 +287,7 @@ static varargs string render_psyc(mixed source, string mc, mixed data, } return psyc_render(({ rvars, evars, mc, data })); -#endif - +#else if (mappingp(vars)) vars = vars + rvars; else @@ -323,6 +323,7 @@ static varargs string render_psyc(mixed source, string mc, mixed data, if (strlen(rbuf)) return rbuf[1 ..] +"\n"+ ebuf +"\n" S_GLYPH_PACKET_DELIMITER "\n"; return ebuf +"\n" S_GLYPH_PACKET_DELIMITER "\n"; +#endif } // notice for completeness: the PSYC renderer does not convert_charset diff --git a/world/net/spyc/circuit.c b/world/net/spyc/circuit.c index 9fe1631..409c2ed 100644 --- a/world/net/spyc/circuit.c +++ b/world/net/spyc/circuit.c @@ -3,10 +3,6 @@ #include "psyc.h" -#ifdef USE_PSYC -# include "../psyc/circuit.c" -#else - #include #include #include @@ -302,4 +298,3 @@ varargs int msg(string source, string mc, string data, return emit(buf); } -#endif // USE_PSYC diff --git a/world/net/spyc/common.h b/world/net/spyc/common.h deleted file mode 100644 index 40045b0..0000000 --- a/world/net/spyc/common.h +++ /dev/null @@ -1,3 +0,0 @@ -#ifdef USE_PSYC -# include "../psyc/common.h" -#endif diff --git a/world/net/spyc/parse.c b/world/net/spyc/parse.c index b448b37..d25089e 100644 --- a/world/net/spyc/parse.c +++ b/world/net/spyc/parse.c @@ -1,8 +1,6 @@ // vim:foldmethod=marker:syntax=lpc:noexpandtab // $Id: parse.c,v 1.30 2008/12/18 18:16:14 lynx Exp $ -#ifndef USE_PSYC - #include "psyc.h" #include #include @@ -468,5 +466,3 @@ void interrupt_parse() { void resume_parse() { state = PSYCPARSE_STATE_HEADER; } - -#endif // USE_PSYC diff --git a/world/net/spyc/psyc.h b/world/net/spyc/psyc.h index 8c16808..c71c892 100644 --- a/world/net/spyc/psyc.h +++ b/world/net/spyc/psyc.h @@ -23,12 +23,11 @@ * the first byte. */ +#ifndef SPYC #define SPYC #include -#ifndef USE_PSYC - #if __EFUN_DEFINED__(psyc_parse) # define LIBPSYC # include @@ -46,4 +45,4 @@ return; \ } -#endif // USE_PSYC +#endif // SPYC diff --git a/world/net/spyc/server.c b/world/net/spyc/server.c index d86c046..7444b91 100644 --- a/world/net/spyc/server.c +++ b/world/net/spyc/server.c @@ -5,10 +5,6 @@ #include "psyc.h" -#ifdef USE_PSYC -# include "../psyc/server.c" -#else - #include #include #define NO_INHERIT @@ -195,4 +191,3 @@ void circuit_msg(string mc, mapping vars, string data) { } } -#endif // USE_PSYC diff --git a/world/net/spyc/udp.c b/world/net/spyc/udp.c index 4e164fb..056c551 100644 --- a/world/net/spyc/udp.c +++ b/world/net/spyc/udp.c @@ -3,10 +3,6 @@ #include "psyc.h" -#ifdef USE_PSYC -# include "../psyc/udp.c" -#else - #include #include #include @@ -42,5 +38,3 @@ parseUDP(ip, port, msg) { // ignoring the routing vars.. TODO FIXME #define PSYC_UDP #include "dispatch.i" - -#endif // USE_PSYC From a363c6f255af011c6d6836fe2d6d6d464e6eca96 Mon Sep 17 00:00:00 2001 From: "psyc://psyced.org/~lynX" <@> Date: Mon, 23 May 2011 13:15:40 +0200 Subject: [PATCH 2/2] wrong file.. cslaves keep state (but don't do anything with it yet) --- world/net/group/master.c | 20 -------------------- world/net/group/slave.c | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/world/net/group/master.c b/world/net/group/master.c index 2308ef3..48e4f00 100644 --- a/world/net/group/master.c +++ b/world/net/group/master.c @@ -60,10 +60,6 @@ volatile mapping _costate, _cmemory; volatile mapping ctemp, cunused; #endif // }}} -#ifdef USE_SPYC -mapping _state; // an alternative to ifdef CONTEXT_STATE ? -#endif - #ifdef PERSISTENT_SLAVES int revision; // persistent revision counter #endif @@ -90,9 +86,6 @@ create() { ctemp = ([ ]); _cmemory = m_allocate(0, 2); #endif // }}} -#ifdef USE_SPYC - _state = ([ ]); -#endif ::create(); } @@ -294,19 +287,6 @@ insert_member(source, origin) { P3(("%O -> _routes = %O\n", ME, _routes)) } -#ifdef USE_SPYC -get_state() { - PT(("cstate for %O picked up by %O: %O\n", ME, - previous_object(), _state)) - return _state; -} -commit_state() { - PT(("cstate for %O committed by %O: %O\n", ME, - previous_object(), _state)) - _state = ([ ]); -} -#endif - // code duplicaton is faster than others #ifdef CONTEXT_STATE // {{{ // diff --git a/world/net/group/slave.c b/world/net/group/slave.c index c9755bf..6d1c89e 100644 --- a/world/net/group/slave.c +++ b/world/net/group/slave.c @@ -29,11 +29,16 @@ private int _revision = -1; #endif #ifdef CONTEXT_STATE +// cslaves should store their copy of state, so it shouldn't be volatile here private volatile mapping cast_state; private volatile mapping temp_state; inherit NET_PATH "state"; #endif +#ifdef USE_SPYC +mapping _state; // should probably merge with ifdef CONTEXT_STATE.. +#endif + private volatile mapping _members; void create() { @@ -42,6 +47,9 @@ void create() { unless(mappingp(cast_state)) cast_state = ([ ]); unless(mappingp(temp_state)) temp_state = ([ ]); #endif +#ifdef USE_SPYC + unless(mappingp(_state)) _state = ([ ]); +#endif } #ifdef PERSISTENT_SLAVES @@ -264,3 +272,16 @@ void Diminish(mixed source, string key, mixed value) { } #endif // }}} + +#ifdef USE_SPYC +get_state() { + PT(("cstate for %O picked up by %O: %O\n", ME, + previous_object(), _state)) + return _state; +} +commit_state() { + PT(("cstate for %O committed by %O: %O\n", ME, + previous_object(), _state)) + _state = ([ ]); +} +#endif