Register itimers_event_hook as a kernel event handler, so I don't
have to duplicate code to call it in exec() and exit1().
This commit is contained in:
parent
6593049efd
commit
d26b1a1fb9
@ -58,7 +58,6 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/sysent.h>
|
||||
#include <sys/shm.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/timers.h>
|
||||
#include <sys/vnode.h>
|
||||
#ifdef KTRACE
|
||||
#include <sys/ktrace.h>
|
||||
@ -481,9 +480,6 @@ do_execve(td, args, mac_p)
|
||||
*/
|
||||
fdunshare(p, td);
|
||||
|
||||
/* Clear POSIX timers */
|
||||
itimers_event_hook(p, ITIMER_EV_EXEC);
|
||||
|
||||
/*
|
||||
* Malloc things before we need locks.
|
||||
*/
|
||||
|
@ -66,7 +66,6 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/mac.h>
|
||||
#include <sys/shm.h>
|
||||
#include <sys/sem.h>
|
||||
#include <sys/timers.h>
|
||||
#ifdef KTRACE
|
||||
#include <sys/ktrace.h>
|
||||
#endif
|
||||
@ -232,8 +231,6 @@ exit1(struct thread *td, int rv)
|
||||
sigqueue_flush(&td->td_sigqueue);
|
||||
PROC_UNLOCK(p);
|
||||
|
||||
itimers_event_hook(p, ITIMER_EV_EXIT);
|
||||
|
||||
/*
|
||||
* Reset any sigio structures pointing to us as a result of
|
||||
* F_SETOWN with our pid.
|
||||
|
@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/lock.h>
|
||||
#include <sys/mutex.h>
|
||||
#include <sys/sysproto.h>
|
||||
#include <sys/eventhandler.h>
|
||||
#include <sys/resourcevar.h>
|
||||
#include <sys/signalvar.h>
|
||||
#include <sys/kernel.h>
|
||||
@ -86,6 +87,7 @@ static void itimer_enter(struct itimer *);
|
||||
static void itimer_leave(struct itimer *);
|
||||
static struct itimer *itimer_find(struct proc *, timer_t, int);
|
||||
static void itimers_alloc(struct proc *);
|
||||
static void itimers_event_hook(void *arg, struct proc *p);
|
||||
static int realtimer_create(struct itimer *);
|
||||
static int realtimer_gettime(struct itimer *, struct itimerspec *);
|
||||
static int realtimer_settime(struct itimer *, int,
|
||||
@ -889,6 +891,10 @@ itimer_start(void)
|
||||
p31b_setcfg(CTL_P1003_1B_TIMERS, 200112L);
|
||||
p31b_setcfg(CTL_P1003_1B_DELAYTIMER_MAX, INT_MAX);
|
||||
p31b_setcfg(CTL_P1003_1B_TIMER_MAX, TIMER_MAX);
|
||||
EVENTHANDLER_REGISTER(process_exit, itimers_event_hook,
|
||||
(void *)ITIMER_EV_EXIT, EVENTHANDLER_PRI_ANY);
|
||||
EVENTHANDLER_REGISTER(process_exec, itimers_event_hook,
|
||||
(void *)ITIMER_EV_EXEC, EVENTHANDLER_PRI_ANY);
|
||||
}
|
||||
|
||||
int
|
||||
@ -1504,11 +1510,12 @@ itimers_alloc(struct proc *p)
|
||||
}
|
||||
|
||||
/* Clean up timers when some process events are being triggered. */
|
||||
void
|
||||
itimers_event_hook(struct proc *p, int event)
|
||||
static void
|
||||
itimers_event_hook(void *arg, struct proc *p)
|
||||
{
|
||||
struct itimers *its;
|
||||
struct itimer *it;
|
||||
int event = (int)arg;
|
||||
int i;
|
||||
|
||||
if (p->p_itimers != NULL) {
|
||||
|
Loading…
Reference in New Issue
Block a user