summaryrefslogtreecommitdiff
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* module: fix styleRoman Reiss2015-04-171-2/+2
| | | | | | | This makes the linter happy again. PR-URL: https://github.com/iojs/io.js/pull/1453 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
* http: logically respect maxSocketsfengmk22015-04-171-1/+1
| | | | | | | | | | Allows the number of pooled free sockets to equal maxSockets. Previously it would only allow maxSockets - 1. PR-URL: https://github.com/iojs/io.js/pull/1242 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Christian Tellnes <christian@tellnes.no>
* net: add fd into listen2 debug infoJackson Tian2015-04-171-1/+1
| | | | | | | | | Add fd into debug message. PR-URL: https://github.com/iojs/io.js/pull/1442 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Roman Reiss <me@silverwind.io>
* stream: remove duplicated expressionYazhong Liu2015-04-161-3/+3
| | | | | | | PR-URL: https://github.com/iojs/io.js/pull/1444 Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
* module: handle NODE_PATH in require('.')Roman Reiss2015-04-171-1/+19
| | | | | | | | | | | | | This commit restores the functionality of adding a module's path to NODE_PATH and requiring it with require('.'). As NODE_PATH was never intended to be used as a pointer to a module directory (but instead, to a directory containing directories of modules), this feature is also being deprecated in turn, to be removed at a later point in time. PR-URL: https://github.com/iojs/io.js/pull/1363 Fixes: https://github.com/iojs/io.js/issues/1356 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Rod Vagg <rod@vagg.org>
* buffer: fast-case for empty string in byteLengthJackson Tian2015-04-161-0/+3
| | | | | | | | | When the string is empty, calling the binding is unnecessary and slow. PR-URL: https://github.com/iojs/io.js/pull/1441 Reviewed-by: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Christian Tellnes <christian@tellnes.no>
* node: allow multiple arguments passed to nextTickTrevor Norris2015-04-1514-144/+172
| | | | | PR-URL: https://github.com/iojs/io.js/pull/1077 Reviewed-by: Colin Ihrig <cjihrig@gmail.com>
* readline: fix calling constructor without newAlex Kocharin2015-04-101-1/+4
| | | | | | | | | Previously, we detected options object based on amount of arguments supplied. But if we're calling readline without new operator, constructor gets re-called and will always have 4 arguments. PR-URL: https://github.com/iojs/io.js/pull/1385 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
* lib: reduce process.binding() callsBrendan Ashworth2015-04-098-102/+36
| | | | | | | | | | | | This commit better handles calls to process.binding() in lib/ by no longer lazy loading the bindings (the load times themselves are rather miniscule compared to the load time of V8) and never reloading the bindings (which is 172 times slower than referencing a variable with the same value). PR-URL: https://github.com/iojs/io.js/pull/1367 Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
* zlib: make constants keep readonlyJackson Tian2015-04-071-4/+12
| | | | | | | | | | | | In zlib module, a dozen constants were exported to user land, If user change the constant, maybe lead unexcepted error. Make them readonly and freezon. PR-URL: https://github.com/iojs/io.js/pull/1361 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Johan Bergström <bugs@bergstroem.nu> Reviewed-By: Shigeki Ohtsu <ohtsu@iij.ad.jp>
* url: fix resolving from non-file to file URLs.Jeffrey Jagoda2015-04-041-1/+3
| | | | | | | | | | | | | | | When resolving a reference URL with the 'file' scheme an no host against a base URL without the 'file' scheme, the first path element of the reference URL is used as the host for the target URL. This results in an invalid target URL. This change makes an exception for file URLs so that the host is not mangled during URL resolution. PR-URL: https://github.com/iojs/io.js/pull/1277 Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Petka Antonov <petka_antonov@hotmail.com>
* timers: remove redundant codeFedor Indutny2015-04-041-9/+2
| | | | | PR-URL: https://github.com/iojs/io.js/pull/1330 Reviewed-by: Trevor Norris <trev.norris@gmail.com>
* timers: do not restart the interval after closeFedor Indutny2015-04-041-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | Partially revert 776b73b24306bac0ce299df4f90b7645d5efca31. Following code crashes after backported timer leak fixes: ```javascript var timer = setInterval(function() { clearInterval(timer); }, 10); timer.unref(); ``` Note that this is actually tested in a `test-timers-unref.js`, and is crashing only with 776b73b24306bac0ce299df4f90b7645d5efca31. Calling `clearInterval` leads to the crashes in case of `.unref()`ed timers, and might lead to a extra timer spin in case of regular intervals that was closed during the interval callback. All of these happens because `.unref()`ed timer has it's own `_handle` and was used after the `.close()`. PR-URL: https://github.com/iojs/io.js/pull/1330 Reviewed-by: Trevor Norris <trev.norris@gmail.com>
* timers: don't close interval timers when unrefdJulien Gilli2015-04-041-1/+1
| | | | | | | | | | | This change fixes a regression introduced by commit 0d051238be2e07e671d7d9f4f444e0cc1efadf1b, which contained a typo that would cause every unrefd interval to fire only once. Fixes: https://github.com/joyent/node/issues/8900 Reviewed-By: Timothy J Fontaine <tjfontaine@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-by: Trevor Norris <trev.norris@gmail.com>
* timers: fix unref() memory leakTrevor Norris2015-04-041-1/+10
| | | | | | | | | The destructor isn't being called for timers that have been unref'd. Fixes: https://github.com/joyent/node/issues/8364 PR-URL: https://github.com/iojs/io.js/pull/1330 Reviewed-By: Fedor Indutny <fedor@indutny.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
* lib: remove unused variablesBrian White2015-03-312-6/+6
| | | | | PR-URL: https://github.com/iojs/io.js/pull/1290 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
* streams: use strict on _stream_wrapBrendan Ashworth2015-03-281-0/+2
| | | | | | | | | | A Mostly Harmless™ change to enable 'use strict' mode in _stream_wrap, bringing it in line with /all/ the other modules. PR-URL: https://github.com/iojs/io.js/pull/1279 Reviewed-By: Brian White (@mscdex) <mscdex@mscdex.net> Reviewed-By: Roman Reiss (@silverwind) <me@silverwind.io> Reviewed-By: Yosuke Furukawa (@yosuke-furukawa) <yosuke.furukawa@gmail.com>
* debugger: don't spawn child process in remote modeJackson Tian2015-03-271-20/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When debug in remote mode with host:port or pid, the interface spawn child process also. If the debugger agent is running, will get following output: ``` < Error: listen EADDRINUSE :::5858 < at Object.exports._errnoException (util.js:734:11) < at exports._exceptionWithHostPort (util.js:757:20) < at Agent.Server._listen2 (net.js:1155:14) < at listen (net.js:1181:10) < at Agent.Server.listen (net.js:1268:5) < at Object.start (_debug_agent.js:21:9) < at startup (node.js:68:9) < at node.js:799:3 ``` This fix won't spawn child process and no more error message was shown. When use `iojs debug`, the tip information just like this: ``` Usage: iojs debug script.js ``` This fix will display the advance usage also: ``` Usage: iojs debug script.js iojs debug <host>:<port> iojs debug -p <pid> ``` Fixes: https://github.com/iojs/io.js/issues/889 PR-URL: https://github.com/iojs/io.js/pull/1282 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
* timers: cleanup interval handlingJeremiah Senkpiel2015-03-261-4/+2
| | | | | | | | | Uses `null` as the false-y value for `_repeat` as like other properties. Removes un-reachable statement in setInterval’s `wrapper()`. PR-URL: https://github.com/iojs/io.js/pull/1272 Reviewed-by: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
* timers: assure setTimeout callback only runs onceRoman Reiss2015-03-261-0/+7
| | | | | | | | | | | | | 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: https://github.com/iojs/io.js/issues/1191 Reviewed-by: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> PR-URL: https://github.com/iojs/io.js/pull/1231
* iojs: introduce internal modulesVladimir Kurchatkin2015-03-254-28/+29
| | | | | | | | | | Internal modules can be used to share private code between public modules without risk to expose private APIs to the user. PR-URL: https://github.com/iojs/io.js/pull/848 Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
* string_decoder: optimize write()Brian White2015-03-251-37/+68
| | | | | | | | | | | By limiting property getting/setting to only where they are absolutely necessary, we can achieve greater performance especially with small utf8 inputs and any size base64 inputs. PR-URL: https://github.com/iojs/io.js/pull/1209 Reviewed-By: Rod Vagg <rod@vagg.org> Reviewed-By: Nicu Micleușanu <micnic90@gmail.com> Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
* fs: fix corruption in writeFile and writeFileSyncOlov Lassus2015-03-241-5/+11
| | | | | | | | | | | | | | | | | | 1. writeFileSync bumps position incorrectly, causing it to drift in iteration three and onwards. 2. Append mode files will get corrupted in the middle if writeFile or writeFileSync iterates multiple times, unless running on Linux. position starts out as null so first write is OK, but then position will refer to a location inside an existing file, corrupting that data. Linux ignores position for append mode files so it doesn't happen there. This commit fixes these two related issues by bumping position correctly and by always using null as the position argument to write/writeSync for append mode files. PR-URL: https://github.com/iojs/io.js/pull/1063 Reviewed-By: Bert Belder <bertbelder@gmail.com>
* lib: add missing `new` for errors lib/*.jsMayhem2015-03-246-10/+11
| | | | | | | | | | Not including `new` adds a useless frame and removes a potentially useful frame. PR-URL: https://github.com/iojs/io.js/pull/1246 Reviewed-By: Petka Antonov <petka_antonov@hotmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Brendan Ashworth <brendan.ashworth@me.com>
* assert: simplify logic of testing buffer equalityAlex Yursha2015-03-231-7/+2
| | | | | | | | Delegate buffer equality check to `buffer.equals()` PR-URL: https://github.com/iojs/io.js/pull/1171 Reviewed-By: Brendan Ashworth <brendan.ashworth@me.com> Reviewed-By: Christian Vaagland Tellnes <christian@tellnes.com>
* util: Check input to util.inheritsConnor Peet2015-03-221-0/+15
| | | | | | PR-URL: https://github.com/iojs/io.js/pull/1240 Reviewed-By: Brendan Ashworth <brendan.ashworth@me.com> Reviewed-By: Petka Antonov <petka_antonov@hotmail.com>
* lib: don't penalize setInterval() common caseBen Noordhuis2015-03-201-30/+28
| | | | | | | | | | The common case is where setInterval() is called with two arguments, the callback and the timeout. Specifying optional arguments in the parameter list forces common case calls to go through an arguments adaptor stack frame. PR-URL: https://github.com/iojs/io.js/pull/1221 Reviewed-By: Trevor Norris <trev.norris@gmail.com>
* lib: don't penalize setTimeout() common caseBen Noordhuis2015-03-201-23/+13
| | | | | | | | | | The common case is where setTimeout() is called with two arguments, the callback and the timeout. Specifying optional arguments in the parameter list forces common case calls to go through an arguments adaptor stack frame. PR-URL: https://github.com/iojs/io.js/pull/1221 Reviewed-By: Trevor Norris <trev.norris@gmail.com>
* module: allow require('.')Michaël Zasso2015-03-201-1/+1
| | | | | | | | | | | Previously, the minimal argument to require the current directory was require('./'). This commits allows to skip the trailing slash. Fixes: https://github.com/iojs/io.js/issues/1178 PR-URL: https://github.com/iojs/io.js/pull/1185 Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com> Reviewed-By: Christian Tellnes <christian@tellnes.no> Reviewed-By: Roman Reiss <me@silverwind.io>
* querystring: fix broken stringifyPrimitiveJeremiah Senkpiel2015-03-191-1/+3
| | | | | | | | | | | stringifyPrimitive has always failed to stringify numbers since its introduction in 422d3c9. This went uncaught due to encodeURIComponent's string coercion. Fixes: https://github.com/iojs/io.js/issues/1208 PR-URL: https://github.com/iojs/io.js/pull/1213 Reviewed-By: Rod Vagg <rod@vagg.org> Reviewed-By: Brian White <mscdex@mscdex.net>
* querystring: parse numbers correctlyJeremiah Senkpiel2015-03-191-0/+3
| | | | | | | | | Fixes a number parsing regression introduced in 85a92a3 Fixes: https://github.com/iojs/io.js/issues/1208 PR-URL: https://github.com/iojs/io.js/pull/1213 Reviewed-By: Rod Vagg <rod@vagg.org> Reviewed-By: Brian White <mscdex@mscdex.net>
* path: reduce type checking on some methodscjihrig2015-03-191-10/+0
| | | | | | | | | | | | a465840313f548b913eb2bd8ea3d26c2ab5dcebb added strict type checking for the methods in the path module. However, dirname(), basename(), and extname() actually had some undocumented uses in the wild. This commit loosens the type checking on those methods. Fixes: https://github.com/iojs/io.js/issues/1215 PR-URL: https://github.com/iojs/io.js/pull/1216 Reviewed-By: Rod Vagg <rod@vagg.org>
* lib: don't error in repl when cwd doesn't existBen Noordhuis2015-03-191-2/+10
| | | | | | | | | | | The current working directory may not exist when the REPL starts up. Don't treat that as an error because it's still possible to do many useful things. This is like the previous commit but for the REPL. Fixes: https://github.com/iojs/io.js/issues/1184 PR-URL: https://github.com/iojs/io.js/pull/1194 Reviewed-By: Johan Bergström <bugs@bergstroem.nu> Reviewed-By: Rod Vagg <rod@vagg.org>
* http: add flushHeaders and deprecate flushYosuke Furukawa2015-03-171-1/+5
| | | | | | | | PR-URL: https://github.com/iojs/io.js/pull/1156 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Christian Tellnes <christian@tellnes.no> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
* net: use cached peername to resolve remote fieldsJames Hartig2015-03-161-3/+4
| | | | | | | | | Allows socket.remote* properties to still be accessed even after the socket is closed. Fixes: https://github.com/joyent/node/issues/9287 PR-URL: https://github.com/joyent/node/pull/9366 Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
* lib: remove broken NODE_MODULE_CONTEXTS featureBen Noordhuis2015-03-161-34/+0
| | | | | | | | | | | This feature has no tests and has been broken for ages, see for example https://github.com/iojs/io.js/pull/1160. Don't bother fixing it, it's pretty much broken by design and there can't be too many users because it's almost undocumented. A quick Google search suggests that it causes more grief than joy to the few that do use it. Remove it. PR-URL: https://github.com/iojs/io.js/pull/1162 Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
* path: add type checking for path inputscjihrig2015-03-161-19/+50
| | | | | | | | | | | | This commit adds type checking of path inputs to exported methods in the path module. The exception is _makeLong(), which seems to explicitly support any data type. Fixes: https://github.com/iojs/io.js/issues/1139 PR-URL: https://github.com/iojs/io.js/pull/1153 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Brendan Ashworth <brendan.ashworth@me.com>
* querystring: optimize parse and stringifyBrian White2015-03-151-35/+90
| | | | | | | | | | | | | | | | | | | | parse optimizations: * Move try-catch to separate function to keep entire function from being deoptimized. * Use key array lookup instead of using hasOwnProperty. * Avoid decoding known empty strings. * Avoid possibly unnecessary switch to slower decoder for values if key decoding throws. stringify optimizations: * Use manual loop for default encoder instead of encodeURIComponent. * Use string concatenation instead of joining an array of strings. * Avoid caching result of typeof. PR-URL: https://github.com/iojs/io.js/pull/847 Reviewed-By: Trevor Norris <trev.norris@gmail.com>
* fs: use stat.st_size only to read regular filesSantiago Gimeno2015-03-121-2/+4
| | | | | | | | Using st_size to read non-regular files can lead to not reading all the data. PR-URL: https://github.com/iojs/io.js/pull/1074 Reviewed-By: Bert Belder <bertbelder@gmail.com>
* buffer: align chunks on 8-byte boundaryFedor Indutny2015-03-111-0/+6
| | | | | | | | | | | | | When slicing global pool - ensure that the underlying buffer's data ptr is 8-byte alignment to do not ruin expectations of 3rd party C++ addons. NOTE: 0.10 node.js always returned aligned pointers and io.js should do this too for compatibility. PR-URL: https://github.com/iojs/io.js/pull/1126 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-by: Bert Belder <bertbelder@gmail.com>
* https: don't overwrite servername optionskenqbx2015-03-101-5/+7
| | | | | | PR-URL: https://github.com/iojs/io.js/pull/1110 Reviewed-By: Fedor Indutny <fedor@indutny.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
* lib: allow server.listen({ port: "1234" })Ben Noordhuis2015-03-101-13/+25
| | | | | | | | | | net.connect() accepts `{ port: "1234" }` (i.e. a string) as of commit 9d2b89d06 ("net: allow port 0 in connect()") but net.Server#listen() did not, creating a minor inconsistency. This commit rectifies that. Fixes: https://github.com/iojs/io.js/issues/1111 PR-URL: https://github.com/iojs/io.js/pull/1116 Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
* tls_wrap: proxy handle methods in prototypeFedor Indutny2015-03-091-8/+8
| | | | | | | | | | Set proxied methods wrappers in `TLSWrap` prototype instead of doing it on every socket allocation. Should speed up things a bit and will certainly make heapsnapshot less verbose. PR-URL: https://github.com/iojs/io.js/pull/1108 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
* buffer: Don't assign .parent if none existsTrevor Norris2015-03-091-1/+4
| | | | | | | | | The .parent property of the allocated buffer should remain undefined in the case that it's not a slice. Also included test to verify this. PR-URL: https://github.com/iojs/io.js/pull/1109 Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com> Reviewed-By: Fedor Indutny <fedor@indutny.com>
* http_client: ensure empty socket on errorFedor Indutny2015-03-091-1/+8
| | | | | | | | | | | | | | | | | | | Read all pending data out of the socket on `error` event and ensure that no `data`/`end` handlers will be invoked on `socket.destroy()`. Otherwise following assertion happens: AssertionError: null == true at TLSSocket.socketOnData (_http_client.js:308:3) at TLSSocket.emit (events.js:107:17) at TLSSocket.Readable.read (_stream_readable.js:373:10) at TLSSocket.socketCloseListener (_http_client.js:229:10) at TLSSocket.emit (events.js:129:20) at TCP.close (net.js:476:12) Fix: https://github.com/joyent/node/issues/9348 PR-URL: https://github.com/iojs/io.js/pull/1103 Reviewed-By: Rod Vagg <rod@vagg.org> Reviewed-By: Nicu Micleușanu <micnic90@gmail.com>
* fs: fix .write() not coercing non-string valuesJeremiah Senkpiel2015-03-081-1/+1
| | | | | | Fixes: https://github.com/iojs/io.js/issues/1098 PR-URL: https://github.com/iojs/io.js/pull/1102 Reviewed-By: Brendan Ashworth <brendan.ashworth@me.com>
* url: remove redundant assignment in url.parseAlex Kocharin2015-03-081-1/+0
| | | | | | PR-URL: https://github.com/iojs/io.js/pull/1095 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Nicu Micleușanu <micnic90@gmail.com>
* tls_wrap: do not hold persistent ref to parentFedor Indutny2015-03-061-0/+1
| | | | | | | Hold non-persistent reference in JS, rather than in C++ to avoid cycles. PR-URL: https://github.com/iojs/io.js/pull/1078 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
* http: send Content-Length when possibleChristian Tellnes2015-03-051-6/+29
| | | | | | | | | | | | This changes the behavior for http to send send a Content-Length header instead of using chunked encoding when we know the size of the body when sending the headers. Fixes: https://github.com/iojs/io.js/issues/1044 PR-URL: https://github.com/iojs/io.js/pull/1062 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Rod Vagg <rod@vagg.org> Reviewed-By: Brian White <mscdex@mscdex.net>
* lib: avoid .toLowerCase() call in Buffer#write()Ben Noordhuis2015-03-051-31/+29
| | | | | | | | | | | Avoid a costly String#toLowerCase() call in Buffer#write() in the common case, i.e., that the string is already lowercase. Reduces the running time of the following benchmark by about 40%: for (var b = Buffer(1), i = 0; i < 25e6; ++i) b.write('x', 'ucs2'); PR-URL: https://github.com/iojs/io.js/pull/1048 Reviewed-By: Trevor Norris <trev.norris@gmail.com>