/// Handler for LMP bind reply messages from the Monitor static void bind_lmp_reply_handler(struct monitor_binding *b, errval_t success, uintptr_t mon_id, uintptr_t conn_id, struct capref endpoint) { struct lmp_chan *lc = (void *)conn_id; errval_t err; assert(lc->connstate == LMP_BIND_WAIT); if (err_is_ok(success)) { /* bind succeeded */ lc->connstate = LMP_CONNECTED; /* Place the cap in the rootcn, to allow LRPC */ err = move_to_root(endpoint, &lc->remote_cap); if (err_is_fail(err)) { DEBUG_ERR(err, "error moving endpoint cap to root in LMP bind reply"); // leave it where it is, and continue lc->remote_cap = endpoint; } } /* either way, tell the user what happened */ assert(lc->bind_continuation.handler != NULL); lc->bind_continuation.handler(lc->bind_continuation.st, success, lc); }
static void actlist_insert_after(actlist_t*a, segment_t*left, segment_t*s) { #ifdef SPLAY //fprintf(stderr, "insert [%d] after [%d]\n", SEGNR(s), SEGNR(left)); //actlist_splay_dump(a); //actlist_dump(a, s->a.y); #endif s->left = left; if(left) { s->right = left->right; } else { s->right = a->list; a->list = s; } if(s->left) s->left->right = s; if(s->right) s->right->left = s; #ifdef SPLAY // we insert nodes not trees assert(!s->leftchild); assert(!s->rightchild); if(a->root) { move_to_root(a, left); if(left) { LINK(s,leftchild,a->root); // steal right child from (previous) root LINK(s,rightchild,a->root->rightchild); a->root->rightchild = 0; } else { LINK(s,rightchild,a->root); } } a->root = s; a->root->parent = 0; assert(actlist_splay_verify(a)); #endif a->size++; }
void actlist_delete(actlist_t*a, segment_t*s) { #ifdef SPLAY assert(actlist_splay_verify(a)); move_to_root(a, s); assert(actlist_splay_verify(a)); #endif if(s->left) { s->left->right = s->right; } else { a->list = s->right; } if(s->right) { s->right->left = s->left; } s->left = s->right = 0; a->size--; #ifdef SPLAY assert(a->root == s); // delete root node if(!a->root->leftchild) { a->root = a->root->rightchild; } else if(!a->root->rightchild) { a->root = a->root->leftchild; } else { #ifdef HAVE_LRAND48 if(lrand48()&1) { #else if(((ptroff_t)s)&16) { #endif // free up root->left->right segment_t*t = a->root->leftchild; while(t->rightchild) { segment_t*r = t->rightchild; segment_t*l = r->leftchild; LINK(r, leftchild, t); LINK(t, rightchild, l); t = r; } LINK(a->root,leftchild,t); assert(!a->root->leftchild->rightchild); LINK(a->root->leftchild,rightchild,a->root->rightchild); a->root = a->root->leftchild; } else { // free up root->right->left segment_t*t = a->root->rightchild; while(t->leftchild) { segment_t*l = t->leftchild; segment_t*r = l->rightchild; LINK(l, rightchild, t); LINK(t, leftchild, r); t = l; } LINK(a->root,rightchild,t); assert(!a->root->rightchild->leftchild); LINK(a->root->rightchild,leftchild,a->root->leftchild); a->root = a->root->rightchild; } } if(a->root) a->root->parent = 0; s->leftchild = s->rightchild = s->parent = 0; assert(actlist_splay_verify(a)); #endif } int actlist_size(actlist_t*a) { return a->size; } segment_t* actlist_leftmost(actlist_t*a) { return a->list; } segment_t* actlist_rightmost(actlist_t*a) { /* this is only used in checks, so it doesn't matter that it's slow */ #ifndef CHECKS fprintf(stderr, "Warning: actlist_rightmost should not be used\n"); #endif segment_t*s = a->list; segment_t*last = 0; while(s) { last = s; s = s->right; } return last; }