[e-cvs] cvs commit: e/src/jsrc/org/erights/e/elib/serial PassByConstructionGuard.java
markm@eros.cs.jhu.edu
markm@eros.cs.jhu.edu
Mon, 6 Aug 2001 13:21:20 -0400
markm 01/08/06 13:21:20
Modified: src Makefile
src/jsrc/net/captp/jcomm DelayedRedirector.java
ProxyConnection.java RemoteVowHandler.java
src/jsrc/org/erights/e/elib/ref Ref.java
WhenResolvedReactor.java
src/jsrc/org/erights/e/elib/serial
PassByConstructionGuard.java
Log:
fixed MarcS's new when-catch bug. Added special case to DelayedRedirector
Revision Changes Path
1.101 +2 -2 e/src/Makefile
Index: Makefile
===================================================================
RCS file: /cvs/e/src/Makefile,v
retrieving revision 1.100
retrieving revision 1.101
diff -u -r1.100 -r1.101
--- Makefile 2001/08/05 07:01:24 1.100
+++ Makefile 2001/08/06 17:21:19 1.101
@@ -7,8 +7,8 @@
# Prefix tagging this release's attributes
PREFIX=tl-E
-DOTVER=0.8.9w
-TAGVER=0_8_9w
+DOTVER=0.8.9x
+TAGVER=0_8_9x
RELEASE=working
TOP=..
1.4 +41 -7 e/src/jsrc/net/captp/jcomm/DelayedRedirector.java
Index: DelayedRedirector.java
===================================================================
RCS file: /cvs/e/src/jsrc/net/captp/jcomm/DelayedRedirector.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DelayedRedirector.java 2001/07/29 02:16:49 1.3
+++ DelayedRedirector.java 2001/08/06 17:21:19 1.4
@@ -27,6 +27,9 @@
import org.erights.e.elib.ref.Resolver;
import org.erights.e.elib.util.DeadManSwitch;
import org.erights.e.elib.util.OneArgFunc;
+import org.erights.e.elib.sealing.Brand;
+import org.erights.e.elib.sealing.SealedBox;
+import org.erights.e.elib.sealing.Unsealer;
import org.erights.e.elib.serial.PassByProxy;
/**
@@ -66,18 +69,49 @@
*/
public Object run(Object target) {
if (null == myOptResolver) {
+ //If my vow is already resolved, then ignore further resolution
+ //attempts
return null;
}
+
RemoteVowHandler rvh = (RemoteVowHandler)myOptResolver.optHandler();
- if (rvh.isUsed()) {
- Object[] pair = Ref.promise();
- Redirector rdr = new Redirector((Resolver)pair[1]);
- E.sendOnly(myOptResolver.getProxy(), "whenMoreResolved", rdr);
- myOptResolver.resolve(pair[0]);
- myOptResolver = null;
- } else {
+ if (rvh.isFresh()) {
+ //If no messages have yet been sent over my vow, then there's no
+ //message ordering issue, so resolve to target immediately.
myOptResolver.resolve(target);
+ return null;
+ }
+
+ ProxyConnection conn = rvh.myConn;
+ Unsealer unsealer = conn.getUnsealer();
+ Brand brand = unsealer.brand();
+ SealedBox optTargetBox = Ref.optMeta(target, brand);
+ RemoteHandler optTargetHandler =
+ (RemoteHandler)unsealer.unseal(optTargetBox, RemoteHandler.class);
+ if (null != optTargetHandler && conn == optTargetHandler.myConn) {
+ //If the new target is a remote reference into the same vat that
+ //my vow is into, then messages to be sent over target will only
+ //arrive after messages previously sent on this vow, so again
+ //there's no message ordering issue, and we can resolve to target
+ //immediately.
+ myOptResolver.resolve(target);
+ return null;
}
+
+ //If we fall through the above special cases, then we're in the
+ //general case, where we do need to deal with the message ordering
+ //issue. In this case, ignore the run/1 argument, send a last
+ //whenMoreResolved/1 message over the vow with a simple redirector as
+ //argument, and then resolve to a promise whose resolver is held by
+ //that redirector. This will locally buffer messages until all
+ //previous messages have been drained out, and will then resolve to
+ //the argument of the second run/1 message (thereby delivering all
+ //buffered messages as well).
+ Object[] pair = Ref.promise();
+ Redirector rdr = new Redirector((Resolver)pair[1]);
+ E.sendOnly(myOptResolver.getProxy(), "whenMoreResolved", rdr);
+ myOptResolver.resolve(pair[0]);
+ myOptResolver = null;
return null;
}
1.21 +6 -1 e/src/jsrc/net/captp/jcomm/ProxyConnection.java
Index: ProxyConnection.java
===================================================================
RCS file: /cvs/e/src/jsrc/net/captp/jcomm/ProxyConnection.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- ProxyConnection.java 2001/08/04 06:56:52 1.20
+++ ProxyConnection.java 2001/08/06 17:21:19 1.21
@@ -302,6 +302,11 @@
/*package*/ Sealer getSealer() { return myProxyMgr.mySealer; }
/**
+ *
+ */
+ /*package*/ Unsealer getUnsealer() { return myProxyMgr.myUnsealer; }
+
+ /**
* Return our identity.
*/
/*package*/ String localVatID() {
@@ -402,7 +407,7 @@
* appropriate descriptor for encoding it over the wire.
*/
/*package*/ ObjectRefDesc makeEventualDesc(Ref ref) {
- Unsealer unsealer = myProxyMgr.myUnsealer;
+ Unsealer unsealer = getUnsealer();
Brand brand = unsealer.brand();
SealedBox optBox = ref.optMeta(brand);
RemoteHandler optHandler =
1.4 +7 -7 e/src/jsrc/net/captp/jcomm/RemoteVowHandler.java
Index: RemoteVowHandler.java
===================================================================
RCS file: /cvs/e/src/jsrc/net/captp/jcomm/RemoteVowHandler.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- RemoteVowHandler.java 2001/07/29 02:16:49 1.3
+++ RemoteVowHandler.java 2001/08/06 17:21:19 1.4
@@ -32,7 +32,7 @@
/**
* Flag to remember whether any E-level messages have been sent over me.
*/
- private boolean myUsedFlag = false;
+ private boolean myFreshFlag = true;
/**
* Construct a new RemoteVowHandler.
@@ -45,23 +45,23 @@
}
/**
- * Override to also set myUsedFlag
+ * Override to also clear myFreshFlag
*/
public void handleSendAllOnly(String verb, Object[] args) {
- myUsedFlag = true;
+ myFreshFlag = false;
super.handleSendAllOnly(verb, args);
}
/**
- * Override to also set myUsedFlag
+ * Override to also clear myFreshFlag
*/
public Ref handleSendAll(String verb, Object[] args) {
- myUsedFlag = true;
+ myFreshFlag = false;
return super.handleSendAll(verb, args);
}
/**
- * Have any E-level messages have been sent over me?
+ * Have no E-level messages yet been sent over me?
*/
- /*package*/ boolean isUsed() { return myUsedFlag; }
+ /*package*/ boolean isFresh() { return myFreshFlag; }
}
1.19 +6 -2 e/src/jsrc/org/erights/e/elib/ref/Ref.java
Index: Ref.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elib/ref/Ref.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- Ref.java 2001/07/31 13:09:14 1.18
+++ Ref.java 2001/08/06 17:21:20 1.19
@@ -667,8 +667,12 @@
/**
*
*/
- static public SealedBox optMeta(Amplifiable ref, Brand brand) {
- return ref.optMeta(brand);
+ static public SealedBox optMeta(Object ref, Brand brand) {
+ if (ref instanceof Amplifiable) {
+ return ((Amplifiable)ref).optMeta(brand);
+ } else {
+ return null;
+ }
}
/**
1.6 +17 -12 e/src/jsrc/org/erights/e/elib/ref/WhenResolvedReactor.java
Index: WhenResolvedReactor.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elib/ref/WhenResolvedReactor.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- WhenResolvedReactor.java 2001/07/31 13:09:14 1.5
+++ WhenResolvedReactor.java 2001/08/06 17:21:20 1.6
@@ -33,8 +33,9 @@
*
* Like a Once extended to also invoke "wrapped run/1" when a client
* is lost (according to reactToLostClient). Only does the run/1 behavior
- * if argument is resolved. Hence the difference between "whenResolved" and
- * "whenMoreResolved". <p>
+ * when the original reference is resolved, and does it on the original
+ * reference. Hence the main difference between "whenResolved" and the
+ * Miranda "whenMoreResolved" message.<p>
*
* @author <a href="mailto:markm@erights.org">Mark S. Miller</a>
*/
@@ -54,12 +55,13 @@
}
/**
- * If arg is resolved, then invoke myOptWrapped once, and remember not to
+ * Causes us to wakeup and check if myRef is resolved.
+ *
+ * If myRef is resolved, then invoke myOptWrapped once, and remember not to
* invoke it again (by forgetting it). Also forget myRef, since we won't
- * need it for reactToLostClient. <p>
+ * need it for again. <p>
*
- * If arg is not resolved, then remember it as a better myRef (for
- * supporting reactToLostClient), and send a new <pre>
+ * If myRef is not resolved, then send a new <pre>
*
* arg <- whenMoreResolved(this)
* </pre> message. Unlike a Once, redundant invocations silently return
@@ -72,13 +74,13 @@
if (null == myOptWrapped) {
return null;
}
- if (Ref.isResolved(arg)) {
- myRef = null;
+ if (Ref.isResolved(myRef)) {
+ Object ref = myRef;
OneArgFunc optWrapped = myOptWrapped;
+ myRef = null;
myOptWrapped = null;
- optWrapped.run(arg);
+ optWrapped.run(ref);
} else {
- myRef = arg;
E.sendOnly(arg, "whenMoreResolved", this);
}
return null;
@@ -99,8 +101,11 @@
run(myRef);
} else {
//for myRef to be unbroken is likely a bug, but better to report
- //the problem.
- run(Ref.broken(problem));
+ //the problem. XXX this case should be traced rather than
+ //reported. To report it in this inconsistent way is likely a
+ //bug.
+ myRef = Ref.broken(problem);
+ run(myRef);
}
}
}
1.8 +1 -1 e/src/jsrc/org/erights/e/elib/serial/PassByConstructionGuard.java
Index: PassByConstructionGuard.java
===================================================================
RCS file: /cvs/e/src/jsrc/org/erights/e/elib/serial/PassByConstructionGuard.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- PassByConstructionGuard.java 2001/07/14 12:57:23 1.7
+++ PassByConstructionGuard.java 2001/08/06 17:21:20 1.8
@@ -63,7 +63,7 @@
*/
public Object coerce(Object specimen, OneArgFunc optEjector) {
if (Ref.isPBC(specimen)) {
- if (specimen.getClass().isArray()) {
+ if (specimen != null && specimen.getClass().isArray()) {
//Because we try to pretend that arrays are PassByCopy lists,
//we coerce it to a ConstList.
return ConstList.fromArray(specimen);