* Use a portable POSIX timed wait.
* Handle the different ioctl format.
This commit is contained in:
parent
71dafcd844
commit
105579b1e6
@ -82,6 +82,7 @@ dtrace_sleep(dtrace_hdl_t *dtp)
|
||||
return; /* sleep duration has already past */
|
||||
}
|
||||
|
||||
#if defined(sun)
|
||||
tv.tv_sec = (earliest - now) / NANOSEC;
|
||||
tv.tv_nsec = (earliest - now) % NANOSEC;
|
||||
|
||||
@ -91,6 +92,23 @@ dtrace_sleep(dtrace_hdl_t *dtp)
|
||||
* awaken, iterate over any pending notifications and process them.
|
||||
*/
|
||||
(void) pthread_cond_reltimedwait_np(&dph->dph_cv, &dph->dph_lock, &tv);
|
||||
#else
|
||||
earliest -= now;
|
||||
clock_gettime(CLOCK_REALTIME,&tv);
|
||||
tv.tv_sec += earliest / NANOSEC;
|
||||
tv.tv_nsec += earliest % NANOSEC;
|
||||
while (tv.tv_nsec > NANOSEC) {
|
||||
tv.tv_sec += 1;
|
||||
tv.tv_nsec -= NANOSEC;
|
||||
}
|
||||
|
||||
/*
|
||||
* Wait for either 'tv' nanoseconds to pass or to receive notification
|
||||
* that a process is in an interesting state. Regardless of why we
|
||||
* awaken, iterate over any pending notifications and process them.
|
||||
*/
|
||||
(void) pthread_cond_timedwait(&dph->dph_cv, &dph->dph_lock, &tv);
|
||||
#endif
|
||||
|
||||
while ((dprn = dph->dph_notify) != NULL) {
|
||||
if (dtp->dt_prochdlr != NULL) {
|
||||
@ -164,6 +182,7 @@ dtrace_status(dtrace_hdl_t *dtp)
|
||||
int
|
||||
dtrace_go(dtrace_hdl_t *dtp)
|
||||
{
|
||||
dtrace_enable_io_t args;
|
||||
void *dof;
|
||||
int err;
|
||||
|
||||
@ -185,7 +204,9 @@ dtrace_go(dtrace_hdl_t *dtp)
|
||||
if ((dof = dtrace_getopt_dof(dtp)) == NULL)
|
||||
return (-1); /* dt_errno has been set for us */
|
||||
|
||||
err = dt_ioctl(dtp, DTRACEIOC_ENABLE, dof);
|
||||
args.dof = dof;
|
||||
args.n_matched = 0;
|
||||
err = dt_ioctl(dtp, DTRACEIOC_ENABLE, &args);
|
||||
dtrace_dof_destroy(dtp, dof);
|
||||
|
||||
if (err == -1 && (errno != ENOTTY || dtp->dt_vector == NULL))
|
||||
|
Loading…
Reference in New Issue
Block a user