Fix for rescheduling a timer that is currently in progress.
Also fix a typo which uses the wrong mutex for a condition wait.
@@ -113,6 +113,21 @@ sctp_os_timer_start(sctp_os_timer_t *c, int to_ticks, void (*ftn) (void *),
SCTP_TIMERQ_LOCK();
/* check to see if we're rescheduling a timer */
+ if (c == sctp_os_timer_current) {
+ /*
+ * We're being asked to reschedule a callout which is
+ * currently in progress.
+ */
+ if (sctp_os_timer_waiting) {
+ /*
+ * This callout is already being stopped.
+ * callout. Don't reschedule.
+ */
+ SCTP_TIMERQ_UNLOCK();
+ return;
+ }
+ }
+
if (c->c_flags & SCTP_CALLOUT_PENDING) {
if (c == sctp_os_timer_next) {
sctp_os_timer_next = TAILQ_NEXT(c, tqe);
@@ -172,7 +187,7 @@ sctp_os_timer_stop(sctp_os_timer_t *c)
INFINITE);
#else
pthread_cond_wait(&sctp_os_timer_wait_cond,
- &SCTP_BASE_VAR(timer_mtx));
+ &sctp_os_timerwait_mtx);
#endif
}
SCTP_TIMERWAIT_UNLOCK();
