timers: assure setTimeout callback only runs once by silverwind · Pull Request #1231 · nodejs/node

@silverwind changed the title timer: assure setTimeout callback only run once timer: assure setTimeout callback only runs once

Mar 21, 2015

@silverwind silverwind added the timers

Issues and PRs related to the timers subsystem / setImmediate, setInterval, setTimeout.

label

Mar 21, 2015

@silverwind silverwind changed the title timer: assure setTimeout callback only runs once timers: assure setTimeout callback only runs once

Mar 21, 2015

@silverwind

This fixes an edge case where running this.unref() during the callback caused the
callback to get executed multiple times.

@rvagg rvagg mentioned this pull request

Mar 25, 2015

@silverwind

@silverwind

@silverwind

@silverwind

silverwind added a commit that referenced this pull request

Mar 26, 2015
Calling this.unref() during the callback of SetTimeout caused the
callback to get executed twice because unref() didn't expect to be
called during that time and did not stop the ref()ed Timeout but
did start a new timer. This commit prevents the new timer creation
when the callback was already called.

Fixes: #1191
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
PR_URL: #1231

silverwind added a commit that referenced this pull request

Mar 26, 2015
Calling this.unref() during the callback of SetTimeout caused the
callback to get executed twice because unref() didn't expect to be
called during that time and did not stop the ref()ed Timeout but
did start a new timer. This commit prevents the new timer creation
when the callback was already called.

Fixes: #1191
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
PR-URL: #1231

rvagg added a commit that referenced this pull request

Mar 31, 2015
Notable changes:

 * fs: corruption can be caused by fs.writeFileSync() and append-mode
   fs.writeFile() and fs.writeFileSync() under certain circumstances,
   reported in #1058, fixed in #1063 (Olov Lassus).
 * iojs: an "internal modules" API has been introduced to allow core
   code to share JavaScript modules internally only without having to
   expose them as a public API, this feature is for core-only #848
   (Vladimir Kurchatkin).
 * timers: two minor problems with timers have been fixed:
   - Timer#close() is now properly idempotent #1288 (Petka Antonov).
   - setTimeout() will only run the callback once now after an
     unref() during the callback #1231 (Roman Reiss).
 * Windows: a "delay-load hook" has been added for compiled add-ons
   on Windows that should alleviate some of the problems that Windows
   users may be experiencing with add-ons in io.js #1251
   (Bert Belder).
 * V8: minor bug-fix upgrade for V8 to 4.1.0.27.
 * npm: upgrade npm to 2.7.4. See npm CHANGELOG.md for details.