]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
DEVEL15-rx-make-rxdebug-optional-20090113
authorJeffrey Altman <jaltman@your-file-system.com>
Tue, 13 Jan 2009 16:33:30 +0000 (16:33 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Tue, 13 Jan 2009 16:33:30 +0000 (16:33 +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.

(cherry picked from commit f1a13e15625afa324ffc6614eea432dcc89bf768)

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 fc3a920416d92e4bb454228cd2dfe25337d155b0..dde219e7750810d633216af8f9204079d527bf31 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 9b67145c4c2555df035b589da537303926270fb6..382ea7b51b505c72af30551f308e4901f63d8a46 100644 (file)
@@ -8,7 +8,7 @@
 srcdir=@srcdir@
 include @TOP_OBJDIR@/src/config/Makefile.config
 
-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 c389d11202b5b25c4efc5e6f7841b317c6aaba52..b9fdbc15b977dda750174a9d59db3cb93601a54a 100644 (file)
@@ -2787,9 +2787,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);
@@ -2851,9 +2852,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);
@@ -6373,10 +6375,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;
@@ -6399,27 +6401,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];
@@ -6453,8 +6461,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
@@ -6465,6 +6475,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)) {
@@ -6539,7 +6550,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 */
@@ -6569,8 +6582,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
@@ -6583,6 +6597,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,
@@ -6688,15 +6703,19 @@ 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)
 {
+#ifndef RXDEBUG
+     afs_int32 rc = -1;
+#else
+    afs_int32 rc = 0;
     struct rx_debugIn in;
     afs_int32 *lp = (afs_int32 *) stat;
-    afs_int32 rc = 0;
 
     *supportedValues = 0;
     in.type = htonl(RX_DEBUGI_GETSTATS);
@@ -6747,7 +6766,7 @@ rx_GetServerDebug(osi_socket socket, afs_uint32 remoteAddr,
         stat->nWaited = ntohl(stat->nWaited);
         stat->nPackets = ntohl(stat->nPackets);
     }
-
+#endif
     return rc;
 }
 
@@ -6756,10 +6775,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;
     afs_int32 *lp = (afs_int32 *) stat;
     int i;
-    afs_int32 rc = 0;
 
     /*
      * supportedValues is currently unused, but added to allow future
@@ -6784,7 +6806,7 @@ rx_GetServerStats(osi_socket socket, afs_uint32 remoteAddr,
            *lp = ntohl(*lp);
        }
     }
-
+#endif
     return rc;
 }
 
@@ -6793,10 +6815,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
@@ -6806,8 +6832,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;
 
     /*
@@ -6879,7 +6908,7 @@ rx_GetServerConnections(osi_socket socket, afs_uint32 remoteAddr,
        conn->epoch = ntohl(conn->epoch);
        conn->natMTU = ntohl(conn->natMTU);
     }
-
+#endif
     return rc;
 }
 
@@ -6889,8 +6918,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
@@ -6941,10 +6973,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 91caabe33f9384b5219e30efd15b76ba626f0a91..19decc3b25f78975e9d7a8f4f210c8cc1bdbdc3c 100644 (file)
@@ -545,11 +545,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;
@@ -564,6 +566,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
 /*
@@ -579,10 +584,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 79c6274217734fbaceefd35f08784025e2713a3a..c35ab218bce53f685528f91c97f234e93b328033 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>
@@ -183,5 +192,4 @@ main(int argc, char **argv)
 }
 
 #endif /* DUMPTRACE */
-
-#endif
+#endif /* RXDEBUG */
index 0a768566aa243a858a01f7a3d6320b8608a58a87..f2da9452b2906186ceed345beb459449eabf3df7 100644 (file)
@@ -8,7 +8,7 @@
 srcdir=@srcdir@
 include @TOP_OBJDIR@/src/config/Makefile.config
 
-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 6de76052eb6c703c487e57dcfac053310f3d3a90..963b8698ba6cb98e09f9ed01902b1c277c590e83 100644 (file)
@@ -14,7 +14,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}