Subversion Repositories

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

Go to most recent revision | Details | Last modification | View Log | RSS feed

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