rx-make-rxdebug-optional-20090113
authorJeffrey Altman <jaltman@your-file-system.com>
Tue, 13 Jan 2009 16:19:11 +0000 (16:19 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Tue, 13 Jan 2009 16:19:11 +0000 (16:19 +0000)
LICENSE BSD

Permit the rx library to be built without the RXDEBUG preprocessor
definition.  When RXDEBUG is not defined all of the debugging functions
either become stubs or log a message indicating that the library was
built without RXDEBUG so that there will be no surprises.  There
are no changes to the export list.  By default RXDEBUG is defined.

Eventually the definition of RXDEBUG can become a configuration option
to the build system.

src/cf/osconf.m4
src/rx/Makefile.in
src/rx/rx.c
src/rx/rx_globals.h
src/rx/rx_trace.c
src/rxdebug/Makefile.in
src/viced/Makefile.in

index 67cc101..30d7e0a 100644 (file)
@@ -4,6 +4,7 @@ AC_DEFUN([OPENAFS_OSCONF], [
 dnl defaults, override in case below as needed
 CFLAGS=
 XCFLAGS='${DBG} ${OPTMZ}'
+RXDEBUG="-DRXDEBUG"
 SHLIB_SUFFIX="so"
 CC="cc"
 CCOBJ="cc"
index 140d39e..5aad9bc 100644 (file)
@@ -12,7 +12,7 @@ INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 
-CFLAGS=${COMMON_CFLAGS} ${XCFLAGS} ${ARCHFLAGS} -DRXDEBUG
+CFLAGS=${COMMON_CFLAGS} ${XCFLAGS} ${ARCHFLAGS} ${RXDEBUG}
 
 #
 # Generic xdr objects (or, at least, xdr stuff that's not newly defined for rx).
index 1a15c83..11b02b8 100644 (file)
@@ -2825,9 +2825,10 @@ rxi_ReceivePacket(register struct rx_packet *np, osi_socket socket,
            call = rxi_NewCall(conn, channel);
            MUTEX_EXIT(&conn->conn_call_lock);
            *call->callNumber = np->header.callNumber;
+#ifdef RXDEBUG
            if (np->header.callNumber == 0) 
                dpf(("RecPacket call 0 %d %s: %x.%u.%u.%u.%u.%u.%u flags %d, packet %lx resend %d.%0.3d len %d", np->header.serial, rx_packetTypes[np->header.type - 1], ntohl(conn->peer->host), ntohs(conn->peer->port), np->header.serial, np->header.epoch, np->header.cid, np->header.callNumber, np->header.seq, np->header.flags, (unsigned long)np, np->retryTime.sec, np->retryTime.usec / 1000, np->length));
-
+#endif
            call->state = RX_STATE_PRECALL;
            clock_GetTime(&call->queueTime);
            hzero(call->bytesSent);
@@ -2885,9 +2886,10 @@ rxi_ReceivePacket(register struct rx_packet *np, osi_socket socket,
            }
            rxi_ResetCall(call, 0);
            *call->callNumber = np->header.callNumber;
+#ifdef RXDEBUG
            if (np->header.callNumber == 0) 
                dpf(("RecPacket call 0 %d %s: %x.%u.%u.%u.%u.%u.%u flags %d, packet %lx resend %d.%0.3d len %d", np->header.serial, rx_packetTypes[np->header.type - 1], ntohl(conn->peer->host), ntohs(conn->peer->port), np->header.serial, np->header.epoch, np->header.cid, np->header.callNumber, np->header.seq, np->header.flags, (unsigned long)np, np->retryTime.sec, np->retryTime.usec / 1000, np->length));
-
+#endif
            call->state = RX_STATE_PRECALL;
            clock_GetTime(&call->queueTime);
            hzero(call->bytesSent);
@@ -6400,10 +6402,10 @@ rxi_ComputeRate(register struct rx_peer *peer, register struct rx_call *call,
 #endif /* ADAPT_WINDOW */
 
 
-#ifdef RXDEBUG
 void
 rxi_DebugInit(void)
 {
+#ifdef RXDEBUG
 #ifdef AFS_NT40_ENV
 #define TRACE_OPTION_DEBUGLOG 4
     HKEY parmKey;
@@ -6426,27 +6428,33 @@ rxi_DebugInit(void)
     }
     RegCloseKey (parmKey);
 #endif /* AFS_NT40_ENV */
+#endif
 }
 
-#ifdef AFS_NT40_ENV
 void
 rx_DebugOnOff(int on)
 {
+#ifdef RXDEBUG
+#ifdef AFS_NT40_ENV
     rxdebug_active = on;
+#endif
+#endif
 }
 
 void
 rx_StatsOnOff(int on)
 {
+#ifdef RXDEBUG
     rx_stats_active = on;
+#endif
 }
-#endif /* AFS_NT40_ENV */
 
 
 /* Don't call this debugging routine directly; use dpf */
 void
 rxi_DebugPrint(char *format, ...)
 {
+#ifdef RXDEBUG
     va_list ap;
 #ifdef AFS_NT40_ENV
     char msg[512];
@@ -6480,8 +6488,10 @@ rxi_DebugPrint(char *format, ...)
     putc('\n', rx_Log);
     va_end(ap);
 #endif
+#endif
 }
 
+#ifndef KERNEL
 /*
  * This function is used to process the rx_stats structure that is local
  * to a process as well as an rx_stats structure received from a remote
@@ -6492,6 +6502,7 @@ void
 rx_PrintTheseStats(FILE * file, struct rx_statistics *s, int size,
                   afs_int32 freePackets, char version)
 {
+#ifdef RXDEBUG
     int i;
 
     if (size != sizeof(struct rx_statistics)) {
@@ -6566,7 +6577,9 @@ rx_PrintTheseStats(FILE * file, struct rx_statistics *s, int size,
 #if    !defined(AFS_PTHREAD_ENV) && !defined(AFS_USE_GETTIMEOFDAY)
     fprintf(file, "   %d clock updates\n", clock_nUpdates);
 #endif
-
+#else
+    fprintf(file, "ERROR: compiled without RXDEBUG\n");
+#endif
 }
 
 /* for backward compatibility */
@@ -6596,8 +6609,9 @@ rx_PrintPeerStats(FILE * file, struct rx_peer *peer)
            "max out packet skew %d\n", peer->ifMTU, (int)peer->inPacketSkew,
            (int)peer->outPacketSkew);
 }
+#endif
 
-#ifdef AFS_PTHREAD_ENV
+#if defined(AFS_PTHREAD_ENV) && defined(RXDEBUG)
 /*
  * This mutex protects the following static variables:
  * counter
@@ -6610,6 +6624,7 @@ rx_PrintPeerStats(FILE * file, struct rx_peer *peer)
 #define UNLOCK_RX_DEBUG
 #endif /* AFS_PTHREAD_ENV */
 
+#ifdef RXDEBUG
 static int
 MakeDebugCall(osi_socket socket, afs_uint32 remoteAddr, afs_uint16 remotePort,
              u_char type, void *inputData, size_t inputLength,
@@ -6715,14 +6730,18 @@ MakeDebugCall(osi_socket socket, afs_uint32 remoteAddr, afs_uint16 remotePort,
     memcpy(outputData, tp, code);
     return code;
 }
+#endif /* RXDEBUG */
 
 afs_int32
 rx_GetServerDebug(osi_socket socket, afs_uint32 remoteAddr,
                  afs_uint16 remotePort, struct rx_debugStats * stat,
                  afs_uint32 * supportedValues)
 {
-    struct rx_debugIn in;
+#ifndef RXDEBUG
+    afs_int32 rc = -1;
+#else
     afs_int32 rc = 0;
+    struct rx_debugIn in;
 
     *supportedValues = 0;
     in.type = htonl(RX_DEBUGI_GETSTATS);
@@ -6773,7 +6792,7 @@ rx_GetServerDebug(osi_socket socket, afs_uint32 remoteAddr,
         stat->nWaited = ntohl(stat->nWaited);
         stat->nPackets = ntohl(stat->nPackets);
     }
-
+#endif
     return rc;
 }
 
@@ -6782,10 +6801,13 @@ rx_GetServerStats(osi_socket socket, afs_uint32 remoteAddr,
                  afs_uint16 remotePort, struct rx_statistics * stat,
                  afs_uint32 * supportedValues)
 {
+#ifndef RXDEBUG
+    afs_int32 rc = -1;
+#else
+    afs_int32 rc = 0;
     struct rx_debugIn in;
     int i;
     afs_int32 *lp = (afs_int32 *) stat;
-    afs_int32 rc = 0;
 
     /*
      * supportedValues is currently unused, but added to allow future
@@ -6810,7 +6832,7 @@ rx_GetServerStats(osi_socket socket, afs_uint32 remoteAddr,
            *lp = ntohl(*lp);
        }
     }
-
+#endif
     return rc;
 }
 
@@ -6819,10 +6841,14 @@ rx_GetServerVersion(osi_socket socket, afs_uint32 remoteAddr,
                    afs_uint16 remotePort, size_t version_length,
                    char *version)
 {
+#ifdef RXDEBUG
     char a[1] = { 0 };
     return MakeDebugCall(socket, remoteAddr, remotePort,
                         RX_PACKET_TYPE_VERSION, a, 1, version,
                         version_length);
+#else
+    return -1;
+#endif
 }
 
 afs_int32
@@ -6832,8 +6858,11 @@ rx_GetServerConnections(osi_socket socket, afs_uint32 remoteAddr,
                        struct rx_debugConn * conn,
                        afs_uint32 * supportedValues)
 {
-    struct rx_debugIn in;
+#ifndef RXDEBUG
+    afs_int32 rc = -1;
+#else
     afs_int32 rc = 0;
+    struct rx_debugIn in;
     int i;
 
     /*
@@ -6905,7 +6934,7 @@ rx_GetServerConnections(osi_socket socket, afs_uint32 remoteAddr,
        conn->epoch = ntohl(conn->epoch);
        conn->natMTU = ntohl(conn->natMTU);
     }
-
+#endif
     return rc;
 }
 
@@ -6915,8 +6944,11 @@ rx_GetServerPeers(osi_socket socket, afs_uint32 remoteAddr,
                  afs_uint32 debugSupportedValues, struct rx_debugPeer * peer,
                  afs_uint32 * supportedValues)
 {
-    struct rx_debugIn in;
+#ifndef RXDEBUG
+    afs_int32 rc = -1;
+#else
     afs_int32 rc = 0;
+    struct rx_debugIn in;
 
     /*
      * supportedValues is currently unused, but added to allow future
@@ -6967,10 +6999,9 @@ rx_GetServerPeers(osi_socket socket, afs_uint32 remoteAddr,
        peer->bytesReceived.high = ntohl(peer->bytesReceived.high);
        peer->bytesReceived.low = ntohl(peer->bytesReceived.low);
     }
-
+#endif
     return rc;
 }
-#endif /* RXDEBUG */
 
 void
 shutdown_rx(void)
index 91e58f5..5e07a2b 100644 (file)
@@ -547,11 +547,13 @@ EXT afs_kmutex_t rx_connHashTable_lock;
 
 EXT afs_int32 rx_stats_active GLOBALSINIT(1);  /* boolean - rx statistics gathering */
 
-#ifdef RXDEBUG
+#ifndef KERNEL
 /* Some debugging stuff */
 EXT FILE *rx_debugFile;                /* Set by the user to a stdio file for debugging output */
 EXT FILE *rxevent_debugFile;   /* Set to an stdio descriptor for event logging to that file */
+#endif
 
+#ifdef RXDEBUG
 #define rx_Log rx_debugFile
 #ifdef AFS_NT40_ENV
 EXT int rxdebug_active;
@@ -566,6 +568,9 @@ EXT int rxdebug_active;
 #define rx_Log_event rxevent_debugFile
 
 EXT char *rx_packetTypes[RX_N_PACKET_TYPES] GLOBALSINIT(RX_PACKET_TYPES);      /* Strings defined in rx.h */
+#else
+#define dpf(args)
+#endif /* RXDEBUG */
 
 #ifndef KERNEL
 /*
@@ -581,10 +586,6 @@ EXT afs_kmutex_t rxi_keyCreate_lock;
 #endif /* RX_ENABLE_LOCKS */
 #endif /* !KERNEL */
 
-#else
-#define dpf(args)
-#endif /* RXDEBUG */
-
 /*
  * SERVER ONLY: Threshholds used to throttle error replies to looping
  * clients. When consecutive calls are aborting with the same error, the
index c61adf0..cfe581b 100644 (file)
 RCSID
     ("$Header$");
 
-#ifdef RXDEBUG
+#ifndef RXDEBUG
+char rxi_tracename[80] = "\0Tracing not compiled in";
+#ifdef DUMPTRACE
+int
+main(int argc, char **argv)
+{
+    return 0;
+}
+#endif
+#else
 #include <string.h>
 #ifdef AFS_NT40_ENV
 #include <fcntl.h>
@@ -184,5 +193,4 @@ main(int argc, char **argv)
 }
 
 #endif /* DUMPTRACE */
-
-#endif
+#endif /* RXDEBUG */
index 5623710..e06e534 100644 (file)
@@ -12,7 +12,7 @@ INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 
-CFLAGS=${COMMON_CFLAGS} ${XCFLAGS} ${ARCHFLAGS} -DRXDEBUG
+CFLAGS=${COMMON_CFLAGS} ${XCFLAGS} ${ARCHFLAGS}
 
 LIBS=${TOP_LIBDIR}/librx.a ${TOP_LIBDIR}/liblwp.a ${TOP_LIBDIR}/libcmd.a \
               ${TOP_LIBDIR}/libsys.a ${TOP_LIBDIR}/libafsutil.a
index 202701b..81d1ae9 100644 (file)
@@ -18,7 +18,7 @@ HELPER_SPLINT=@HELPER_SPLINT@
 
 CFLAGS=${DBG} ${OPTMZ} -I${TOP_OBJDIR}/src/config -I. -I${TOP_INCDIR} \
        -I${TOP_INCDIR}/afs -I${TOP_OBJDIR} -I${TOP_OBJDIR}/fsint\
-        ${XCFLAGS} ${ARCHFLAGS} -DRXDEBUG -DNINTERFACE
+        ${XCFLAGS} ${ARCHFLAGS} -DNINTERFACE
 
 LDFLAGS = ${DBUG} ${XLDFLAGS} ${ARCHFLAGS}