Changeset 1692

Show
Ignore:
Timestamp:
07/25/08 16:43:48 (6 months ago)
Author:
alo
Message:

--

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • cherokee/trunk/ChangeLog

    r1691 r1692  
    112008-07-25  Alvaro Lopez Ortega  <alvaro@alobbs.com> 
     2 
     3        * cherokee/socket.c, cherokee/socket.h, cherokee/connection.c, 
     4        configure.in, acinclude.m4: Added support for TCP_CORK on BSD and 
     5        OS X systems. Actually, it's called TCP_NOPUSH on those. 
    26 
    37        * admin/config.py (Config.serialize): Sorts the configuration file 
  • cherokee/trunk/acinclude.m4

    r1 r1692  
    448448 
    449449]) 
     450 
     451AC_DEFUN([HYDRA_TCP_NOPUSH], [ 
     452 
     453AC_MSG_CHECKING([whether TCP_NOPUSH is a valid TCP socket option]) 
     454AC_TRY_COMPILE( 
     455#include <sys/socket.h> 
     456#include <netinet/tcp.h> 
     457#include <netinet/in.h> 
     458,[ 
     459  int one = 1, fd; 
     460  if (setsockopt(fd, IPPROTO_TCP, TCP_NOPUSH, 
     461                    (void *) &one, sizeof (one)) == -1) 
     462      return -1; 
     463  return 0; 
     464 
     465], 
     466dnl *** FOUND 
     467AC_DEFINE( HAVE_TCP_NOPUSH, 1, [TCP_NOPUSH was found and will be used]) 
     468AC_MSG_RESULT(yes), 
     469dnl *** NOT FOUND 
     470AC_MSG_RESULT(no) 
     471) 
     472 
     473]) 
  • cherokee/trunk/cherokee/connection.c

    r1684 r1692  
    721721cherokee_connection_set_cork (cherokee_connection_t *conn, cherokee_boolean_t enable) 
    722722{ 
    723 #ifdef HAVE_TCP_CORK 
    724         int fd; 
    725         int on = 0; 
    726  
    727         fd = SOCKET_FD(&conn->socket); 
    728         if (enable) { 
    729                 setsockopt(fd, IPPROTO_TCP, TCP_NODELAY,  &on, sizeof on); 
    730  
    731                 on = 1; 
    732                 setsockopt(fd, IPPROTO_TCP, TCP_CORK,  &on, sizeof on); 
     723        cherokee_socket_set_cork (&conn->socket, enable); 
     724 
     725        if (enable) 
    733726                BIT_SET (conn->options, conn_op_tcp_cork); 
    734         } else { 
    735                 setsockopt(fd, IPPROTO_TCP, TCP_CORK,  &on, sizeof on); 
    736  
    737                 on = 1; 
    738                 setsockopt(fd, IPPROTO_TCP, TCP_NODELAY,  &on, sizeof on); 
     727        else 
    739728                BIT_UNSET (conn->options, conn_op_tcp_cork); 
    740         } 
    741 #else 
    742         UNUSED(conn); 
    743         UNUSED(enable); 
    744 #endif 
    745729 
    746730        return ret_ok; 
  • cherokee/trunk/cherokee/socket.c

    r1575 r1692  
    8484#endif 
    8585 
     86#if !defined(TCP_CORK) && defined(TCP_NOPUSH) 
     87#define TCP_CORK TCP_NOPUSH 
     88#endif 
     89 
    8690#define ENTRIES "socket" 
    8791 
     
    18861890} 
    18871891 
     1892 
     1893ret_t 
     1894cherokee_socket_set_cork (cherokee_socket_t *socket, cherokee_boolean_t *enable) 
     1895{ 
     1896#if defined(HAVE_TCP_CORK) || defined(HAVE_TCP_NOPUSH) 
     1897        int on; 
     1898        int fd = socket->socket; 
     1899 
     1900        if (enable) { 
     1901                on = 0; 
     1902                setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &on, sizeof on); 
     1903                on = 1; 
     1904                setsockopt(fd, IPPROTO_TCP, TCP_CORK, &on, sizeof on); 
     1905        } else { 
     1906                on = 0; 
     1907                setsockopt(fd, IPPROTO_TCP, TCP_CORK, &on, sizeof on); 
     1908                on = 1; 
     1909                setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &on, sizeof on); 
     1910        } 
     1911#else 
     1912        UNUSED(socket); 
     1913        UNUSED(enable); 
     1914#endif 
     1915        return ret_ok; 
     1916} 
  • cherokee/trunk/cherokee/socket.h

    r1131 r1692  
    204204ret_t cherokee_socket_gethostbyname     (cherokee_socket_t *socket, cherokee_buffer_t *hostname); 
    205205ret_t cherokee_socket_set_status        (cherokee_socket_t *socket, cherokee_socket_status_t status); 
     206ret_t cherokee_socket_set_cork          (cherokee_socket_t *socket, cherokee_boolean_t *enable); 
    206207 
    207208/* Low level functions 
  • cherokee/trunk/configure.in

    r1651 r1692  
    451451dnl 
    452452HYDRA_TCP_CORK 
     453HYDRA_TCP_NOPUSH 
    453454 
    454455dnl