use callout for request timeout, so that it could expire independantly

of iod calling smb_iod_sendall()
g/c now unneeded request timeout expire check from smb_iod_sendall()

make it possible to override default request timeout - set timeout
value in smb_rq_init() to default value, caller can adjust the value
before calling smb_iod_sendrq(); value <=0  means no timeout
This commit is contained in:
jdolecek 2003-03-30 11:58:17 +00:00
parent 349bcca42d
commit 95aaf6bde8
3 changed files with 27 additions and 32 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: smb_iod.c,v 1.15 2003/03/30 11:27:45 jdolecek Exp $ */
/* $NetBSD: smb_iod.c,v 1.16 2003/03/30 11:58:17 jdolecek Exp $ */
/*
* Copyright (c) 2000-2001 Boris Popov
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: smb_iod.c,v 1.15 2003/03/30 11:27:45 jdolecek Exp $");
__KERNEL_RCSID(0, "$NetBSD: smb_iod.c,v 1.16 2003/03/30 11:58:17 jdolecek Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -80,9 +80,16 @@ smb_iod_rqprocessed(struct smb_rq *rqp, int error)
rqp->sr_rpgen++;
rqp->sr_state = SMBRQ_NOTIFIED;
wakeup(&rqp->sr_state);
callout_stop(&rqp->sr_timo_ch);
SMBRQ_SUNLOCK(rqp);
}
static void
smb_iod_rqtimedout(void *arg)
{
smb_iod_rqprocessed((struct smb_rq *)arg, ETIMEDOUT);
}
static void
smb_iod_invrq(struct smbiod *iod)
{
@ -254,14 +261,11 @@ smb_iod_sendrq(struct smbiod *iod, struct smb_rq *rqp)
m = m_copym(rqp->sr_rq.mb_top, 0, M_COPYALL, M_WAIT);
error = rqp->sr_lerror = (m) ? SMB_TRAN_SEND(vcp, m, p) : ENOBUFS;
if (error == 0) {
int s;
struct timeval ts, tstimeout;
SMB_TRAN_GETPARAM(vcp, SMBTP_TIMEOUT, &tstimeout);
s = splclock();
ts = mono_time;
splx(s);
timeradd(&ts, &tstimeout, &rqp->sr_sendtimo);
if (rqp->sr_timo > 0) {
callout_init(&rqp->sr_timo_ch);
callout_reset(&rqp->sr_timo_ch, rqp->sr_timo,
smb_iod_rqtimedout, rqp);
}
#if 0
iod->iod_lastrqsent = ts;
#endif
@ -542,8 +546,7 @@ static void
smb_iod_sendall(struct smbiod *iod)
{
struct smb_rq *rqp;
struct timeval ts;
int herror, s;
int herror;
herror = 0;
/*
@ -551,8 +554,7 @@ smb_iod_sendall(struct smbiod *iod)
*/
SMB_IOD_RQLOCK(iod);
SIMPLEQ_FOREACH(rqp, &iod->iod_rqlist, sr_link) {
switch (rqp->sr_state) {
case SMBRQ_NOTSENT:
if (__predict_false(rqp->sr_state == SMBRQ_NOTSENT)) {
rqp->sr_flags |= SMBR_XLOCK;
SMB_IOD_RQUNLOCK(iod);
herror = smb_iod_sendrq(iod, rqp);
@ -562,20 +564,10 @@ smb_iod_sendall(struct smbiod *iod)
rqp->sr_flags &= ~SMBR_XLOCKWANT;
wakeup(rqp);
}
break;
case SMBRQ_SENT:
s = splclock();
ts = mono_time;
splx(s);
if (timercmp(&ts, &rqp->sr_sendtimo, >)) {
smb_iod_rqprocessed(rqp, ETIMEDOUT);
}
break;
default:
break;
if (__predict_false(herror != 0))
break;
}
if (herror)
break;
}
SMB_IOD_RQUNLOCK(iod);
if (herror == ENOTCONN)

View File

@ -1,4 +1,4 @@
/* $NetBSD: smb_rq.c,v 1.16 2003/03/24 07:51:04 jdolecek Exp $ */
/* $NetBSD: smb_rq.c,v 1.17 2003/03/30 11:58:17 jdolecek Exp $ */
/*
* Copyright (c) 2000-2001, Boris Popov
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: smb_rq.c,v 1.16 2003/03/24 07:51:04 jdolecek Exp $");
__KERNEL_RCSID(0, "$NetBSD: smb_rq.c,v 1.17 2003/03/30 11:58:17 jdolecek Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -92,6 +92,7 @@ smb_rq_init(struct smb_rq *rqp, struct smb_connobj *layer, u_char cmd,
struct smb_cred *scred)
{
int error;
struct timeval timo;
bzero(rqp, sizeof(*rqp));
smb_sl_init(&rqp->sr_slock, "srslock");
@ -108,6 +109,8 @@ smb_rq_init(struct smb_rq *rqp, struct smb_connobj *layer, u_char cmd,
}
rqp->sr_cred = scred;
rqp->sr_mid = smb_vc_nextmid(rqp->sr_vc);
SMB_TRAN_GETPARAM(rqp->sr_vc, SMBTP_TIMEOUT, &timo);
rqp->sr_timo = timo.tv_sec * hz;
return smb_rq_new(rqp, cmd);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: smb_rq.h,v 1.6 2003/03/23 16:57:51 jdolecek Exp $ */
/* $NetBSD: smb_rq.h,v 1.7 2003/03/30 11:58:17 jdolecek Exp $ */
/*
* Copyright (c) 2000-2001, Boris Popov
@ -89,8 +89,8 @@ struct smb_rq {
struct smb_cred * sr_cred;
u_short sr_mid;
u_short sr_flags; /* SMBR_* */
struct timeval sr_sendtimo; /* timeout expiration time */
int sr_timo;
struct callout sr_timo_ch; /* for timeout expiration */
int sr_timo; /* timeout in ticks, -1 notimo*/
int sr_sendcnt;
int sr_lerror;
u_int8_t * sr_rqtid;