Bug 3574 - TCP_NODELAY and TCP_MAXSEG got undef'ed in HPUX
TCP_NODELAY and TCP_MAXSEG got undef'ed in HPUX
Status: RESOLVED WONTFIX
Product: Samba 3.0
Classification: Unclassified
Component: Build environment
3.0.21b
PA-RISC HP-UX
: P3 normal
: none
Assigned To: Tim Potter
Samba QA Contact
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2006-03-02 19:38 UTC by Adrian Tam
Modified: 2006-03-22 19:29 UTC (History)
0 users

See Also:


Attachments
includes.h patch for 3.0.21c (2.95 KB, patch)
2006-03-22 19:02 UTC, Adrian Tam
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Adrian Tam 2006-03-02 19:38:53 UTC
In include/includes.h, TCP_NODELAY and TCP_MAXSEG are undef'ed in serveral places for HPUX to avoid compiler warnings of their redifinitions. However, the code seems to be a little too agressive. TCP_NODELAY and TCP_MAXSEG ended up being completely removed. This causes an error when trying to set TCP_NODELAY as a socket option in smb.conf.

The following is a patch for 3.0.21b to fix this problem. Instead of undef'ing TCP_NODELAY and TCP_MAXSEG many times, the fix does a check to see if they are already defined. If so, they are undef'ed once just before <netinet/tcp.h> is included.

--- includes.h.orig     2006-03-02 17:06:42 -0800
+++ includes.h  2006-03-02 16:52:41 -0800
@@ -232,10 +232,6 @@

 #include <sys/file.h>

-#ifdef HAVE_NETINET_TCP_H
-#include <netinet/tcp.h>
-#endif
-
 /*
  * The next three defines are needed to access the IPTOS_* options
  * on some systems.
@@ -323,19 +319,6 @@
 #endif

 #ifdef HAVE_SHADOW_H
-/*
- * HP-UX 11.X has TCP_NODELAY and TCP_MAXSEG defined in <netinet/tcp.h> which
- * was included above.  However <rpc/rpc.h> includes <sys/xti.h> which defines
- * them again without checking if they already exsist.  This generates
- * two "Redefinition of macro" warnings for every single .c file that is
- * compiled.
- */
-#if defined(HPUX) && defined(TCP_NODELAY)
-#undef TCP_NODELAY
-#endif
-#if defined(HPUX) && defined(TCP_MAXSEG)
-#undef TCP_MAXSEG
-#endif
 #include <shadow.h>
 #endif

@@ -388,19 +371,6 @@
 #if defined(HAVE_SYS_SECURITY_H) && defined(HAVE_RPC_AUTH_ERROR_CONFLICT)
 #undef AUTH_ERROR
 #endif
-/*
- * HP-UX 11.X has TCP_NODELAY and TCP_MAXSEG defined in <netinet/tcp.h> which
- * was included above.  However <rpc/rpc.h> includes <sys/xti.h> which defines
- * them again without checking if they already exsist.  This generates
- * two "Redefinition of macro" warnings for every single .c file that is
- * compiled.
- */
-#if defined(HPUX) && defined(TCP_NODELAY)
-#undef TCP_NODELAY
-#endif
-#if defined(HPUX) && defined(TCP_MAXSEG)
-#undef TCP_MAXSEG
-#endif
 #include <rpc/rpc.h>
 #endif

@@ -410,19 +380,6 @@

 #if defined (HAVE_NETGROUP)
 #if defined(HAVE_RPCSVC_YP_PROT_H)
-/*
- * HP-UX 11.X has TCP_NODELAY and TCP_MAXSEG defined in <netinet/tcp.h> which
- * was included above.  However <rpc/rpc.h> includes <sys/xti.h> which defines
- * them again without checking if they already exsist.  This generates
- * two "Redefinition of macro" warnings for every single .c file that is
- * compiled.
- */
-#if defined(HPUX) && defined(TCP_NODELAY)
-#undef TCP_NODELAY
-#endif
-#if defined(HPUX) && defined(TCP_MAXSEG)
-#undef TCP_MAXSEG
-#endif
 #include <rpcsvc/yp_prot.h>
 #endif
 #if defined(HAVE_RPCSVC_YPCLNT_H)
@@ -1229,6 +1186,25 @@
 #define MSG_WAITALL 0
 #endif

+/*
+ * HP-UX 11.X has TCP_NODELAY and TCP_MAXSEG defined in <netinet/tcp.h>.
+ * However <rpc/rpc.h> includes <sys/xti.h> which defines
+ * them again without checking if they already exsist.  This generates
+ * two "Redefinition of macro" warnings for every single .c file that is
+ * compiled.
+ * So we check if TCP_NODELAY and TCP_MAXSEG are already defined and
+ * undef them before including <netinet/tcp.h>.
+ */
+#if defined(HPUX) && defined(TCP_NODELAY)
+#undef TCP_NODELAY
+#endif
+#if defined(HPUX) && defined(TCP_MAXSEG)
+#undef TCP_MAXSEG
+#endif
+#ifdef HAVE_NETINET_TCP_H
+#include <netinet/tcp.h>
+#endif
+
 /* default socket options. Dave Miller thinks we should default to TCP_NODELAY
    given the socket IO pattern that Samba uses */
 #ifdef TCP_NODELAY
Comment 1 Adrian Tam 2006-03-22 19:02:12 UTC
Created attachment 1819 [details]
includes.h patch for 3.0.21c

This is the same patch implemented in samba 3.0.21c
Comment 2 Jeremy Allison 2006-03-22 19:29:34 UTC
I'm sorry but I hate this patch. Please don't apply it.
Look - HPUX 11 has *broken* header guards. Hiding this in Samba doesn't help, it needs to get fixed in HPUX - adding this into our code base just makes us harder to read and includes an operating system dependency into our includes.h (which I've been trying to remove).
PLEASE FIX HPUX.
Jeremy.