MCPcopy Create free account
hub / github.com/F-Stack/f-stack / filt_timertouch

Function filt_timertouch

freebsd/kern/kern_event.c:793–858  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

791}
792
793static void
794filt_timertouch(struct knote *kn, struct kevent *kev, u_long type)
795{
796 struct kq_timer_cb_data *kc;
797 struct kqueue *kq;
798 sbintime_t to;
799 int error;
800
801 switch (type) {
802 case EVENT_REGISTER:
803 /* Handle re-added timers that update data/fflags */
804 if (kev->flags & EV_ADD) {
805 kc = kn->kn_ptr.p_v;
806
807 /* Drain any existing callout. */
808 callout_drain(&kc->c);
809
810 /* Throw away any existing undelivered record
811 * of the timer expiration. This is done under
812 * the presumption that if a process is
813 * re-adding this timer with new parameters,
814 * it is no longer interested in what may have
815 * happened under the old parameters. If it is
816 * interested, it can wait for the expiration,
817 * delete the old timer definition, and then
818 * add the new one.
819 *
820 * This has to be done while the kq is locked:
821 * - if enqueued, dequeue
822 * - make it no longer active
823 * - clear the count of expiration events
824 */
825 kq = kn->kn_kq;
826 KQ_LOCK(kq);
827 if (kn->kn_status & KN_QUEUED)
828 knote_dequeue(kn);
829
830 kn->kn_status &= ~KN_ACTIVE;
831 kn->kn_data = 0;
832 KQ_UNLOCK(kq);
833
834 /* Reschedule timer based on new data/fflags */
835 kn->kn_sfflags = kev->fflags;
836 kn->kn_sdata = kev->data;
837 error = filt_timervalidate(kn, &to);
838 if (error != 0) {
839 kn->kn_flags |= EV_ERROR;
840 kn->kn_data = error;
841 } else
842 filt_timerstart(kn, to);
843 }
844 break;
845
846 case EVENT_PROCESS:
847 *kev = kn->kn_kevent;
848 if (kn->kn_flags & EV_CLEAR) {
849 kn->kn_data = 0;
850 kn->kn_fflags = 0;

Callers

nothing calls this directly

Calls 4

knote_dequeueFunction · 0.85
filt_timervalidateFunction · 0.85
filt_timerstartFunction · 0.85
panicFunction · 0.70

Tested by

no test coverage detected