Browse Source

[net2] toRead() for non-linux (SIOCINQ -> FIONREAD)

v0.7.4-release
David Sklar 15 years ago
committed by Ryan Dahl
parent
commit
de9bfdea8e
  1. 1
      lib/net.js
  2. 10
      src/node_net2.cc

1
lib/net.js

@ -109,7 +109,6 @@ Socket.prototype._allocateNewRecvBuf = function () {
var newBufferSize = 1024; // TODO make this adjustable from user API
if (toRead) {
// Note: only Linux supports toRead().
// Is the extra system call even worth it?
var bytesToRead = toRead(self.fd);
if (bytesToRead > 1024) {

10
src/node_net2.cc

@ -18,8 +18,14 @@
#include <netinet/tcp.h>
#include <sys/ioctl.h>
#include <linux/sockios.h>
#ifdef __linux__
# include <linux/sockios.h> /* For the SIOCINQ / FIONREAD ioctl */
#endif
/* Non-linux platforms like OS X define this ioctl elsewhere */
#ifndef FIONREAD
#include <sys/filio.h>
#endif
#include <errno.h>
@ -530,7 +536,7 @@ static Handle<Value> ToRead(const Arguments& args) {
FD_ARG(args[0])
int value;
int r = ioctl(fd, SIOCINQ, &value);
int r = ioctl(fd, FIONREAD, &value);
if (r < 0) {
return ThrowException(ErrnoException(errno, "ioctl"));

Loading…
Cancel
Save