Commit f77b5987 authored by Josh Kunz's avatar Josh Kunz
Browse files

Flush debugging session with david

parent fd782fb9
Pipeline #1849 passed with stage
in 21 seconds
......@@ -684,6 +684,9 @@ class Node(Capability):
("node_reset_args", args))
return reply.item.capability
# Exception raised when there is a protocol violation in the recv_iter protocol
class RecvIterException(Exception):
""
@Protocol.register_objtype
class RP(Capability):
......@@ -751,17 +754,17 @@ class RP(Capability):
"send_iter_context" context."""
start, iter_id = self.recv_wait(timeout=timeout).split("_")
if start != "start-iter":
raise Exception("Expected start-iter")
raise RecvIterException("Expected start-iter")
while True:
msg = self.recv_wait(timeout=timeout)
try:
stop, _id = msg.split("_")
if end != "stop-iter":
raise Exception("Expected stop-iter")
if stop != "stop-iter":
raise RecvIterException("Expected stop-iter")
if _id != iter_id:
raise Exception("Got stop-iter for wrong id")
raise RecvIterException("Got stop-iter for wrong id")
return
except Exception:
except AttributeError:
yield msg
def recv_iter_exn(self):
......
import capnet
from collections import namedtuple
NodeProperties = namedtuple("NodeProperties",
["node", "node_grant", "info", "rp", "flow"])
["node", "grant", "info", "rp", "flow"])
def recv_preamble(p):
rp0 = p.rp0()
......@@ -18,8 +18,8 @@ def recv_nodes(p, rp_iter):
nodes = {}
for node in rp_iter:
node_rp = p.create(capnet.RP)
node_grant = node.reset(node_rp)
grant = node.reset(node_rp)
info = node.info()
flow = node_grant.flow()
nodes[info.name] = NodeProperties(node, node_grant, info, node_rp, flow)
nodes[info.name] = NodeProperties(node, grant, info, node_rp, flow)
return nodes
......@@ -535,6 +535,10 @@ struct cn_rp_elem {
};
};
static inline bool cn_rp_elem_is_normal(struct cn_rp_elem * elem) {
return elem->source == CN_RP_ELEM_SOURCE_NORMAL;
}
static inline bool cn_rp_elem_is_injected(struct cn_rp_elem * elem) {
return elem->source == CN_RP_ELEM_SOURCE_INJECTED;
}
......@@ -1544,6 +1548,9 @@ static int cn_rp_recv_injected(struct cnode * rp, struct cn_rp_elem * e,
static int cn_rp_recv_membrane(struct cnode *rp, struct cn_rp_elem *e,
cptr_t * recv_cap, cn_objtype_t *type) {
assert(cn_rp_elem_is_membrane(e) || cn_rp_elem_is_normal(e) &&
"rp_elem must be normal or membrane when doing a membrane recv");
cn_cnode_meta_t * meta = (cn_cnode_meta_t *) cap_cnode_metadata(rp);
cn_wrapper_t wrapper = NULL;
if (meta != NULL && cn_cnode_meta_is_wrapped(meta)) {
......@@ -1582,10 +1589,19 @@ static int cn_rp_recv_membrane(struct cnode *rp, struct cn_rp_elem *e,
cn_abort("unreachable");
}
cn_principal_t * owner = NULL;
cptr_t cap;
if (cn_rp_elem_is_normal(e)) {
owner = e->normal.cap_owner;
cap = e->normal.cap;
} else {
owner = e->membrane.cap_owner;
cap = e->membrane.cap;
}
/* Now we just do the normal membrane grant... */
if (cn_membrane_grant(membrane, send_type, recv_type,
e->membrane.cap_owner, e->membrane.cap,
cn_cnode_principal(rp),
owner, cap, cn_cnode_principal(rp),
recv_cap, type) != 0) {
return -1;
}
......@@ -1621,8 +1637,11 @@ int cn_rp_recv(struct cnode *rp,
*flags |= CN_RP_RECV_RESULT_TYPE_MESSAGE;
}
// XXX: No wrapping is done on injected objects.
if (cn_rp_elem_is_injected(e)) {
// XXX: No wrapping is done on injected objects, or on messages.
if (e->source == CN_RP_ELEM_SOURCE_MESSAGE) {
// if our cap contains only a message, then skip the rest of the
// processing, it was handled above.
} else if (cn_rp_elem_is_injected(e)) {
if (cn_rp_recv_injected(rp, e, recv_cap, type) != 0) {
goto recover;
}
......@@ -1641,7 +1660,6 @@ int cn_rp_recv(struct cnode *rp,
goto recover;
}
*flags |= CN_RP_RECV_RESULT_TYPE_CPTR;
} else if (e->source == CN_RP_ELEM_SOURCE_MESSAGE) {
} else {
cn_abort("Unrecognized rp elem source: %d", e->source);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment