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:
parent
349bcca42d
commit
95aaf6bde8
|
@ -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
|
* Copyright (c) 2000-2001 Boris Popov
|
||||||
|
@ -35,7 +35,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#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/param.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
|
@ -80,9 +80,16 @@ smb_iod_rqprocessed(struct smb_rq *rqp, int error)
|
||||||
rqp->sr_rpgen++;
|
rqp->sr_rpgen++;
|
||||||
rqp->sr_state = SMBRQ_NOTIFIED;
|
rqp->sr_state = SMBRQ_NOTIFIED;
|
||||||
wakeup(&rqp->sr_state);
|
wakeup(&rqp->sr_state);
|
||||||
|
callout_stop(&rqp->sr_timo_ch);
|
||||||
SMBRQ_SUNLOCK(rqp);
|
SMBRQ_SUNLOCK(rqp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
smb_iod_rqtimedout(void *arg)
|
||||||
|
{
|
||||||
|
smb_iod_rqprocessed((struct smb_rq *)arg, ETIMEDOUT);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
smb_iod_invrq(struct smbiod *iod)
|
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);
|
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;
|
error = rqp->sr_lerror = (m) ? SMB_TRAN_SEND(vcp, m, p) : ENOBUFS;
|
||||||
if (error == 0) {
|
if (error == 0) {
|
||||||
int s;
|
if (rqp->sr_timo > 0) {
|
||||||
struct timeval ts, tstimeout;
|
callout_init(&rqp->sr_timo_ch);
|
||||||
|
callout_reset(&rqp->sr_timo_ch, rqp->sr_timo,
|
||||||
SMB_TRAN_GETPARAM(vcp, SMBTP_TIMEOUT, &tstimeout);
|
smb_iod_rqtimedout, rqp);
|
||||||
s = splclock();
|
}
|
||||||
ts = mono_time;
|
|
||||||
splx(s);
|
|
||||||
timeradd(&ts, &tstimeout, &rqp->sr_sendtimo);
|
|
||||||
#if 0
|
#if 0
|
||||||
iod->iod_lastrqsent = ts;
|
iod->iod_lastrqsent = ts;
|
||||||
#endif
|
#endif
|
||||||
|
@ -542,8 +546,7 @@ static void
|
||||||
smb_iod_sendall(struct smbiod *iod)
|
smb_iod_sendall(struct smbiod *iod)
|
||||||
{
|
{
|
||||||
struct smb_rq *rqp;
|
struct smb_rq *rqp;
|
||||||
struct timeval ts;
|
int herror;
|
||||||
int herror, s;
|
|
||||||
|
|
||||||
herror = 0;
|
herror = 0;
|
||||||
/*
|
/*
|
||||||
|
@ -551,8 +554,7 @@ smb_iod_sendall(struct smbiod *iod)
|
||||||
*/
|
*/
|
||||||
SMB_IOD_RQLOCK(iod);
|
SMB_IOD_RQLOCK(iod);
|
||||||
SIMPLEQ_FOREACH(rqp, &iod->iod_rqlist, sr_link) {
|
SIMPLEQ_FOREACH(rqp, &iod->iod_rqlist, sr_link) {
|
||||||
switch (rqp->sr_state) {
|
if (__predict_false(rqp->sr_state == SMBRQ_NOTSENT)) {
|
||||||
case SMBRQ_NOTSENT:
|
|
||||||
rqp->sr_flags |= SMBR_XLOCK;
|
rqp->sr_flags |= SMBR_XLOCK;
|
||||||
SMB_IOD_RQUNLOCK(iod);
|
SMB_IOD_RQUNLOCK(iod);
|
||||||
herror = smb_iod_sendrq(iod, rqp);
|
herror = smb_iod_sendrq(iod, rqp);
|
||||||
|
@ -562,20 +564,10 @@ smb_iod_sendall(struct smbiod *iod)
|
||||||
rqp->sr_flags &= ~SMBR_XLOCKWANT;
|
rqp->sr_flags &= ~SMBR_XLOCKWANT;
|
||||||
wakeup(rqp);
|
wakeup(rqp);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case SMBRQ_SENT:
|
if (__predict_false(herror != 0))
|
||||||
s = splclock();
|
break;
|
||||||
ts = mono_time;
|
|
||||||
splx(s);
|
|
||||||
if (timercmp(&ts, &rqp->sr_sendtimo, >)) {
|
|
||||||
smb_iod_rqprocessed(rqp, ETIMEDOUT);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if (herror)
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
SMB_IOD_RQUNLOCK(iod);
|
SMB_IOD_RQUNLOCK(iod);
|
||||||
if (herror == ENOTCONN)
|
if (herror == ENOTCONN)
|
||||||
|
|
|
@ -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
|
* Copyright (c) 2000-2001, Boris Popov
|
||||||
|
@ -35,7 +35,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#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/param.h>
|
||||||
#include <sys/systm.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)
|
struct smb_cred *scred)
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
|
struct timeval timo;
|
||||||
|
|
||||||
bzero(rqp, sizeof(*rqp));
|
bzero(rqp, sizeof(*rqp));
|
||||||
smb_sl_init(&rqp->sr_slock, "srslock");
|
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_cred = scred;
|
||||||
rqp->sr_mid = smb_vc_nextmid(rqp->sr_vc);
|
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);
|
return smb_rq_new(rqp, cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
* Copyright (c) 2000-2001, Boris Popov
|
||||||
|
@ -89,8 +89,8 @@ struct smb_rq {
|
||||||
struct smb_cred * sr_cred;
|
struct smb_cred * sr_cred;
|
||||||
u_short sr_mid;
|
u_short sr_mid;
|
||||||
u_short sr_flags; /* SMBR_* */
|
u_short sr_flags; /* SMBR_* */
|
||||||
struct timeval sr_sendtimo; /* timeout expiration time */
|
struct callout sr_timo_ch; /* for timeout expiration */
|
||||||
int sr_timo;
|
int sr_timo; /* timeout in ticks, -1 notimo*/
|
||||||
int sr_sendcnt;
|
int sr_sendcnt;
|
||||||
int sr_lerror;
|
int sr_lerror;
|
||||||
u_int8_t * sr_rqtid;
|
u_int8_t * sr_rqtid;
|
||||||
|
|
Loading…
Reference in New Issue