Browse Source

Merge remote-tracking branch 'ry/v0.6' into master

Conflicts:
	AUTHORS
	ChangeLog
	LICENSE
	Makefile
	deps/http_parser/test.c
	deps/npm/AUTHORS
	deps/npm/html/api/bin.html
	deps/npm/html/api/bugs.html
	deps/npm/html/api/commands.html
	deps/npm/html/api/config.html
	deps/npm/html/api/deprecate.html
	deps/npm/html/api/docs.html
	deps/npm/html/api/edit.html
	deps/npm/html/api/explore.html
	deps/npm/html/api/help-search.html
	deps/npm/html/api/init.html
	deps/npm/html/api/install.html
	deps/npm/html/api/link.html
	deps/npm/html/api/load.html
	deps/npm/html/api/ls.html
	deps/npm/html/api/npm.html
	deps/npm/html/api/outdated.html
	deps/npm/html/api/owner.html
	deps/npm/html/api/pack.html
	deps/npm/html/api/prefix.html
	deps/npm/html/api/prune.html
	deps/npm/html/api/publish.html
	deps/npm/html/api/rebuild.html
	deps/npm/html/api/restart.html
	deps/npm/html/api/root.html
	deps/npm/html/api/run-script.html
	deps/npm/html/api/search.html
	deps/npm/html/api/shrinkwrap.html
	deps/npm/html/api/start.html
	deps/npm/html/api/stop.html
	deps/npm/html/api/submodule.html
	deps/npm/html/api/tag.html
	deps/npm/html/api/test.html
	deps/npm/html/api/uninstall.html
	deps/npm/html/api/unpublish.html
	deps/npm/html/api/update.html
	deps/npm/html/api/version.html
	deps/npm/html/api/view.html
	deps/npm/html/api/whoami.html
	deps/npm/html/doc/README.html
	deps/npm/html/doc/adduser.html
	deps/npm/html/doc/bin.html
	deps/npm/html/doc/bugs.html
	deps/npm/html/doc/build.html
	deps/npm/html/doc/bundle.html
	deps/npm/html/doc/cache.html
	deps/npm/html/doc/changelog.html
	deps/npm/html/doc/coding-style.html
	deps/npm/html/doc/completion.html
	deps/npm/html/doc/config.html
	deps/npm/html/doc/deprecate.html
	deps/npm/html/doc/developers.html
	deps/npm/html/doc/disputes.html
	deps/npm/html/doc/docs.html
	deps/npm/html/doc/edit.html
	deps/npm/html/doc/explore.html
	deps/npm/html/doc/faq.html
	deps/npm/html/doc/folders.html
	deps/npm/html/doc/help-search.html
	deps/npm/html/doc/help.html
	deps/npm/html/doc/index.html
	deps/npm/html/doc/init.html
	deps/npm/html/doc/install.html
	deps/npm/html/doc/json.html
	deps/npm/html/doc/link.html
	deps/npm/html/doc/list.html
	deps/npm/html/doc/npm.html
	deps/npm/html/doc/outdated.html
	deps/npm/html/doc/owner.html
	deps/npm/html/doc/pack.html
	deps/npm/html/doc/prefix.html
	deps/npm/html/doc/prune.html
	deps/npm/html/doc/publish.html
	deps/npm/html/doc/rebuild.html
	deps/npm/html/doc/registry.html
	deps/npm/html/doc/removing-npm.html
	deps/npm/html/doc/restart.html
	deps/npm/html/doc/root.html
	deps/npm/html/doc/run-script.html
	deps/npm/html/doc/scripts.html
	deps/npm/html/doc/search.html
	deps/npm/html/doc/semver.html
	deps/npm/html/doc/shrinkwrap.html
	deps/npm/html/doc/star.html
	deps/npm/html/doc/start.html
	deps/npm/html/doc/stop.html
	deps/npm/html/doc/submodule.html
	deps/npm/html/doc/tag.html
	deps/npm/html/doc/test.html
	deps/npm/html/doc/uninstall.html
	deps/npm/html/doc/unpublish.html
	deps/npm/html/doc/update.html
	deps/npm/html/doc/version.html
	deps/npm/html/doc/view.html
	deps/npm/html/doc/whoami.html
	deps/npm/lib/npm.js
	deps/npm/man/man1/npm.1
	deps/npm/man/man3/npm.3
	deps/npm/node_modules/fstream-npm/fstream-npm.js
	deps/npm/node_modules/fstream-npm/node_modules/fstream-ignore/package.json
	deps/npm/node_modules/fstream-npm/package.json
	deps/npm/node_modules/node-gyp/LICENSE
	deps/npm/node_modules/node-gyp/lib/build.js
	deps/npm/node_modules/node-gyp/lib/install.js
	deps/npm/node_modules/node-gyp/node_modules/ansi/package.json
	deps/npm/node_modules/node-gyp/node_modules/glob/package.json
	deps/npm/node_modules/node-gyp/package.json
	deps/npm/package.json
	deps/uv/test/test-fs.c
	deps/v8/src/regexp-macro-assembler-tracer.cc
	deps/v8/src/version.cc
	src/node_version.h
	src/platform_sunos.cc
	test/simple/test-net-write-after-close.js
	wscript
v0.9.1-release
isaacs 13 years ago
parent
commit
ecca7525cc
  1. 1
      AUTHORS
  2. 46
      ChangeLog
  3. 7
      LICENSE
  4. 7
      Makefile
  5. 1031
      deps/http_parser/test.c
  6. 64
      deps/uv/test/test-fs.c
  7. 8
      doc/community/index.html
  8. BIN
      doc/images/linkedin-logo.png
  9. BIN
      doc/images/microsoft-logo.png
  10. BIN
      doc/images/yahoo-logo.png
  11. 11
      doc/pipe.css
  12. 12
      lib/fs.js
  13. 62
      lib/net.js
  14. 8
      src/node.h
  15. 5
      src/node_crypto.cc
  16. 92
      src/node_file.cc
  17. 4
      src/v8_typed_array.cc
  18. 2
      test/simple/test-fs-largefile.js
  19. 48
      test/simple/test-fs-readfile-unlink.js
  20. 46
      test/simple/test-http-no-content-length.js
  21. 37
      test/simple/test-memory-usage-emfile.js
  22. 13
      test/simple/test-net-write-after-close.js

1
AUTHORS

@ -300,3 +300,4 @@ Aaron Jacobs <jacobsa@google.com>
Mustansir Golawala <mgolawala@gmail.com>
fukayatsu <fukayatsu@gmail.com>
Domenic Denicola <domenic@domenicdenicola.com>
Bryan Cantrill <bryan@joyent.com>

46
ChangeLog

@ -255,6 +255,52 @@
* Bug fixes
2012.04.09 Version 0.6.15 (stable)
* Update npm to 1.1.16
* Show licenses in binary installers.
* unix: add uv_fs_read64, uv_fs_write64 and uv_fs_ftruncate64 (Ben Noordhuis)
* add 64bit offset fs functions (Igor Zinkovsky)
* windows: don't report ENOTSOCK when attempting to bind an udp handle twice (Bert Belder)
* windows: backport pipe-connect-to-file fixes from master (Bert Belder)
* windows: never call fs event callbacks after closing the watcher (Bert Belder)
* fs.readFile: don't make the callback before the fd is closed (Bert Belder)
* windows: use 64bit offsets for uv_fs apis (Igor Zinkovsky)
* Fix #2061: segmentation fault on OS X due to stat size mismatch (Ben Noordhuis)
2012.03.22 Version 0.6.14 (stable), e513ffef7549a56a5af728e1f0c2c0c8f290518a
* net: don't crash when queued write fails (Igor Zinkovsky)
* sunos: fix EMFILE on process.memoryUsage() (Bryan Cantrill)
* crypto: fix compile-time error with openssl 0.9.7e (Ben Noordhuis)
* unix: ignore ECONNABORTED errors from accept() (Ben Noordhuis)
* Add UV_ENOSPC and mappings to it (Bert Belder)
* http-parser: Fix response body is not read (koichik)
* Upgrade npm to 1.1.12
- upgrade node-gyp to 0.3.7
- work around AV-locked directories on Windows
- Fix isaacs/npm#2293 Don't try to 'uninstall' /
- Exclude symbolic links from packages.
- Fix isaacs/npm#2275 Spurious 'unresolvable cycle' error.
- Exclude/include dot files as if they were normal files
2012.03.15 Version 0.6.13 (stable), 9f7f86b534f8556290eb8cad915984ff4ca54996
* Windows: Many libuv test fixes (Bert Belder)

7
LICENSE

@ -361,13 +361,6 @@ maintained libraries. The externally maintained libraries used by Node are:
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# Here are some issues that I've had people identify in my code during reviews,
# that I think are possible to flag automatically in a lint tool. If these were
# caught by lint, it would save time both for myself and that of my reviewers.
# Most likely, some of these are beyond the scope of the current lint framework,
# but I think it is valuable to retain these wish-list items even if they cannot
# be immediately implemented.
"""
- lib/buffer_ieee754.js. Its license follows:

7
Makefile

@ -150,6 +150,13 @@ blog.html: email.md
website-upload: doc
rsync -r out/doc/ node@nodejs.org:~/web/nodejs.org/
ssh node@nodejs.org '\
rm -f ~/web/nodejs.org/dist/latest &&\
ln -s $(VERSION) ~/web/nodejs.org/dist/latest &&\
rm -f ~/web/nodejs.org/docs/latest &&\
ln -s $(VERSION) ~/web/nodejs.org/docs/latest &&\
rm -f ~/web/nodejs.org/dist/node-latest.tar.gz &&\
ln -s $(VERSION)/node-$(VERSION).tar.gz ~/web/nodejs.org/dist/node-latest.tar.gz'
docopen: out/doc/api/all.html
-google-chrome out/doc/api/all.html

1031
deps/http_parser/test.c

File diff suppressed because it is too large

64
deps/uv/test/test-fs.c

@ -225,7 +225,6 @@ static void close_cb(uv_fs_t* req) {
uv_fs_req_cleanup(req);
if (close_cb_count == 3) {
r = uv_fs_unlink(loop, &unlink_req, "test_file2", unlink_cb);
ASSERT(r == 0);
}
}
@ -238,7 +237,6 @@ static void ftruncate_cb(uv_fs_t* req) {
ftruncate_cb_count++;
uv_fs_req_cleanup(req);
r = uv_fs_close(loop, &close_req, open_req1.result, close_cb);
ASSERT(r == 0);
}
@ -257,7 +255,6 @@ static void read_cb(uv_fs_t* req) {
ASSERT(strcmp(buf, "test-bu") == 0);
r = uv_fs_close(loop, &close_req, open_req1.result, close_cb);
}
ASSERT(r == 0);
}
@ -277,7 +274,6 @@ static void open_cb(uv_fs_t* req) {
memset(buf, 0, sizeof(buf));
r = uv_fs_read(loop, &read_req, open_req1.result, buf, sizeof(buf), -1,
read_cb);
ASSERT(r == 0);
}
@ -302,7 +298,6 @@ static void fsync_cb(uv_fs_t* req) {
fsync_cb_count++;
uv_fs_req_cleanup(req);
r = uv_fs_close(loop, &close_req, open_req1.result, close_cb);
ASSERT(r == 0);
}
@ -314,7 +309,6 @@ static void fdatasync_cb(uv_fs_t* req) {
fdatasync_cb_count++;
uv_fs_req_cleanup(req);
r = uv_fs_fsync(loop, &fsync_req, open_req1.result, fsync_cb);
ASSERT(r == 0);
}
@ -326,7 +320,6 @@ static void write_cb(uv_fs_t* req) {
write_cb_count++;
uv_fs_req_cleanup(req);
r = uv_fs_fdatasync(loop, &fdatasync_req, open_req1.result, fdatasync_cb);
ASSERT(r == 0);
}
@ -339,7 +332,6 @@ static void create_cb(uv_fs_t* req) {
uv_fs_req_cleanup(req);
r = uv_fs_write(loop, &write_req, req->result, test_buf, sizeof(test_buf),
-1, write_cb);
ASSERT(r == 0);
}
@ -1673,59 +1665,3 @@ TEST_IMPL(fs_rename_to_existing_file) {
return 0;
}
TEST_IMPL(fs_read_file_eof) {
int r;
/* Setup. */
unlink("test_file");
loop = uv_default_loop();
r = uv_fs_open(loop, &open_req1, "test_file", O_WRONLY | O_CREAT,
S_IWRITE | S_IREAD, NULL);
ASSERT(r != -1);
ASSERT(open_req1.result != -1);
uv_fs_req_cleanup(&open_req1);
r = uv_fs_write(loop, &write_req, open_req1.result, test_buf,
sizeof(test_buf), -1, NULL);
ASSERT(r != -1);
ASSERT(write_req.result != -1);
uv_fs_req_cleanup(&write_req);
r = uv_fs_close(loop, &close_req, open_req1.result, NULL);
ASSERT(r != -1);
ASSERT(close_req.result != -1);
uv_fs_req_cleanup(&close_req);
r = uv_fs_open(loop, &open_req1, "test_file", O_RDONLY, 0, NULL);
ASSERT(r != -1);
ASSERT(open_req1.result != -1);
uv_fs_req_cleanup(&open_req1);
memset(buf, 0, sizeof(buf));
r = uv_fs_read(loop, &read_req, open_req1.result, buf, sizeof(buf), -1,
NULL);
ASSERT(r != -1);
ASSERT(read_req.result != -1);
ASSERT(strcmp(buf, test_buf) == 0);
uv_fs_req_cleanup(&read_req);
r = uv_fs_read(loop, &read_req, open_req1.result, buf, sizeof(buf),
read_req.result, NULL);
ASSERT(r == 0);
ASSERT(read_req.result == 0);
uv_fs_req_cleanup(&read_req);
r = uv_fs_close(loop, &close_req, open_req1.result, NULL);
ASSERT(r != -1);
ASSERT(close_req.result != -1);
uv_fs_req_cleanup(&close_req);
/* Cleanup */
unlink("test_file");
return 0;
}

8
doc/community/index.html

@ -142,7 +142,13 @@
<br>
<a href="http://nodejs.hk">HKNoJ</a> Hong Kong community
<br>
<a href="http://nodejs.tw">nodejs.tw</a> Taiwan community</p>
<a href="http://nodejs.tw">nodejs.tw</a> Taiwan community
<br>
<a href="http://nodehispano.com">Node Hispano</a> Spanish language community
<br>
<a href="http://nodejskr.org">OctoberSkyJs</a> Korea Node.js community
</p>
</div>
</div>

BIN
doc/images/linkedin-logo.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
doc/images/microsoft-logo.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
doc/images/yahoo-logo.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

11
doc/pipe.css

@ -150,16 +150,7 @@ h1 a, h2 a, h3 a, h4 a
font-size: 11px;
}
#quotes ul li.ebay {
margin-top: -10px;
}
#quotes ul li.linkedin {
margin-top: -4px;
}
#quotes ul li.yahoo {
margin-top: -4px;
#quotes ul li:last-child {
padding-right: 0;
}

12
lib/fs.js

@ -106,6 +106,7 @@ fs.readFile = function(path, encoding_) {
var readStream = fs.createReadStream(path);
var buffers = [];
var nread = 0;
var error;
readStream.on('data', function(chunk) {
buffers.push(chunk);
@ -113,11 +114,18 @@ fs.readFile = function(path, encoding_) {
});
readStream.on('error', function(er) {
callback(er);
error = er;
readStream.destroy();
if (!readStream.fd) {
readStream.emit('close');
}
});
readStream.on('end', function() {
readStream.on('close', function() {
if (error) {
return callback(error);
}
// copy all the buffers into one
var buffer;
switch (buffers.length) {

62
lib/net.js

@ -114,6 +114,7 @@ function initSocketHandle(self) {
self._flags = 0;
self._connectQueueSize = 0;
self.destroyed = false;
self.errorEmitted = false;
self.bytesRead = 0;
self.bytesWritten = 0;
@ -278,7 +279,7 @@ Socket.prototype.end = function(data, encoding) {
var shutdownReq = this._handle.shutdown();
if (!shutdownReq) {
this.destroy(errnoException(errno, 'shutdown'));
this._destroy(errnoException(errno, 'shutdown'));
return false;
}
@ -301,7 +302,7 @@ function afterShutdown(status, handle, req) {
}
if (self._flags & FLAG_GOT_EOF || !self.readable) {
self.destroy();
self._destroy();
} else {
}
}
@ -312,7 +313,7 @@ Socket.prototype.destroySoon = function() {
this._flags |= FLAG_DESTROY_SOON;
if (this._pendingWriteReqs == 0) {
this.destroy();
this._destroy();
}
};
@ -324,11 +325,24 @@ Socket.prototype._connectQueueCleanUp = function(exception) {
};
Socket.prototype.destroy = function(exception) {
if (this.destroyed) return;
Socket.prototype._destroy = function(exception, cb) {
var self = this;
function fireErrorCallbacks() {
if (cb) cb(exception);
if (exception && !self.errorEmitted) {
process.nextTick(function() {
self.emit('error', exception);
});
self.errorEmitted = true;
}
};
if (this.destroyed) {
fireErrorCallbacks();
return;
}
self._connectQueueCleanUp();
debug('destroy');
@ -349,8 +363,9 @@ Socket.prototype.destroy = function(exception) {
this._handle = null;
}
fireErrorCallbacks();
process.nextTick(function() {
if (exception) self.emit('error', exception);
self.emit('close', exception ? true : false);
});
@ -358,6 +373,11 @@ Socket.prototype.destroy = function(exception) {
};
Socket.prototype.destroy = function(exception) {
this._destroy(exception);
}
function onread(buffer, offset, length) {
var handle = this;
var self = handle.socket;
@ -396,7 +416,7 @@ function onread(buffer, offset, length) {
// We call destroy() before end(). 'close' not emitted until nextTick so
// the 'end' event will come first as required.
if (!self.writable) self.destroy();
if (!self.writable) self._destroy();
if (!self.allowHalfOpen) self.end();
if (self._events && self._events['end']) self.emit('end');
@ -404,9 +424,9 @@ function onread(buffer, offset, length) {
} else {
// Error
if (errno == 'ECONNRESET') {
self.destroy();
self._destroy();
} else {
self.destroy(errnoException(errno, 'read'));
self._destroy(errnoException(errno, 'read'));
}
}
}
@ -484,13 +504,16 @@ Socket.prototype.write = function(data, arg1, arg2) {
Socket.prototype._write = function(data, encoding, cb) {
timers.active(this);
if (!this._handle) throw new Error('This socket is closed.');
if (!this._handle) {
this._destroy(new Error('This socket is closed.'), cb);
return false;
}
// `encoding` is unused right now, `data` is always a buffer.
var writeReq = this._handle.write(data);
if (!writeReq) {
this.destroy(errnoException(errno, 'write'));
this._destroy(errnoException(errno, 'write'), cb);
return false;
}
@ -511,7 +534,7 @@ function afterWrite(status, handle, req, buffer) {
}
if (status) {
self.destroy(errnoException(errno, 'write'));
self._destroy(errnoException(errno, 'write'), req.cb);
return;
}
@ -526,7 +549,7 @@ function afterWrite(status, handle, req, buffer) {
if (req.cb) req.cb();
if (self._pendingWriteReqs == 0 && self._flags & FLAG_DESTROY_SOON) {
self.destroy();
self._destroy();
}
}
@ -563,7 +586,7 @@ function connect(self, address, port, addressType, localAddress) {
if (connectReq !== null) {
connectReq.oncomplete = afterConnect;
} else {
self.destroy(errnoException(errno, 'connect'));
self._destroy(errnoException(errno, 'connect'));
}
}
@ -617,7 +640,7 @@ Socket.prototype.connect = function(options, cb) {
// error event to the next tick.
process.nextTick(function() {
self.emit('error', err);
self.destroy();
self._destroy();
});
} else {
timers.active(self);
@ -662,8 +685,9 @@ function afterConnect(status, handle, req, readable, writable) {
if (self._connectQueue) {
debug('Drain the connect queue');
for (var i = 0; i < self._connectQueue.length; i++) {
self._write.apply(self, self._connectQueue[i]);
var connectQueue = self._connectQueue;
for (var i = 0; i < connectQueue.length; i++) {
self._write.apply(self, connectQueue[i]);
}
self._connectQueueCleanUp();
}
@ -677,7 +701,7 @@ function afterConnect(status, handle, req, readable, writable) {
}
} else {
self._connectQueueCleanUp();
self.destroy(errnoException(errno, 'connect'));
self._destroy(errnoException(errno, 'connect'));
}
}

8
src/node.h

@ -75,6 +75,14 @@
#define NODE_STRINGIFY_HELPER(n) #n
#endif
#ifndef STATIC_ASSERT
#if defined(_MSC_VER)
# define STATIC_ASSERT(expr) static_assert(expr, "")
# else
# define STATIC_ASSERT(expr) static_cast<void>((sizeof(char[-1 + !!(expr)])))
# endif
#endif
namespace node {
int Start(int argc, char *argv[]);

5
src/node_crypto.cc

@ -972,7 +972,10 @@ Handle<Value> Connection::New(const Arguments& args) {
}
void Connection::SSLInfoCallback(const SSL *ssl, int where, int ret) {
void Connection::SSLInfoCallback(const SSL *ssl_, int where, int ret) {
// Be compatible with older versions of OpenSSL. SSL_get_app_data() wants
// a non-const SSL* in OpenSSL <= 0.9.7e.
SSL* ssl = const_cast<SSL*>(ssl_);
if (where & SSL_CB_HANDSHAKE_START) {
HandleScope scope;
Connection* c = static_cast<Connection*>(SSL_get_app_data(ssl));

92
src/node_file.cc

@ -39,7 +39,6 @@
# include <io.h>
#endif
namespace node {
using namespace v8;
@ -70,7 +69,38 @@ static Persistent<String> buf_symbol;
static Persistent<String> oncomplete_sym;
#ifdef _LARGEFILE_SOURCE
#ifndef _LARGEFILE_SOURCE
typedef off_t node_off_t;
# define ASSERT_OFFSET(a) \
STATIC_ASSERT(sizeof(node_off_t) * CHAR_BIT >= 32); \
if (!(a)->IsUndefined() && !(a)->IsNull() && !(a)->IsInt32()) { \
return ThrowException(Exception::TypeError(String::New("Not an integer"))); \
}
# define ASSERT_TRUNCATE_LENGTH(a) \
if (!(a)->IsUndefined() && !(a)->IsNull() && !(a)->IsUint32()) { \
return ThrowException(Exception::TypeError(String::New("Not an integer"))); \
}
# define GET_OFFSET(a) ((a)->IsNumber() ? (a)->Int32Value() : -1)
# define GET_TRUNCATE_LENGTH(a) ((a)->Uint32Value())
#else
# ifdef _WIN32
# define NODE_USE_64BIT_UV_FS_API
typedef int64_t node_off_t;
# else
typedef off_t node_off_t;
# endif
# define ASSERT_OFFSET(a) \
STATIC_ASSERT(sizeof(node_off_t) * CHAR_BIT >= 64); \
if (!(a)->IsUndefined() && !(a)->IsNull() && !IsInt64((a)->NumberValue())) { \
return ThrowException(Exception::TypeError(String::New("Not an integer"))); \
}
# define ASSERT_TRUNCATE_LENGTH(a) \
if (!(a)->IsUndefined() && !(a)->IsNull() && !IsInt64((a)->NumberValue())) { \
return ThrowException(Exception::TypeError(String::New("Not an integer"))); \
}
# define GET_OFFSET(a) ((a)->IsNumber() ? (a)->IntegerValue() : -1)
# define GET_TRUNCATE_LENGTH(a) ((a)->IntegerValue())
static inline int IsInt64(double x) {
return x == static_cast<double>(static_cast<int64_t>(x));
}
@ -475,20 +505,6 @@ static Handle<Value> Rename(const Arguments& args) {
}
}
#ifndef _LARGEFILE_SOURCE
#define ASSERT_TRUNCATE_LENGTH(a) \
if (!(a)->IsUndefined() && !(a)->IsNull() && !(a)->IsUint32()) { \
return ThrowException(Exception::TypeError(String::New("Not an integer"))); \
}
#define GET_TRUNCATE_LENGTH(a) ((a)->Uint32Value())
#else
#define ASSERT_TRUNCATE_LENGTH(a) \
if (!(a)->IsUndefined() && !(a)->IsNull() && !IsInt64((a)->NumberValue())) { \
return ThrowException(Exception::TypeError(String::New("Not an integer"))); \
}
#define GET_TRUNCATE_LENGTH(a) ((a)->IntegerValue())
#endif
static Handle<Value> Truncate(const Arguments& args) {
HandleScope scope;
@ -499,12 +515,20 @@ static Handle<Value> Truncate(const Arguments& args) {
int fd = args[0]->Int32Value();
ASSERT_TRUNCATE_LENGTH(args[1]);
off_t len = GET_TRUNCATE_LENGTH(args[1]);
node_off_t len = GET_TRUNCATE_LENGTH(args[1]);
if (args[2]->IsFunction()) {
#ifdef NODE_USE_64BIT_UV_FS_API
ASYNC_CALL(ftruncate64, args[2], fd, len)
#else
ASYNC_CALL(ftruncate, args[2], fd, len)
#endif
} else {
#ifdef NODE_USE_64BIT_UV_FS_API
SYNC_CALL(ftruncate64, 0, fd, len)
#else
SYNC_CALL(ftruncate, 0, fd, len)
#endif
return Undefined();
}
}
@ -674,20 +698,6 @@ static Handle<Value> Open(const Arguments& args) {
}
}
#ifndef _LARGEFILE_SOURCE
#define ASSERT_OFFSET(a) \
if (!(a)->IsUndefined() && !(a)->IsNull() && !(a)->IsInt32()) { \
return ThrowException(Exception::TypeError(String::New("Not an integer"))); \
}
#define GET_OFFSET(a) ((a)->IsNumber() ? (a)->Int32Value() : -1)
#else
#define ASSERT_OFFSET(a) \
if (!(a)->IsUndefined() && !(a)->IsNull() && !IsInt64((a)->NumberValue())) { \
return ThrowException(Exception::TypeError(String::New("Not an integer"))); \
}
#define GET_OFFSET(a) ((a)->IsNumber() ? (a)->IntegerValue() : -1)
#endif
// bytesWritten = write(fd, data, position, enc, callback)
// Wrapper for write(2).
//
@ -728,15 +738,23 @@ static Handle<Value> Write(const Arguments& args) {
}
ASSERT_OFFSET(args[4]);
off_t pos = GET_OFFSET(args[4]);
node_off_t pos = GET_OFFSET(args[4]);
char * buf = (char*)buffer_data + off;
Local<Value> cb = args[5];
if (cb->IsFunction()) {
#ifdef NODE_USE_64BIT_UV_FS_API
ASYNC_CALL(write64, cb, fd, buf, len, pos)
#else
ASYNC_CALL(write, cb, fd, buf, len, pos)
#endif
} else {
#ifdef NODE_USE_64BIT_UV_FS_API
SYNC_CALL(write64, 0, fd, buf, len, pos)
#else
SYNC_CALL(write, 0, fd, buf, len, pos)
#endif
return scope.Close(Integer::New(SYNC_RESULT));
}
}
@ -765,7 +783,7 @@ static Handle<Value> Read(const Arguments& args) {
Local<Value> cb;
size_t len;
off_t pos;
node_off_t pos;
char * buf = NULL;
@ -797,9 +815,17 @@ static Handle<Value> Read(const Arguments& args) {
cb = args[5];
if (cb->IsFunction()) {
#ifdef NODE_USE_64BIT_UV_FS_API
ASYNC_CALL(read64, cb, fd, buf, len, pos);
#else
ASYNC_CALL(read, cb, fd, buf, len, pos);
#endif
} else {
#ifdef NODE_USE_64BIT_UV_FS_API
SYNC_CALL(read64, 0, fd, buf, len, pos)
#else
SYNC_CALL(read, 0, fd, buf, len, pos)
#endif
Local<Integer> bytesRead = Integer::New(SYNC_RESULT);
return scope.Close(bytesRead);
}

4
src/v8_typed_array.cc

@ -471,6 +471,8 @@ class TypedArray {
case v8::kExternalPixelArray: return "Uint8ClampedArray";
}
abort();
// Please the compiler
return "";
}
};
@ -567,7 +569,7 @@ int valueToCType(v8::Handle<v8::Value> value) {
template <>
float valueToCType(v8::Handle<v8::Value> value) {
return value->NumberValue();
return static_cast<float>(value->NumberValue());
}
template <>

2
test/disabled/test-fs-largefile.js → test/simple/test-fs-largefile.js

@ -53,6 +53,6 @@ assert.ok(exceptionRaised);
fs.close(fd);
process.on('exit', function() {
fs.unlink(filepath);
fs.unlinkSync(filepath);
});

48
test/simple/test-fs-readfile-unlink.js

@ -0,0 +1,48 @@
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
var assert = require('assert'),
common = require('../common'),
fs = require('fs'),
path = require('path'),
dirName = path.resolve(common.fixturesDir, 'test-readfile-unlink'),
fileName = path.resolve(dirName, 'test.bin');
var buf = new Buffer(512 * 1024);
buf.fill(42);
try {
fs.mkdirSync(dirName);
} catch (e) {
// Ignore if the directory already exists.
if (e.code != 'EEXIST') throw e;
}
fs.writeFileSync(fileName, buf);
fs.readFile(fileName, function(err, data) {
assert.ifError(err);
assert(data.length == buf.length);
assert.strictEqual(buf[0], 42);
fs.unlinkSync(fileName);
fs.rmdirSync(dirName);
});

46
test/simple/test-http-no-content-length.js

@ -0,0 +1,46 @@
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
var common = require('../common');
var assert = require('assert');
var net = require('net');
var http = require('http');
var body = '';
var server = net.createServer(function(socket) {
// Neither Content-Length nor Connection
socket.end('HTTP/1.1 200 ok\r\n\r\nHello');
}).listen(common.PORT, function() {
var req = http.get({port: common.PORT}, function(res) {
res.setEncoding('utf8');
res.on('data', function(chunk) {
body += chunk;
});
res.on('end', function() {
server.close();
});
});
});
process.on('exit', function() {
assert.equal(body, 'Hello');
});

37
test/simple/test-memory-usage-emfile.js

@ -0,0 +1,37 @@
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
var common = require('../common');
var assert = require('assert');
var fs = require('fs');
var files = [];
while (files.length < 256)
files.push(fs.openSync(__filename, 'r'));
var r = process.memoryUsage();
console.log(common.inspect(r));
assert.equal(true, r['rss'] > 0);

13
test/simple/test-net-write-after-close.js

@ -24,18 +24,23 @@ var assert = require('assert');
var net = require('net');
var gotError = false;
var gotWriteCB = false;
process.on('exit', function() {
assert(gotError);
assert(gotWriteCB);
});
var server = net.createServer(function(socket) {
setTimeout(function() {
assert.throws(function() {
socket.write('test');
}, /This socket is closed/);
socket.on('error', function(error) {
server.close();
gotError = true;
});
setTimeout(function() {
socket.write('test', function(e) {
gotWriteCB = true;
});
}, 250);
});

Loading…
Cancel
Save