pike.git / src / modules / _Stdio / file.c

version» Context lines:

pike.git/src/modules/_Stdio/file.c:114:   #undef NOERROR   #endif /* NOERROR */      #ifdef HAVE_NETDB_H   #include <netdb.h>   #endif   #ifdef HAVE_NET_NETDB_H   #include <net/netdb.h>   #endif /* HAVE_NET_NETDB_H */    + #ifdef HAVE_NETINET_TCP_H + #include <netinet/tcp.h> + #endif +    #include "dmalloc.h"         #undef THIS   #define THIS ((struct my_file *)(Pike_fp->current_storage))   #define FD (THIS->box.fd)   #define ERRNO (THIS->my_errno)      #define READ_BUFFER 8192   #define DIRECT_BUFSIZE (64*1024)
pike.git/src/modules/_Stdio/file.c:2423: Inside #if defined(SO_LINGER)
   }    if (errno) {    ERRNO = errno;    push_int(0);    } else {    push_int(1);    }   }   #endif    + #ifdef TCP_NODELAY + /*! @decl int(0..1) nodelay(int(0..1)|void state) +  *! +  *! Control Nagle's Algorithm (RFC 896) +  *! +  *! @param state +  *! @int +  *! @value 0 +  *! Return to the normal state of using Nagle's Algorithm +  *! @value 1 +  *! (default) Disable Nagling - small writes will not be queued. +  *! @endint +  *! +  *! @returns +  *! Returns @expr{1@} on success, and @expr{0@} (zero) on failure. +  *! +  *! @note +  *! This operation is only valid on sockets. +  */ + static void file_nodelay(INT32 args) + { +  int fd = FD; +  int state = 1; +  +  if(fd < 0) +  Pike_error("File not open.\n"); +  +  get_all_args("Stdio.File->nodelay", args, ".%d", &state); +  +  if (state && state != 1) { +  SIMPLE_BAD_ARG_ERROR("Stdio.File->nodelay()", 1, "int(0..1)"); +  } +  +  errno = 0; +  while ((fd_setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, +  &state, sizeof(state)) < 0) && +  (errno == EINTR)) { +  errno = 0; +  } +  if (errno) { +  ERRNO = errno; +  push_int(0); +  } else { +  push_int(1); +  } + } + #endif +    static int do_close(int flags)   {    struct my_file *f = THIS;    if(FD == -1) return 1; /* already closed */    ERRNO=0;       flags &= f->open_mode;       switch(flags & (FILE_READ | FILE_WRITE))    {