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

version» Context lines:

pike.git/src/modules/_Stdio/sendfile.c:318:    }    }    }    SF_DFPRINTF((stderr, "sendfile: send_iov(): Sent %d bytes\n",    sent));    return sent;   }      void low_do_sendfile(struct pike_sendfile *this)   { - #if defined(SOL_TCP) && (defined(TCP_CORK) || defined(TCP_NODELAY)) -  int old_val = -1; -  socklen_t old_len = (socklen_t) sizeof(old_val); - #ifdef TCP_CORK -  int new_val = 1; - #else /* !TCP_CORK */ -  int new_val = 0; - #endif /* TCP_CORK */ - #endif /* SOL_TCP && (TCP_CORK || TCP_NODELAY) */ -  +  int oldbulkmode = bulkmode_start(this->to_fd);    /* Make sure we're using blocking I/O */    set_nonblocking(this->to_fd, 0);    - #ifdef SOL_TCP - #ifdef TCP_CORK -  /* Attempt to set the out socket into cork mode. -  * FIXME: Do we need to adjust TCP_NODELAY here? -  */ -  while ((getsockopt(this->to_fd, SOL_TCP, TCP_CORK, -  &old_val, &old_len)<0) && -  (errno == EINTR)) -  ; -  if (!old_val) { -  while ((setsockopt(this->to_fd, SOL_TCP, TCP_CORK, -  &new_val, sizeof(new_val))<0) && -  (errno == EINTR)) -  ; -  } - #elif defined(TCP_NODELAY) -  /* Attempt to set the out socket into nagle mode. -  */ -  while ((getsockopt(this->to_fd, SOL_TCP, TCP_NODELAY, -  &old_val, &old_len)<0) && -  (errno == EINTR)) -  ; -  if (old_val == 1) { -  while ((setsockopt(this->to_fd, SOL_TCP, TCP_NODELAY, -  &new_val, sizeof(new_val))<0) && -  (errno == EINTR)) -  ; -  } - #endif /* TCP_CORK || TCP_NODELAY */ - #endif /* SOL_TCP */ -  +     SF_DFPRINTF((stderr, "sendfile: Worker started\n"));       if ((this->from_file) && (this->len)) {   #if defined(HAVE_FREEBSD_SENDFILE) || defined(HAVE_HPUX_SENDFILE) || defined(HAVE_MACOSX_SENDFILE)    off_t sent = 0;    int len = this->len;    int res;      #if defined(HAVE_FREEBSD_SENDFILE) || defined(HAVE_MACOSX_SENDFILE)    struct sf_hdtr hdtr = { NULL, 0, NULL, 0 };
pike.git/src/modules/_Stdio/sendfile.c:705:    }    /* All iovec's are now in iov & iovcnt */       this->sent += send_iov(this->to_fd, iov, iovcnt);    }      #if defined(HAVE_FREEBSD_SENDFILE) || defined(HAVE_HPUX_SENDFILE) || defined(HAVE_MACOSX_SENDFILE)    done:   #endif /* HAVE_FREEBSD_SENDFILE || HAVE_HPUX_SENDFILE || HAVE_MACOSX_SENDFILE */    - #ifdef SOL_TCP - #ifdef TCP_CORK -  /* Restore the cork mode for the socket. */ -  if (!old_val) { -  while((setsockopt(this->to_fd, SOL_TCP, TCP_CORK, -  &old_val, old_len)<0) && (errno == EINTR)) -  ; -  } - #elif defined(TCP_NODELAY) -  /* Restore the nagle mode for the socket. */ -  if (old_val == 1) { -  while((setsockopt(this->to_fd, SOL_TCP, TCP_NODELAY, -  &old_val, old_len)<0) && (errno == EINTR)) -  ; -  } - #endif /* TCP_CORK || TCP_NODELAY */ - #endif /* SOL_TCP */ +  bulkmode_restore(this->to_fd, oldbulkmode);       SF_DFPRINTF((stderr,    "sendfile: Done. Setting up callback\n"    "%d bytes sent\n", this->sent));       /* FIXME: Restore non-blocking mode here? */   }      static void worker(void *this_)   {