From 52fffe216309d23170f52015304d34ce9ae10722 Mon Sep 17 00:00:00 2001 From: pooka Date: Mon, 10 Jan 2011 11:57:53 +0000 Subject: [PATCH] g/c code which is unused in the server --- lib/librumpuser/rumpuser_sp.c | 61 +++-------------------------------- lib/librumpuser/sp_common.c | 8 ++--- 2 files changed, 8 insertions(+), 61 deletions(-) diff --git a/lib/librumpuser/rumpuser_sp.c b/lib/librumpuser/rumpuser_sp.c index fd52728303b8..2b85dd0fd22e 100644 --- a/lib/librumpuser/rumpuser_sp.c +++ b/lib/librumpuser/rumpuser_sp.c @@ -1,4 +1,4 @@ -/* $NetBSD: rumpuser_sp.c,v 1.32 2011/01/09 14:10:03 pooka Exp $ */ +/* $NetBSD: rumpuser_sp.c,v 1.33 2011/01/10 11:57:53 pooka Exp $ */ /* * Copyright (c) 2010, 2011 Antti Kantee. All Rights Reserved. @@ -35,7 +35,7 @@ */ #include -__RCSID("$NetBSD: rumpuser_sp.c,v 1.32 2011/01/09 14:10:03 pooka Exp $"); +__RCSID("$NetBSD: rumpuser_sp.c,v 1.33 2011/01/10 11:57:53 pooka Exp $"); #include #include @@ -99,68 +99,17 @@ static pthread_mutex_t pfmtx; /* * This version is for the server. It's optimized for multiple threads - * and is *NOT* reentrant wrt to signals + * and is *NOT* reentrant wrt to signals. */ static int waitresp(struct spclient *spc, struct respwait *rw) { - struct pollfd pfd; int rv = 0; sendunlockl(spc); - - rw->rw_error = 0; - while (!rw->rw_done && rw->rw_error == 0 - && spc->spc_state != SPCSTATE_DYING){ - /* are we free to receive? */ - if (spc->spc_istatus == SPCSTATUS_FREE) { - int gotresp; - - spc->spc_istatus = SPCSTATUS_BUSY; - pthread_mutex_unlock(&spc->spc_mtx); - - pfd.fd = spc->spc_fd; - pfd.events = POLLIN; - - for (gotresp = 0; !gotresp; ) { - switch (readframe(spc)) { - case 0: - poll(&pfd, 1, INFTIM); - continue; - case -1: - rv = errno; - spc->spc_state = SPCSTATE_DYING; - goto cleanup; - default: - break; - } - - switch (spc->spc_hdr.rsp_class) { - case RUMPSP_RESP: - case RUMPSP_ERROR: - kickwaiter(spc); - gotresp = spc->spc_hdr.rsp_reqno == - rw->rw_reqno; - break; - case RUMPSP_REQ: - handlereq(spc); - break; - default: - /* panic */ - break; - } - } - cleanup: - pthread_mutex_lock(&spc->spc_mtx); - if (spc->spc_istatus == SPCSTATUS_WANTED) - kickall(spc); - spc->spc_istatus = SPCSTATUS_FREE; - } else { - spc->spc_istatus = SPCSTATUS_WANTED; - pthread_cond_wait(&rw->rw_cv, &spc->spc_mtx); - } + while (!rw->rw_done && spc->spc_state != SPCSTATE_DYING) { + pthread_cond_wait(&rw->rw_cv, &spc->spc_mtx); } - TAILQ_REMOVE(&spc->spc_respwait, rw, rw_entries); pthread_mutex_unlock(&spc->spc_mtx); diff --git a/lib/librumpuser/sp_common.c b/lib/librumpuser/sp_common.c index 7fa32576207b..b3df305465e3 100644 --- a/lib/librumpuser/sp_common.c +++ b/lib/librumpuser/sp_common.c @@ -1,4 +1,4 @@ -/* $NetBSD: sp_common.c,v 1.21 2011/01/09 14:10:03 pooka Exp $ */ +/* $NetBSD: sp_common.c,v 1.22 2011/01/10 11:57:53 pooka Exp $ */ /* * Copyright (c) 2010, 2011 Antti Kantee. All Rights Reserved. @@ -290,7 +290,7 @@ putwait(struct spclient *spc, struct respwait *rw, struct rsp_hdr *rhdr) { rw->rw_data = NULL; - rw->rw_dlen = rw->rw_done = 0; + rw->rw_dlen = rw->rw_done = rw->rw_error = 0; pthread_cond_init(&rw->rw_cv, NULL); pthread_mutex_lock(&spc->spc_mtx); @@ -315,7 +315,7 @@ static void kickwaiter(struct spclient *spc) { struct respwait *rw; - int error; + int error = 0; pthread_mutex_lock(&spc->spc_mtx); TAILQ_FOREACH(rw, &spc->spc_respwait, rw_entries) { @@ -334,8 +334,6 @@ kickwaiter(struct spclient *spc) rw->rw_dlen = (size_t)(spc->spc_off - HDRSZ); if (spc->spc_hdr.rsp_class == RUMPSP_ERROR) { error = rw->rw_error = spc->spc_hdr.rsp_error; - } else { - error = rw->rw_error = 0; } pthread_cond_signal(&rw->rw_cv); pthread_mutex_unlock(&spc->spc_mtx);