Преглед изворни кода

* Ported [2847] to 1.2.10
* Fixed a timer bug which could cause prolonged looping.


svn: 2848

Bryan Drewery пре 20 година
родитељ
комит
97fe3ba3bb
2 измењених фајлова са 6 додато и 2 уклоњено
  1. 1 0
      doc/UPDATES
  2. 5 2
      src/egg_timer.c

+ 1 - 0
doc/UPDATES

@@ -28,6 +28,7 @@ Lines prefixed with '-' were disabled before release and are not finished, or ar
 * Now supressing "port taken" error on hub startup.
 * Now supressing "port taken" error on hub startup.
 * Removed stop-nethack and associated flags. (fixes #219)
 * Removed stop-nethack and associated flags. (fixes #219)
 * +bitch is now properly enforced on a netsplit return. (fixes #219)
 * +bitch is now properly enforced on a netsplit return. (fixes #219)
+* Fixed a timer bug which could cause prolonged looping.
 
 
 1.2.9 - http://tracker.shatow.net/milestone/1.2.9
 1.2.9 - http://tracker.shatow.net/milestone/1.2.9
 * Fixed cmd_[un]stick not properly using numbers for channel masks. (#160)
 * Fixed cmd_[un]stick not properly using numbers for channel masks. (#160)

+ 5 - 2
src/egg_timer.c

@@ -205,8 +205,11 @@ int timer_run()
 
 
 		if (timer->flags & TIMER_REPEAT) {
 		if (timer->flags & TIMER_REPEAT) {
 			/* Update timer. */
 			/* Update timer. */
-			timer->trigger_time.sec += timer->howlong.sec;
-			timer->trigger_time.usec += timer->howlong.usec;
+                        /* This used to be '+= howlong.sec' but, if the time changed say 3 years (happened), this function 
+                         * would end up executing all timers for 3 years until it is caught up.
+                         */
+			timer->trigger_time.sec = my_now.sec + timer->howlong.sec;
+			timer->trigger_time.usec = my_now.usec + timer->howlong.usec;
 
 
 			if (timer->trigger_time.usec >= 1000000) {
 			if (timer->trigger_time.usec >= 1000000) {
 				timer->trigger_time.usec -= 1000000;
 				timer->trigger_time.usec -= 1000000;