Subversion Repositories

?revision_form?Rev ?revision_input??revision_submit??revision_endform?

Rev 108 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
116 holmgren 1
From: Martin Stjernholm <mast@roxen.com>
2
Subject: Encode references to all ex-masters as if they are to the current master.
108 holmgren 3
 
116 holmgren 4
That since we cannot hope to eradicate all references to the old
5
master when replacing it, and in any case the decoder cannot hope to
6
find the same ex-master again.
108 holmgren 7
 
116 holmgren 8
If this creates a problem for someone using replace_master then it's
9
always possible to clear the is_pike_master variable in the old
10
master.
11
 
108 holmgren 12
--- trunk/lib/master.pike.in    28 Jul 2010 10:29:59 -0000      1.474
13
+++ cvs/lib/master.pike.in      28 Jul 2010 22:58:01 -0000      1.476
14
@@ -85,6 +85,13 @@
15
 //!
16
 int show_if_constant_errors = 0;
17
 
18
+int is_pike_master = 0;
19
+// This integer variable should exist in any object that aspires to be
20
+// the master. It gets set to 1 when the master is installed, and is
21
+// therefore set in any object that is or has been the master. That
22
+// makes the Encoder class encode references to the master and all
23
+// ex-masters as references to the current master object.
24
+
25
 // ---  Functions begin here.
26
 
27
 // Have to access some stuff without going through the resolver.
28
@@ -5092,6 +5099,11 @@
29
        }
30
       }
31
 
32
+      else if (what->is_pike_master) {
33
+       ENC_MSG ("  is a master object\n");
34
+       ENC_RETURN ("o/master");
35
+      }
36
+
37
       program prog;
38
       if ((prog = objects_reverse_lookup (what)))
39
        ENC_MSG ("  found program in objects: %O\n", prog);
40
--- trunk/src/builtin_functions.c       27 Jul 2010 16:46:01 -0000      1.704
41
+++ cvs/src/builtin_functions.c 28 Jul 2010 22:51:00 -0000      1.705
42
@@ -7364,22 +7364,28 @@
43
  */
44
 PMOD_EXPORT void f_replace_master(INT32 args)
45
 {
46
+  struct object *new_master;
47
   ASSERT_SECURITY_ROOT("replace_master");
48
 
49
   if(!args)
50
     SIMPLE_TOO_FEW_ARGS_ERROR("replace_master", 1);
51
   if(Pike_sp[-args].type != T_OBJECT)
52
     SIMPLE_BAD_ARG_ERROR("replace_master", 1, "object");
53
-  if(!Pike_sp[-args].u.object->prog)
54
+  new_master = Pike_sp[-args].u.object;
55
+  if(!new_master->prog)
56
     bad_arg_error("replace_master", Pike_sp-args, args, 1, "object", Pike_sp-args,
57
                  "Called with destructed object.\n");
58
 
59
   if (Pike_sp[-args].subtype)
60
     bad_arg_error("replace_master", Pike_sp-args, args, 1, "object", Pike_sp-args,
61
                  "Subtyped master objects are not supported yet.\n");
62
-    
63
+
64
+  push_constant_text ("is_pike_master");
65
+  args++;
66
+  object_set_index (new_master, 0, Pike_sp - 1, &svalue_int_one);
67
+
68
   free_object(master_object);
69
-  master_object=Pike_sp[-args].u.object;
70
+  master_object=new_master;
71
   add_ref(master_object);
72
 
73
   free_program(master_program);
74
--- trunk/src/object.c  11 Jul 2010 10:08:02 -0000      1.310
75
+++ cvs/src/object.c    28 Jul 2010 22:50:59 -0000      1.311
76
@@ -658,6 +658,7 @@
77
   }
78
 
79
   {
80
+    int f;
81
     ONERROR uwp;
82
 
83
     /* fprintf(stderr, "Cloning master...\n"); */
84
@@ -673,7 +674,11 @@
85
 
86
     call_c_initializers(master_object);
87
     call_pike_initializers(master_object,0);
88
-  
89
+
90
+    f = find_identifier ("is_pike_master", master_program);
91
+    if (f >= 0)
92
+      object_low_set_index (master_object, f, &svalue_int_one);
93
+
94
     /* fprintf(stderr, "Master loaded.\n"); */
95
 
96
     UNSET_ONERROR (uwp);
97
--- trunk/src/svalue.c  11 Jul 2010 12:39:10 -0000      1.261
98
+++ cvs/src/svalue.c    28 Jul 2010 22:46:39 -0000      1.262
99
@@ -30,14 +30,10 @@
100
 
101
 #define sp Pike_sp
102
 
103
-PMOD_EXPORT const struct svalue svalue_undefined =
104
+PMOD_EXPORT struct svalue svalue_undefined =
105
   SVALUE_INIT (T_INT, NUMBER_UNDEFINED, 0);
106
-PMOD_EXPORT const struct svalue svalue_int_zero = SVALUE_INIT_INT (0);
107
-#ifdef HAVE_UNION_INIT
108
-PMOD_EXPORT const struct svalue svalue_int_one = SVALUE_INIT_INT (1);
109
-#else
110
+PMOD_EXPORT struct svalue svalue_int_zero = SVALUE_INIT_INT (0);
111
 PMOD_EXPORT struct svalue svalue_int_one = SVALUE_INIT_INT (1);
112
-#endif
113
 
114
 #ifdef PIKE_DEBUG
115
 PMOD_EXPORT const char msg_type_error[] =
116
--- trunk/src/svalue.h  18 Feb 2010 08:52:55 -0000      1.172
117
+++ cvs/src/svalue.h    28 Jul 2010 22:46:40 -0000      1.173
118
@@ -323,13 +323,8 @@
119
 
120
 #define FUNCTION_BUILTIN USHRT_MAX
121
 
122
-extern PMOD_EXPORT const struct svalue svalue_undefined, svalue_int_zero;
123
-#ifdef HAVE_UNION_INIT
124
-extern PMOD_EXPORT const struct svalue svalue_int_one;
125
-#else
126
-/* The value 1 is initialized first thing in init_pike. */
127
-extern PMOD_EXPORT struct svalue svalue_int_one;
128
-#endif
129
+extern PMOD_EXPORT struct svalue svalue_undefined,
130
+  svalue_int_zero, svalue_int_one;
131
 
132
 #define is_gt(a,b) is_lt(b,a)
133
 #define is_ge(a,b) is_le(b,a)