From f1a13e15625afa324ffc6614eea432dcc89bf768 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Tue, 13 Jan 2009 16:19:11 +0000 Subject: [PATCH] rx-make-rxdebug-optional-20090113 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 | 1 + src/rx/Makefile.in | 2 +- src/rx/rx.c | 63 ++++++++++++++++++++++++++++++----------- src/rx/rx_globals.h | 11 +++---- src/rx/rx_trace.c | 14 +++++++-- src/rxdebug/Makefile.in | 2 +- src/viced/Makefile.in | 2 +- 7 files changed, 68 insertions(+), 27 deletions(-) diff --git a/src/cf/osconf.m4 b/src/cf/osconf.m4 index 67cc10179..30d7e0a57 100644 --- a/src/cf/osconf.m4 +++ b/src/cf/osconf.m4 @@ -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" diff --git a/src/rx/Makefile.in b/src/rx/Makefile.in index 140d39ee3..5aad9bc7d 100644 --- a/src/rx/Makefile.in +++ b/src/rx/Makefile.in @@ -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). diff --git a/src/rx/rx.c b/src/rx/rx.c index 1a15c8326..11b02b816 100644 --- a/src/rx/rx.c +++ b/src/rx/rx.c @@ -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) diff --git a/src/rx/rx_globals.h b/src/rx/rx_globals.h index 91e58f576..5e07a2baf 100644 --- a/src/rx/rx_globals.h +++ b/src/rx/rx_globals.h @@ -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 diff --git a/src/rx/rx_trace.c b/src/rx/rx_trace.c index c61adf050..cfe581b0e 100644 --- a/src/rx/rx_trace.c +++ b/src/rx/rx_trace.c @@ -13,7 +13,16 @@ 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 #ifdef AFS_NT40_ENV #include @@ -184,5 +193,4 @@ main(int argc, char **argv) } #endif /* DUMPTRACE */ - -#endif +#endif /* RXDEBUG */ diff --git a/src/rxdebug/Makefile.in b/src/rxdebug/Makefile.in index 562371025..e06e534a3 100644 --- a/src/rxdebug/Makefile.in +++ b/src/rxdebug/Makefile.in @@ -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 diff --git a/src/viced/Makefile.in b/src/viced/Makefile.in index 202701b0f..81d1ae98d 100644 --- a/src/viced/Makefile.in +++ b/src/viced/Makefile.in @@ -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} -- 2.39.5