Commit 6e15674c authored by Filippos Giannakos's avatar Filippos Giannakos

xseg-tool: Fix verify functionality

parent 876b492f
......@@ -1228,7 +1228,7 @@ static void lock_status(struct xlock *lock, char *buf, int len)
if (lock->owner == XLOCK_NOONE) {
r = snprintf(buf, len, "Locked: No");
} else {
unpack_owner(lock->owner, &pid, &tid, &pc);
xlock_unpack_owner(lock->owner, &pid, &tid, &pc);
full_pc = (void *)lock->pc;
r = snprintf(buf, len, "Locked: Yes (Owner: %d, %d, %p[%p])",
pid, tid, pc, full_pc);
......@@ -1462,43 +1462,35 @@ int prompt_user(char *msg)
return r;
}
static void verify_lock(struct xlock *lock, char *name, int fix)
{
char buf[64];
if (lock->owner == XLOCK_NOONE) {
return;
}
lock_status(lock, buf, 64);
fprintf(stdout, "%s: %s\n", name, buf);
if (fix && prompt_user("Unlock it ?")) {
xlock_release(lock);
}
}
//FIXME this should be in xseg lib?
int cmd_verify(int fix)
{
char buf[64];
if (cmd_join())
return -1;
//segment lock
if (xseg->shared->flags & XSEG_F_LOCK){
fprintf(stderr, "Segment lock: Locked\n");
if (fix && prompt_user("Unlock it ?"))
xseg->shared->flags &= ~XSEG_F_LOCK;
}
//heap lock
if (xseg->heap->lock.owner != XLOCK_NOONE){
fprintf(stderr, "Heap lock: Locked (Owner: %llu)\n",
(unsigned long long)xseg->heap->lock.owner);
if (fix && prompt_user("Unlock it ?"))
xlock_release(&xseg->heap->lock);
}
//obj_h locks
if (xseg->request_h->lock.owner != XLOCK_NOONE){
fprintf(stderr, "Requests handler lock: Locked (Owner: %llu)\n",
(unsigned long long)xseg->request_h->lock.owner);
if (fix && prompt_user("Unlock it ?"))
xlock_release(&xseg->request_h->lock);
}
if (xseg->port_h->lock.owner != XLOCK_NOONE){
fprintf(stderr, "Ports handler lock: Locked (Owner: %llu)\n",
(unsigned long long)xseg->port_h->lock.owner);
if (fix && prompt_user("Unlock it ?"))
xlock_release(&xseg->port_h->lock);
}
if (xseg->object_handlers->lock.owner != XLOCK_NOONE){
fprintf(stderr, "Objects handler lock: Locked (Owner: %llu)\n",
(unsigned long long)xseg->object_handlers->lock.owner);
if (fix && prompt_user("Unlock it ?"))
xlock_release(&xseg->object_handlers->lock);
}
verify_lock(&xseg->shared->segment_lock, "Segment lock", fix);
verify_lock(&xseg->heap->lock, "Heap lock", fix);
verify_lock(&xseg->request_h->lock, "Request handler lock", fix);
verify_lock(&xseg->port_h->lock, "Port handler lock", fix);
verify_lock(&xseg->object_handlers->lock, "Objects handler lock", fix);
//take segment lock?
xport i;
struct xseg_port *port;
......@@ -1509,24 +1501,15 @@ int cmd_verify(int fix)
fprintf(stderr, "Inconsisten port <-> portno mapping %u", i);
continue;
}
if (port->fq_lock.owner != XLOCK_NOONE) {
fprintf(stderr, "Free queue lock of port %u locked (Owner %llu)\n",
i, (unsigned long long)port->fq_lock.owner);
if (fix && prompt_user("Unlock it ?"))
xlock_release(&port->fq_lock);
}
if (port->rq_lock.owner != XLOCK_NOONE) {
fprintf(stderr, "Request queue lock of port %u locked (Owner %llu)\n",
i, (unsigned long long)port->rq_lock.owner);
if (fix && prompt_user("Unlock it ?"))
xlock_release(&port->rq_lock);
}
if (port->pq_lock.owner != XLOCK_NOONE) {
fprintf(stderr, "Reply queue lock of port %u locked (Owner %llu)\n",
i, (unsigned long long)port->pq_lock.owner);
if (fix && prompt_user("Unlock it ?"))
xlock_release(&port->pq_lock);
}
snprintf(buf, 64, "Free queue lock of port %u", i);
verify_lock(&port->fq_lock, buf, fix);
snprintf(buf, 64, "Request queue lock of port %u", i);
verify_lock(&port->rq_lock, buf, fix);
snprintf(buf, 64, "Reply queue lock of port %u", i);
verify_lock(&port->pq_lock, buf, fix);
}
}
......
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