Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_timeout.c
Show First 20 Lines • Show All 1,144 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
int | int | ||||
_callout_stop_safe(struct callout *c, int safe) | _callout_stop_safe(struct callout *c, int safe) | ||||
{ | { | ||||
struct callout_cpu *cc, *old_cc; | struct callout_cpu *cc, *old_cc; | ||||
struct lock_class *class; | struct lock_class *class; | ||||
int direct, sq_locked, use_lock; | int direct, sq_locked, use_lock; | ||||
int not_on_a_list; | int not_on_a_list, not_running; | ||||
jhb: If you call the new variable 'not_running' you can drop a few !'s. Normally I would not like… | |||||
Not Done Inline ActionsIt is a good idea, too many !'s are indeed confusing. Updated. jch: It is a good idea, too many !'s are indeed confusing. Updated. | |||||
if (safe) | if (safe) | ||||
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, c->c_lock, | WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, c->c_lock, | ||||
"calling %s", __func__); | "calling %s", __func__); | ||||
/* | /* | ||||
* Some old subsystems don't hold Giant while running a callout_stop(), | * Some old subsystems don't hold Giant while running a callout_stop(), | ||||
* so just discard this check for the moment. | * so just discard this check for the moment. | ||||
▲ Show 20 Lines • Show All 211 Lines • ▼ Show 20 Lines | if ((c->c_iflags & CALLOUT_PROCESSED) == 0) { | ||||
if (cc_exec_next(cc) == c) | if (cc_exec_next(cc) == c) | ||||
cc_exec_next(cc) = LIST_NEXT(c, c_links.le); | cc_exec_next(cc) = LIST_NEXT(c, c_links.le); | ||||
LIST_REMOVE(c, c_links.le); | LIST_REMOVE(c, c_links.le); | ||||
} else { | } else { | ||||
TAILQ_REMOVE(&cc->cc_expireq, c, c_links.tqe); | TAILQ_REMOVE(&cc->cc_expireq, c, c_links.tqe); | ||||
} | } | ||||
} | } | ||||
callout_cc_del(c, cc); | callout_cc_del(c, cc); | ||||
/* | |||||
* If we are asked to stop a callout which is currently in progress | |||||
* and indeed impossible to stop then return 0. | |||||
*/ | |||||
not_running = !(cc_exec_curr(cc, direct) == c); | |||||
CC_UNLOCK(cc); | CC_UNLOCK(cc); | ||||
return (1); | return (not_running); | ||||
} | } | ||||
void | void | ||||
callout_init(struct callout *c, int mpsafe) | callout_init(struct callout *c, int mpsafe) | ||||
{ | { | ||||
bzero(c, sizeof *c); | bzero(c, sizeof *c); | ||||
if (mpsafe) { | if (mpsafe) { | ||||
c->c_lock = NULL; | c->c_lock = NULL; | ||||
▲ Show 20 Lines • Show All 206 Lines • Show Last 20 Lines |
If you call the new variable 'not_running' you can drop a few !'s. Normally I would not like to have 'not_<foo>' variables, but we already have 'not_on_a_list', so I think it would be ok in this case. However, this is a minor suggestion. Feel free to ignore.