You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Randall Stewart <ra...@stewart.chicago.il.us> on 2002/10/17 15:05:50 UTC

Patch option 1 - with apr_socket_create_protocol()

Dear all:

I attach the option 1 patch... aka add the call
apr_socket_create_protocol() to the  apr. This causes
the smallest amount of change to the apr.

I will follow up .. possibly tommorrow if I get the
cycles...sigh.. with option 2 .. change to
the arguments of apr_socket_create() itself to include
the protocol and then changing all the places that
apr_socket_create is called...


I would appreciate feedback on style.. I think I got
everything correct.. but it never hurts to find out :>

I found the setting for emacs so no more ugly tabs :> now
if I could teach it to add a space for me between ){ and arguments
I would be set :-0

R
-- 
Randall R. Stewart
randall@stewart.chicago.il.us 815-342-5222 (cell phone)

Re: detecting SCTP protocol support

Posted by Randall Stewart <ra...@stewart.chicago.il.us>.
Jeff:

Great solution.. it worked wonderfully on both my BSD's .. the have SCTP
and the HAVE-NOT SCTP ;-)

Much better than what I sent in.. thanks Jeff

R

Jeff Trawick wrote:
> Does this work everywhere?  It ensures that we can actually get a
> socket with protocol IPPROTO_SCTP when determining the value of
> APR_HAVE_SCTP.
> 
> Index: configure.in
> ===================================================================
> RCS file: /home/cvs/apr/configure.in,v
> retrieving revision 1.491
> diff -u -r1.491 configure.in
> --- configure.in	18 Oct 2002 15:00:35 -0000	1.491
> +++ configure.in	22 Oct 2002 02:40:13 -0000
> @@ -930,6 +930,8 @@
>      kernel/OS.h		\
>      net/errno.h		\
>      netinet/in.h	\
> +    netinet/sctp.h      \
> +    netinet/sctp_uio.h  \
>      sys/file.h		\
>      sys/mman.h		\
>      sys/poll.h		\
> @@ -977,6 +979,8 @@
>  AC_SUBST(netdbh)
>  AC_SUBST(sys_syslimitsh)
>  AC_SUBST(netinet_inh)
> +AC_SUBST(netinet_sctph)
> +AC_SUBST(netinet_sctp_uioh)
>  AC_SUBST(netinet_tcph)
>  AC_SUBST(stdargh)
>  AC_SUBST(stdioh)
> @@ -1723,9 +1727,12 @@
>      acceptfilter="0"
>  fi
>  
> +APR_CHECK_SCTP
> +
>  AC_SUBST(apr_tcp_nopush_flag)
>  AC_SUBST(have_corkable_tcp)
>  AC_SUBST(acceptfilter)
> +AC_SUBST(have_sctp)
>  
>  AC_CHECK_FUNCS(set_h_errno)
>  APR_CHECK_RESOLV_RETRANS
> Index: build/apr_network.m4
> ===================================================================
> RCS file: /home/cvs/apr/build/apr_network.m4,v
> retrieving revision 1.18
> diff -u -r1.18 apr_network.m4
> --- build/apr_network.m4	30 Apr 2002 10:57:40 -0000	1.18
> +++ build/apr_network.m4	22 Oct 2002 02:40:14 -0000
> @@ -659,6 +659,44 @@
>  
>  
>  dnl
> +dnl APR_CHECK_SCTP
> +dnl
> +dnl check for presence of SCTP protocol support
> +dnl
> +AC_DEFUN(APR_CHECK_SCTP,[
> +  AC_CACHE_CHECK(if SCTP protocol is supported, ac_cv_sctp,[
> +  AC_TRY_RUN( [
> +#ifdef HAVE_SYS_TYPES_H
> +#include <sys/types.h>
> +#endif
> +#ifdef HAVE_SYS_SOCKET_H
> +#include <sys/socket.h>
> +#endif
> +#ifdef HAVE_NETINET_IN_H
> +#include <netinet/in.h>
> +#endif
> +int main(void) {
> +    int s = socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP);
> +    if (s < 0) {
> +        exit(1);
> +    }
> +    exit(0);
> +}
> +],[
> +    ac_cv_sctp="yes"
> +],[
> +    ac_cv_sctp="no"
> +],[
> +    ac_cv_sctp="yes"
> +])])
> +if test "$ac_cv_sctp" = "yes"; then
> +    have_sctp=1
> +else
> +    have_sctp=0
> +fi
> +])
> +
> +dnl
>  dnl APR_CHECK_H_ERRNO_FLAG
>  dnl
>  dnl checks which flags are necessary for <netdb.h> to define h_errno
> Index: include/apr.h.in
> ===================================================================
> RCS file: /home/cvs/apr/include/apr.h.in,v
> retrieving revision 1.115
> diff -u -r1.115 apr.h.in
> --- include/apr.h.in	3 Aug 2002 20:29:54 -0000	1.115
> +++ include/apr.h.in	22 Oct 2002 02:40:14 -0000
> @@ -43,6 +43,8 @@
>  #define APR_HAVE_LIMITS_H        @limitsh@
>  #define APR_HAVE_NETDB_H         @netdbh@
>  #define APR_HAVE_NETINET_IN_H    @netinet_inh@
> +#define APR_HAVE_NETINET_SCTP_H  @netinet_sctph@
> +#define APR_HAVE_NETINET_SCTP_UIO_H @netinet_sctp_uioh@
>  #define APR_HAVE_NETINET_TCP_H   @netinet_tcph@
>  #define APR_HAVE_PTHREAD_H       @pthreadh@
>  #define APR_HAVE_SEMAPHORE_H     @semaphoreh@
> @@ -117,6 +119,7 @@
>  #define APR_HAVE_MEMCHR         @have_memchr@
>  #define APR_HAVE_STRUCT_RLIMIT  @struct_rlimit@
>  #define APR_HAVE_UNION_SEMUN    @have_union_semun@
> +#define APR_HAVE_SCTP           @have_sctp@
>  
>  #if APR_HAVE_SYS_TYPES_H
>  #include <sys/types.h>
> 



-- 
Randall R. Stewart
randall@stewart.chicago.il.us 815-342-5222 (cell phone)


Re: detecting SCTP protocol support

Posted by Randall Stewart <ra...@stewart.chicago.il.us>.
Yep.. at least all those implementations that are
using a socket-api.

Let me do a local patch and make sure this works (for syntax 
errors..etc).. but I think this should be fine :>

R

Jeff Trawick wrote:
> Does this work everywhere?  It ensures that we can actually get a
> socket with protocol IPPROTO_SCTP when determining the value of
> APR_HAVE_SCTP.
> 
> Index: configure.in
> ===================================================================
> RCS file: /home/cvs/apr/configure.in,v
> retrieving revision 1.491
> diff -u -r1.491 configure.in
> --- configure.in	18 Oct 2002 15:00:35 -0000	1.491
> +++ configure.in	22 Oct 2002 02:40:13 -0000
> @@ -930,6 +930,8 @@
>      kernel/OS.h		\
>      net/errno.h		\
>      netinet/in.h	\
> +    netinet/sctp.h      \
> +    netinet/sctp_uio.h  \
>      sys/file.h		\
>      sys/mman.h		\
>      sys/poll.h		\
> @@ -977,6 +979,8 @@
>  AC_SUBST(netdbh)
>  AC_SUBST(sys_syslimitsh)
>  AC_SUBST(netinet_inh)
> +AC_SUBST(netinet_sctph)
> +AC_SUBST(netinet_sctp_uioh)
>  AC_SUBST(netinet_tcph)
>  AC_SUBST(stdargh)
>  AC_SUBST(stdioh)
> @@ -1723,9 +1727,12 @@
>      acceptfilter="0"
>  fi
>  
> +APR_CHECK_SCTP
> +
>  AC_SUBST(apr_tcp_nopush_flag)
>  AC_SUBST(have_corkable_tcp)
>  AC_SUBST(acceptfilter)
> +AC_SUBST(have_sctp)
>  
>  AC_CHECK_FUNCS(set_h_errno)
>  APR_CHECK_RESOLV_RETRANS
> Index: build/apr_network.m4
> ===================================================================
> RCS file: /home/cvs/apr/build/apr_network.m4,v
> retrieving revision 1.18
> diff -u -r1.18 apr_network.m4
> --- build/apr_network.m4	30 Apr 2002 10:57:40 -0000	1.18
> +++ build/apr_network.m4	22 Oct 2002 02:40:14 -0000
> @@ -659,6 +659,44 @@
>  
>  
>  dnl
> +dnl APR_CHECK_SCTP
> +dnl
> +dnl check for presence of SCTP protocol support
> +dnl
> +AC_DEFUN(APR_CHECK_SCTP,[
> +  AC_CACHE_CHECK(if SCTP protocol is supported, ac_cv_sctp,[
> +  AC_TRY_RUN( [
> +#ifdef HAVE_SYS_TYPES_H
> +#include <sys/types.h>
> +#endif
> +#ifdef HAVE_SYS_SOCKET_H
> +#include <sys/socket.h>
> +#endif
> +#ifdef HAVE_NETINET_IN_H
> +#include <netinet/in.h>
> +#endif
> +int main(void) {
> +    int s = socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP);
> +    if (s < 0) {
> +        exit(1);
> +    }
> +    exit(0);
> +}
> +],[
> +    ac_cv_sctp="yes"
> +],[
> +    ac_cv_sctp="no"
> +],[
> +    ac_cv_sctp="yes"
> +])])
> +if test "$ac_cv_sctp" = "yes"; then
> +    have_sctp=1
> +else
> +    have_sctp=0
> +fi
> +])
> +
> +dnl
>  dnl APR_CHECK_H_ERRNO_FLAG
>  dnl
>  dnl checks which flags are necessary for <netdb.h> to define h_errno
> Index: include/apr.h.in
> ===================================================================
> RCS file: /home/cvs/apr/include/apr.h.in,v
> retrieving revision 1.115
> diff -u -r1.115 apr.h.in
> --- include/apr.h.in	3 Aug 2002 20:29:54 -0000	1.115
> +++ include/apr.h.in	22 Oct 2002 02:40:14 -0000
> @@ -43,6 +43,8 @@
>  #define APR_HAVE_LIMITS_H        @limitsh@
>  #define APR_HAVE_NETDB_H         @netdbh@
>  #define APR_HAVE_NETINET_IN_H    @netinet_inh@
> +#define APR_HAVE_NETINET_SCTP_H  @netinet_sctph@
> +#define APR_HAVE_NETINET_SCTP_UIO_H @netinet_sctp_uioh@
>  #define APR_HAVE_NETINET_TCP_H   @netinet_tcph@
>  #define APR_HAVE_PTHREAD_H       @pthreadh@
>  #define APR_HAVE_SEMAPHORE_H     @semaphoreh@
> @@ -117,6 +119,7 @@
>  #define APR_HAVE_MEMCHR         @have_memchr@
>  #define APR_HAVE_STRUCT_RLIMIT  @struct_rlimit@
>  #define APR_HAVE_UNION_SEMUN    @have_union_semun@
> +#define APR_HAVE_SCTP           @have_sctp@
>  
>  #if APR_HAVE_SYS_TYPES_H
>  #include <sys/types.h>
> 



-- 
Randall R. Stewart
randall@stewart.chicago.il.us 815-342-5222 (cell phone)


detecting SCTP protocol support

Posted by Jeff Trawick <tr...@attglobal.net>.
Does this work everywhere?  It ensures that we can actually get a
socket with protocol IPPROTO_SCTP when determining the value of
APR_HAVE_SCTP.

Index: configure.in
===================================================================
RCS file: /home/cvs/apr/configure.in,v
retrieving revision 1.491
diff -u -r1.491 configure.in
--- configure.in	18 Oct 2002 15:00:35 -0000	1.491
+++ configure.in	22 Oct 2002 02:40:13 -0000
@@ -930,6 +930,8 @@
     kernel/OS.h		\
     net/errno.h		\
     netinet/in.h	\
+    netinet/sctp.h      \
+    netinet/sctp_uio.h  \
     sys/file.h		\
     sys/mman.h		\
     sys/poll.h		\
@@ -977,6 +979,8 @@
 AC_SUBST(netdbh)
 AC_SUBST(sys_syslimitsh)
 AC_SUBST(netinet_inh)
+AC_SUBST(netinet_sctph)
+AC_SUBST(netinet_sctp_uioh)
 AC_SUBST(netinet_tcph)
 AC_SUBST(stdargh)
 AC_SUBST(stdioh)
@@ -1723,9 +1727,12 @@
     acceptfilter="0"
 fi
 
+APR_CHECK_SCTP
+
 AC_SUBST(apr_tcp_nopush_flag)
 AC_SUBST(have_corkable_tcp)
 AC_SUBST(acceptfilter)
+AC_SUBST(have_sctp)
 
 AC_CHECK_FUNCS(set_h_errno)
 APR_CHECK_RESOLV_RETRANS
Index: build/apr_network.m4
===================================================================
RCS file: /home/cvs/apr/build/apr_network.m4,v
retrieving revision 1.18
diff -u -r1.18 apr_network.m4
--- build/apr_network.m4	30 Apr 2002 10:57:40 -0000	1.18
+++ build/apr_network.m4	22 Oct 2002 02:40:14 -0000
@@ -659,6 +659,44 @@
 
 
 dnl
+dnl APR_CHECK_SCTP
+dnl
+dnl check for presence of SCTP protocol support
+dnl
+AC_DEFUN(APR_CHECK_SCTP,[
+  AC_CACHE_CHECK(if SCTP protocol is supported, ac_cv_sctp,[
+  AC_TRY_RUN( [
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+int main(void) {
+    int s = socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP);
+    if (s < 0) {
+        exit(1);
+    }
+    exit(0);
+}
+],[
+    ac_cv_sctp="yes"
+],[
+    ac_cv_sctp="no"
+],[
+    ac_cv_sctp="yes"
+])])
+if test "$ac_cv_sctp" = "yes"; then
+    have_sctp=1
+else
+    have_sctp=0
+fi
+])
+
+dnl
 dnl APR_CHECK_H_ERRNO_FLAG
 dnl
 dnl checks which flags are necessary for <netdb.h> to define h_errno
Index: include/apr.h.in
===================================================================
RCS file: /home/cvs/apr/include/apr.h.in,v
retrieving revision 1.115
diff -u -r1.115 apr.h.in
--- include/apr.h.in	3 Aug 2002 20:29:54 -0000	1.115
+++ include/apr.h.in	22 Oct 2002 02:40:14 -0000
@@ -43,6 +43,8 @@
 #define APR_HAVE_LIMITS_H        @limitsh@
 #define APR_HAVE_NETDB_H         @netdbh@
 #define APR_HAVE_NETINET_IN_H    @netinet_inh@
+#define APR_HAVE_NETINET_SCTP_H  @netinet_sctph@
+#define APR_HAVE_NETINET_SCTP_UIO_H @netinet_sctp_uioh@
 #define APR_HAVE_NETINET_TCP_H   @netinet_tcph@
 #define APR_HAVE_PTHREAD_H       @pthreadh@
 #define APR_HAVE_SEMAPHORE_H     @semaphoreh@
@@ -117,6 +119,7 @@
 #define APR_HAVE_MEMCHR         @have_memchr@
 #define APR_HAVE_STRUCT_RLIMIT  @struct_rlimit@
 #define APR_HAVE_UNION_SEMUN    @have_union_semun@
+#define APR_HAVE_SCTP           @have_sctp@
 
 #if APR_HAVE_SYS_TYPES_H
 #include <sys/types.h>

-- 
Jeff Trawick | trawick@attglobal.net
Born in Roswell... married an alien...

Re: mapping TCP_NODELAY to SCTP_NODELAY as appropriate

Posted by Randall Stewart <ra...@stewart.chicago.il.us>.
Just patched it in.. works fine..

R

Jeff Trawick wrote:
> Can you check this out?  I tweaked your sockopt code for Unix just a
> bit.
> 
> Index: include/apr_network_io.h
> ===================================================================
> RCS file: /home/cvs/apr/include/apr_network_io.h,v
> retrieving revision 1.130
> diff -u -r1.130 apr_network_io.h
> --- include/apr_network_io.h	18 Oct 2002 12:03:59 -0000	1.130
> +++ include/apr_network_io.h	22 Oct 2002 19:09:11 -0000
> @@ -103,7 +103,9 @@
>  #define APR_SO_SNDBUF        64
>  #define APR_SO_RCVBUF        128
>  #define APR_SO_DISCONNECTED  256
> -#define APR_TCP_NODELAY      512
> +#define APR_TCP_NODELAY      512  /**< For SCTP sockets, this is mapped
> +                                   * to STCP_NODELAY internally.
> +                                   */
>  #define APR_TCP_NOPUSH       1024
>  #define APR_RESET_NODELAY    2048 /**< This flag is ONLY set internally
>                                     * when we set APR_TCP_NOPUSH with
> Index: include/arch/unix/networkio.h
> ===================================================================
> RCS file: /home/cvs/apr/include/arch/unix/networkio.h,v
> retrieving revision 1.55
> diff -u -r1.55 networkio.h
> --- include/arch/unix/networkio.h	18 Oct 2002 12:03:59 -0000	1.55
> +++ include/arch/unix/networkio.h	22 Oct 2002 19:09:11 -0000
> @@ -87,6 +87,12 @@
>  #if APR_HAVE_NETINET_TCP_H
>  #include <netinet/tcp.h>
>  #endif
> +#if APR_HAVE_NETINET_SCTP_UIO_H
> +#include <netinet/sctp_uio.h>
> +#endif
> +#if APR_HAVE_NETINET_SCTP_H
> +#include <netinet/sctp.h>
> +#endif
>  #if APR_HAVE_NETINET_IN_H
>  #include <netinet/in.h>
>  #endif
> Index: network_io/unix/sockopt.c
> ===================================================================
> RCS file: /home/cvs/apr/network_io/unix/sockopt.c,v
> retrieving revision 1.60
> diff -u -r1.60 sockopt.c
> --- network_io/unix/sockopt.c	22 Oct 2002 18:55:17 -0000	1.60
> +++ network_io/unix/sockopt.c	22 Oct 2002 19:09:12 -0000
> @@ -232,7 +232,16 @@
>      if (opt & APR_TCP_NODELAY) {
>  #if defined(TCP_NODELAY)
>          if (apr_is_option_set(sock->netmask, APR_TCP_NODELAY) != on) {
> -            if (setsockopt(sock->socketdes, IPPROTO_TCP, TCP_NODELAY, (void *)&on, sizeof(int)) == -1) {
> +            int optlevel = IPPROTO_TCP;
> +            int optname = TCP_NODELAY;
> +
> +#if APR_HAVE_SCTP
> +            if (sock->protocol == IPPROTO_SCTP) {
> +                optlevel = IPPROTO_SCTP;
> +                optname = SCTP_NODELAY;
> +            }
> +#endif
> +            if (setsockopt(sock->socketdes, optlevel, optname, (void *)&on, sizeof(int)) == -1) {
>                  return errno;
>              }
>              apr_set_option(&sock->netmask, APR_TCP_NODELAY, on);
> @@ -253,6 +262,15 @@
>      if (opt & APR_TCP_NOPUSH) {
>  #if APR_TCP_NOPUSH_FLAG
>          if (apr_is_option_set(sock->netmask, APR_TCP_NOPUSH) != on) {
> +            int optlevel = IPPROTO_TCP;
> +            int optname = TCP_NODELAY;
> +
> +#if APR_HAVE_SCTP
> +            if (sock->protocol == IPPROTO_SCTP) {
> +                optlevel = IPPROTO_SCTP;
> +                optname = SCTP_NODELAY;
> +            }
> +#endif
>              /* OK we're going to change some settings here... */
>              /* TCP_NODELAY is mutually exclusive, so do we have it set? */
>              if (apr_is_option_set(sock->netmask, APR_TCP_NODELAY) == 1 && on) {
> @@ -260,7 +278,7 @@
>                   * flag set we need to switch it off...
>                   */
>                  int tmpflag = 0;
> -                if (setsockopt(sock->socketdes, IPPROTO_TCP, TCP_NODELAY,
> +                if (setsockopt(sock->socketdes, optlevel, optname,
>                                 (void*)&tmpflag, sizeof(int)) == -1) {
>                      return errno;
>                  }
> @@ -277,7 +295,7 @@
>              apr_set_option(&sock->netmask, APR_TCP_NOPUSH, on);
>              if (!on && apr_is_option_set(sock->netmask, APR_RESET_NODELAY)) {
>                  int tmpflag = 1;
> -                if (setsockopt(sock->socketdes, IPPROTO_TCP, TCP_NODELAY,
> +                if (setsockopt(sock->socketdes, optlevel, optname,
>                                 (void*)&tmpflag, sizeof(int)) == -1) {
>                      return errno;
>                  }
> 
> 



-- 
Randall R. Stewart
randall@stewart.chicago.il.us 815-342-5222 (cell phone)


mapping TCP_NODELAY to SCTP_NODELAY as appropriate

Posted by Jeff Trawick <tr...@attglobal.net>.
Can you check this out?  I tweaked your sockopt code for Unix just a
bit.

Index: include/apr_network_io.h
===================================================================
RCS file: /home/cvs/apr/include/apr_network_io.h,v
retrieving revision 1.130
diff -u -r1.130 apr_network_io.h
--- include/apr_network_io.h	18 Oct 2002 12:03:59 -0000	1.130
+++ include/apr_network_io.h	22 Oct 2002 19:09:11 -0000
@@ -103,7 +103,9 @@
 #define APR_SO_SNDBUF        64
 #define APR_SO_RCVBUF        128
 #define APR_SO_DISCONNECTED  256
-#define APR_TCP_NODELAY      512
+#define APR_TCP_NODELAY      512  /**< For SCTP sockets, this is mapped
+                                   * to STCP_NODELAY internally.
+                                   */
 #define APR_TCP_NOPUSH       1024
 #define APR_RESET_NODELAY    2048 /**< This flag is ONLY set internally
                                    * when we set APR_TCP_NOPUSH with
Index: include/arch/unix/networkio.h
===================================================================
RCS file: /home/cvs/apr/include/arch/unix/networkio.h,v
retrieving revision 1.55
diff -u -r1.55 networkio.h
--- include/arch/unix/networkio.h	18 Oct 2002 12:03:59 -0000	1.55
+++ include/arch/unix/networkio.h	22 Oct 2002 19:09:11 -0000
@@ -87,6 +87,12 @@
 #if APR_HAVE_NETINET_TCP_H
 #include <netinet/tcp.h>
 #endif
+#if APR_HAVE_NETINET_SCTP_UIO_H
+#include <netinet/sctp_uio.h>
+#endif
+#if APR_HAVE_NETINET_SCTP_H
+#include <netinet/sctp.h>
+#endif
 #if APR_HAVE_NETINET_IN_H
 #include <netinet/in.h>
 #endif
Index: network_io/unix/sockopt.c
===================================================================
RCS file: /home/cvs/apr/network_io/unix/sockopt.c,v
retrieving revision 1.60
diff -u -r1.60 sockopt.c
--- network_io/unix/sockopt.c	22 Oct 2002 18:55:17 -0000	1.60
+++ network_io/unix/sockopt.c	22 Oct 2002 19:09:12 -0000
@@ -232,7 +232,16 @@
     if (opt & APR_TCP_NODELAY) {
 #if defined(TCP_NODELAY)
         if (apr_is_option_set(sock->netmask, APR_TCP_NODELAY) != on) {
-            if (setsockopt(sock->socketdes, IPPROTO_TCP, TCP_NODELAY, (void *)&on, sizeof(int)) == -1) {
+            int optlevel = IPPROTO_TCP;
+            int optname = TCP_NODELAY;
+
+#if APR_HAVE_SCTP
+            if (sock->protocol == IPPROTO_SCTP) {
+                optlevel = IPPROTO_SCTP;
+                optname = SCTP_NODELAY;
+            }
+#endif
+            if (setsockopt(sock->socketdes, optlevel, optname, (void *)&on, sizeof(int)) == -1) {
                 return errno;
             }
             apr_set_option(&sock->netmask, APR_TCP_NODELAY, on);
@@ -253,6 +262,15 @@
     if (opt & APR_TCP_NOPUSH) {
 #if APR_TCP_NOPUSH_FLAG
         if (apr_is_option_set(sock->netmask, APR_TCP_NOPUSH) != on) {
+            int optlevel = IPPROTO_TCP;
+            int optname = TCP_NODELAY;
+
+#if APR_HAVE_SCTP
+            if (sock->protocol == IPPROTO_SCTP) {
+                optlevel = IPPROTO_SCTP;
+                optname = SCTP_NODELAY;
+            }
+#endif
             /* OK we're going to change some settings here... */
             /* TCP_NODELAY is mutually exclusive, so do we have it set? */
             if (apr_is_option_set(sock->netmask, APR_TCP_NODELAY) == 1 && on) {
@@ -260,7 +278,7 @@
                  * flag set we need to switch it off...
                  */
                 int tmpflag = 0;
-                if (setsockopt(sock->socketdes, IPPROTO_TCP, TCP_NODELAY,
+                if (setsockopt(sock->socketdes, optlevel, optname,
                                (void*)&tmpflag, sizeof(int)) == -1) {
                     return errno;
                 }
@@ -277,7 +295,7 @@
             apr_set_option(&sock->netmask, APR_TCP_NOPUSH, on);
             if (!on && apr_is_option_set(sock->netmask, APR_RESET_NODELAY)) {
                 int tmpflag = 1;
-                if (setsockopt(sock->socketdes, IPPROTO_TCP, TCP_NODELAY,
+                if (setsockopt(sock->socketdes, optlevel, optname,
                                (void*)&tmpflag, sizeof(int)) == -1) {
                     return errno;
                 }


-- 
Jeff Trawick | trawick@attglobal.net
Born in Roswell... married an alien...

Re: Patch option 1 - with apr_socket_create_protocol()

Posted by Randall Stewart <ra...@stewart.chicago.il.us>.
Jeff Trawick wrote:
> Randall Stewart <ra...@stewart.chicago.il.us> writes:
> 
> 
>>Dear all:
>>
>>I attach the option 1 patch... aka add the call
>>apr_socket_create_protocol() to the  apr. This causes
>>the smallest amount of change to the apr.
> 
> 
> An initial patch to support protocols in general is committed.  Please
> check over and complain appropriately before I go through the rest of
> your patch.
> 
> deferred temporarily: 
>   locating sctp headers, setting APR_HAVE_SCTP, special socket option
>   support for SCTP
> 
> deferred until we prepare for 1.0:
>   protocol support for apr_os_sock_make (since that would break binary
>   compatibility since the structure is extended and I don't think it
>   is necessary to have temporary apr_os_sock_make_ex and temporary
>   apr_os_sock_info_ex_t)
> 
> changed:
>   kernel continues to choose proto if app doesn't choose
>   hard-code numeric values for the several protocols
> 
> enhanced:
>   test/server.c makes sure desired protocol is preserved from
>   listening socket to connected socket
> 
> I've got some high priority Apache testing to do this a.m., but
> hopefully in the next day or so I can get to the parts of your patch
> which I temporarily deferred, and meanwhile you can look out for
> screwups or other problems in what I just committed.
> 
> Thanks,
> 

Thanks jeff.. I will find some cycles this A.M and get my tree up to
date and have a look...

R

-- 
Randall R. Stewart
randall@stewart.chicago.il.us 815-342-5222 (cell phone)


Re: Patch option 1 - with apr_socket_create_protocol()

Posted by Jeff Trawick <tr...@attglobal.net>.
Randall Stewart <ra...@stewart.chicago.il.us> writes:

> Jeff:
> 
> Ok I just stole a few cycles and had a look... some quick comments.
> 
> 1) In the network_io/win32/sockets.c
> 
>     the call from apr_socket_create() to -> apr_socket_create_ex()
> 
>    is going to not compile since you put in a variable "protocol" which
>    is not defined in the function.. I think you meant to put '0' in here
>    like you did in the other 2.

whoops!  (now fixed)

> 2) The change in apr_os_sock_put to specify TCP is, IMO, the wrong
>     thing to do... A quick check of cscope in httpd shows 6 users of
>     this call and of those 6, 4 of the uses are for NON-TCP sockets (at
>     least I think they are.. called things like the "pipe of death" etc.
>     Of the 2 that use TCP .. once SCTP shows up this will cause
>     some problems (at least in the mpm files). They are passing the
>     listener sockets to the child and setting them. One of them knows
>     the protocol (if it cared to get it) the other does not.. and
>     I would imagine will need to send it...
> 
>     Maybe for now just specifying '0' .. or maybe we need a
>     APR_PROT_UNKNOWN -> 0... definition. Sigh.. ugly either
>     way..

definitely ugly...  we have a way to create a socket from a descriptor
where the app tells us the nitty gritty details (apr_os_sock_make) and
a way to create a socket from a descriptor where the app tells us
almost nothing...  I'll change apr_os_sock_put() to use 0 like you
suggest but I wonder why we need the apr_os_sock_put() if we get into
trouble like this trying to guess what kind of socket it is...
apr_os_sock_put() already is broken if type != SOCK_STREAM

Thanks!!!!
-- 
Jeff Trawick | trawick@attglobal.net
Born in Roswell... married an alien...

Re: Patch option 1 - with apr_socket_create_protocol()

Posted by Randall Stewart <ra...@stewart.chicago.il.us>.
Jeff:

Ok I just stole a few cycles and had a look... some quick comments.

1) In the network_io/win32/sockets.c

    the call from apr_socket_create() to -> apr_socket_create_ex()

   is going to not compile since you put in a variable "protocol" which
   is not defined in the function.. I think you meant to put '0' in here
   like you did in the other 2.

2) The change in apr_os_sock_put to specify TCP is, IMO, the wrong
    thing to do... A quick check of cscope in httpd shows 6 users of
    this call and of those 6, 4 of the uses are for NON-TCP sockets (at
    least I think they are.. called things like the "pipe of death" etc.
    Of the 2 that use TCP .. once SCTP shows up this will cause
    some problems (at least in the mpm files). They are passing the
    listener sockets to the child and setting them. One of them knows
    the protocol (if it cared to get it) the other does not.. and
    I would imagine will need to send it...

    Maybe for now just specifying '0' .. or maybe we need a
    APR_PROT_UNKNOWN -> 0... definition. Sigh.. ugly either
    way..


R


Jeff Trawick wrote:
> Randall Stewart <ra...@stewart.chicago.il.us> writes:
> 
> 
>>Dear all:
>>
>>I attach the option 1 patch... aka add the call
>>apr_socket_create_protocol() to the  apr. This causes
>>the smallest amount of change to the apr.
> 
> 
> An initial patch to support protocols in general is committed.  Please
> check over and complain appropriately before I go through the rest of
> your patch.
> 
> deferred temporarily: 
>   locating sctp headers, setting APR_HAVE_SCTP, special socket option
>   support for SCTP
> 
> deferred until we prepare for 1.0:
>   protocol support for apr_os_sock_make (since that would break binary
>   compatibility since the structure is extended and I don't think it
>   is necessary to have temporary apr_os_sock_make_ex and temporary
>   apr_os_sock_info_ex_t)
> 
> changed:
>   kernel continues to choose proto if app doesn't choose
>   hard-code numeric values for the several protocols
> 
> enhanced:
>   test/server.c makes sure desired protocol is preserved from
>   listening socket to connected socket
> 
> I've got some high priority Apache testing to do this a.m., but
> hopefully in the next day or so I can get to the parts of your patch
> which I temporarily deferred, and meanwhile you can look out for
> screwups or other problems in what I just committed.
> 
> Thanks,
> 



-- 
Randall R. Stewart
randall@stewart.chicago.il.us 815-342-5222 (cell phone)


Re: Patch option 1 - with apr_socket_create_protocol()

Posted by Jeff Trawick <tr...@attglobal.net>.
Randall Stewart <ra...@stewart.chicago.il.us> writes:

> Dear all:
> 
> I attach the option 1 patch... aka add the call
> apr_socket_create_protocol() to the  apr. This causes
> the smallest amount of change to the apr.

An initial patch to support protocols in general is committed.  Please
check over and complain appropriately before I go through the rest of
your patch.

deferred temporarily: 
  locating sctp headers, setting APR_HAVE_SCTP, special socket option
  support for SCTP

deferred until we prepare for 1.0:
  protocol support for apr_os_sock_make (since that would break binary
  compatibility since the structure is extended and I don't think it
  is necessary to have temporary apr_os_sock_make_ex and temporary
  apr_os_sock_info_ex_t)

changed:
  kernel continues to choose proto if app doesn't choose
  hard-code numeric values for the several protocols

enhanced:
  test/server.c makes sure desired protocol is preserved from
  listening socket to connected socket

I've got some high priority Apache testing to do this a.m., but
hopefully in the next day or so I can get to the parts of your patch
which I temporarily deferred, and meanwhile you can look out for
screwups or other problems in what I just committed.

Thanks,

-- 
Jeff Trawick | trawick@attglobal.net
Born in Roswell... married an alien...