Commit e279a10e authored by Jonathan Jenkins's avatar Jonathan Jenkins

resource lp fixes (bitfield isn't reset after rollback)

parent 7d65c113
...@@ -251,7 +251,8 @@ static void handle_resource_free_rc( ...@@ -251,7 +251,8 @@ static void handle_resource_free_rc(
} }
/* bitfield usage: /* bitfield usage:
* c0 - dequeue+alloc success */ * c0 - queue was empty to begin with
* c1 - assuming !c0, alloc succeeded */
static void handle_resource_deq( static void handle_resource_deq(
resource_state * ns, resource_state * ns,
tw_bf * b, tw_bf * b,
...@@ -259,6 +260,7 @@ static void handle_resource_deq( ...@@ -259,6 +260,7 @@ static void handle_resource_deq(
tw_lp * lp){ tw_lp * lp){
if (qlist_empty(&ns->pending[m->i.tok])){ if (qlist_empty(&ns->pending[m->i.tok])){
/* nothing to do */ /* nothing to do */
b->c0 = 1;
return; return;
} }
...@@ -267,7 +269,7 @@ static void handle_resource_deq( ...@@ -267,7 +269,7 @@ static void handle_resource_deq(
int ret = resource_get(p->m.req, p->m.tok, &ns->r); int ret = resource_get(p->m.req, p->m.tok, &ns->r);
assert(ret != 2); assert(ret != 2);
if (!ret){ if (!ret){
b->c0 = 1; b->c1 = 1;
/* success, dequeue (saving as rc) and send to client */ /* success, dequeue (saving as rc) and send to client */
qlist_del(front); qlist_del(front);
m->i_rc = p->m; m->i_rc = p->m;
...@@ -291,12 +293,11 @@ static void handle_resource_deq_rc( ...@@ -291,12 +293,11 @@ static void handle_resource_deq_rc(
tw_bf * b, tw_bf * b,
resource_msg * m, resource_msg * m,
tw_lp * lp){ tw_lp * lp){
if (qlist_empty(&ns->pending[m->i.tok])){ if (b->c0){
/* nothing to do */
return; return;
} }
if (b->c0){ if (b->c1){
/* add operation back to the front of the queue */ /* add operation back to the front of the queue */
pending_op *op = malloc(sizeof(pending_op)); pending_op *op = malloc(sizeof(pending_op));
op->m = m->i_rc; op->m = m->i_rc;
...@@ -376,12 +377,21 @@ void resource_rev_handler( ...@@ -376,12 +377,21 @@ void resource_rev_handler(
default: default:
assert(0); assert(0);
} }
// NOTE: ross doesn't reset b in the case of multiple rollbacks...
*(int*)b = 0;
} }
void resource_finalize( void resource_finalize(
resource_state * ns, resource_state * ns,
tw_lp * lp){ tw_lp * lp){
/* Fill me in... */ /* Fill me in... */
struct qlist_head *ent;
qlist_for_each(ent, ns->pending){
pending_op *op = qlist_entry(ent, pending_op, ql);
fprintf(stderr, "WARNING: resource LP %lu has a pending allocation\n",
lp->gid);
}
} }
/**** END IMPLEMENTATIONS ****/ /**** END IMPLEMENTATIONS ****/
......
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