[OpenAFS-devel] [UNTESTED PATCH] consolidate multiple rxdebug.c, add missing include
Christopher Allen Wing
wingc@engin.umich.edu
Wed, 21 Jun 2006 19:04:06 -0400 (EDT)
When rx/rxdebug.c was updated to use afs_inet_ntoa_r() in this CVS delta:
rxdebug-use-afs-ntoa-r-20041202
the necessary include was not added:
#include <afs/afsutil.h>
However, rx/rxdebug.c is only built on Windows, while rxdebug/rxdebug.c is
built on Unix. Here is a patch against 1.4.x which consolidates the two
into rxdebug/rxdebug.c. However, I do not have a Windows build
environment at the moment so I can't test it on Windows.
Does this look correct? (anybody with the ability to build on Windows)
Specifically, this folds the following CVS deltas against rx/rxdebug.c
into rxdebug/rxdebug.c:
jbeuhler-flexelint-bugs-found-20031128
rx-stats-calls-waited-ever-20040917
(via STABLE14-resync-20041018)
STABLE14-rxdebug-use-afs-ntoa-r-20041202
STABLE14-rxdebug-withWaited-20050125
STABLE14-rxdebug-unsigned-20040403
and then it modifies src/NTMakefile, src/rx/NTMakefile so that
rxdebug/rxdebug.c gets built and installed instead of rx/rxdebug.c. Or,
more specifically, that is my intention. I don't have a Windows build
environment to see if that actually happens.
I also adding the missing:
#include <afs/afsutil.h>
which is needed to use afs_inet_ntoa_r().
It's tested on Unix and seems to work. The idea would be to delete
rx/rxdebug.c and rx/rxdebug.rc after applying this patch.
Comments? Anybody with a Windows compiler who can test?
-Chris Wing
wingc@engin.umich.edu
diff -uNr openafs-1.4.2-beta1.orig/src/NTMakefile openafs-1.4.2-beta1/src/NTMakefile
--- openafs-1.4.2-beta1.orig/src/NTMakefile 2005-05-18 18:57:06.000000000 -0400
+++ openafs-1.4.2-beta1/src/NTMakefile 2006-06-21 18:04:40.000000000 -0400
@@ -134,6 +134,13 @@
$(NTMAKE)
$(CD) ..\..
+rxdebug: rx
+ echo ***** $@
+ $(DOCD) $(SRC)\$@
+ $(CD) $(SRC)\$@
+ $(NTMAKE)
+ $(CD) ..\..
+
rxstat: rx
echo ***** $@
$(DOCD) $(SRC)\$@
diff -uNr openafs-1.4.2-beta1.orig/src/rx/NTMakefile openafs-1.4.2-beta1/src/rx/NTMakefile
--- openafs-1.4.2-beta1.orig/src/rx/NTMakefile 2005-03-11 02:03:30.000000000 -0500
+++ openafs-1.4.2-beta1/src/rx/NTMakefile 2006-06-21 18:11:44.000000000 -0400
@@ -70,28 +70,7 @@
# Not yet
#rxdumptrace.exe: rx_trace.c
-# build rxdebug.
-RXDEBUG = $(DESTDIR)\etc\rxdebug.exe
-RXDOBJS = $(OUT)\rxdebug.obj \
- $(OUT)\rxdebug.res
-
-LIBDIR = $(DESTDIR)\lib
-RXDLIBS = $(LIBDIR)\afs\afscmd.lib \
- $(LIBDIR)\afsrx.lib \
- $(LIBDIR)\afslwp.lib \
- $(LIBDIR)\afs\afsutil.lib \
- $(LIBDIR)\afs\afsreg.lib
-
-$(OUT)\rxdebug.res: rxdebug.rc $(VERSFILE).h
- $(RC) /Fo$*.RES $(*F).rc
-
-$(OUT)\rxdebug.obj: rxdebug.c
-
-$(RXDEBUG): $(RXDOBJS) $(RXDLIBS)
- $(EXECONLINK) iphlpapi.lib
- $(EXEPREP)
-
-install: $(LIBFILE) $(INCFILES) $(RXDEBUG)
+install: $(LIBFILE) $(INCFILES)
install9x: $(LIBFILE) $(INCFILES)
diff -uNr openafs-1.4.2-beta1.orig/src/rxdebug/NTMakefile openafs-1.4.2-beta1/src/rxdebug/NTMakefile
--- openafs-1.4.2-beta1.orig/src/rxdebug/NTMakefile 1969-12-31 19:00:00.000000000 -0500
+++ openafs-1.4.2-beta1/src/rxdebug/NTMakefile 2006-06-21 18:47:30.000000000 -0400
@@ -0,0 +1,47 @@
+# Copyright 2000, International Business Machines Corporation and others.
+# All Rights Reserved.
+#
+# This software has been released under the terms of the IBM Public
+# License. For details, see the LICENSE file in the top-level source
+# directory or online at http://www.openafs.org/dl/license10.html
+
+RELDIR=rxdebug
+!include ..\config\NTMakefile.$(SYS_NAME)
+
+# RX has different strings for it's version number.
+VERSFILE=..\rx\RX_component_version_number
+CML_PREFIX=rx_
+
+!include ..\config\NTMakefile.version
+
+{.}.c{$(OUT)}.obj:
+ $(C2OBJ) $<
+
+# Additional debugging flag for RX.
+AFSDEV_AUXCDEFINES = -DRXDEBUG
+
+# build rxdebug.
+RXDEBUG = $(DESTDIR)\etc\rxdebug.exe
+RXDOBJS = $(OUT)\rxdebug.obj \
+ $(OUT)\rxdebug.res
+
+LIBDIR = $(DESTDIR)\lib
+RXDLIBS = $(LIBDIR)\afs\afscmd.lib \
+ $(LIBDIR)\afsrx.lib \
+ $(LIBDIR)\afslwp.lib \
+ $(LIBDIR)\afs\afsutil.lib \
+ $(LIBDIR)\afs\afsreg.lib
+
+$(OUT)\rxdebug.res: rxdebug.rc $(VERSFILE).h
+ $(RC) /Fo$*.RES $(*F).rc
+
+$(OUT)\rxdebug.obj: rxdebug.c
+
+$(RXDEBUG): $(RXDOBJS) $(RXDLIBS)
+ $(EXECONLINK) iphlpapi.lib
+ $(EXEPREP)
+
+install: $(RXDEBUG)
+
+mkdir:
+
diff -uNr openafs-1.4.2-beta1.orig/src/rxdebug/rxdebug.c openafs-1.4.2-beta1/src/rxdebug/rxdebug.c
--- openafs-1.4.2-beta1.orig/src/rxdebug/rxdebug.c 2004-12-07 01:17:15.000000000 -0500
+++ openafs-1.4.2-beta1/src/rxdebug/rxdebug.c 2006-06-21 18:24:27.000000000 -0400
@@ -21,7 +21,6 @@
#include <sys/socket.h>
#include <sys/file.h>
#include <netdb.h>
-#include <arpa/inet.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
@@ -42,6 +41,7 @@
#include <sys/stat.h>
#include <afs/stds.h>
#include <afs/cmd.h>
+#include <afs/afsutil.h>
#include <stdio.h>
@@ -112,9 +112,11 @@
int withRxStats;
int withWaiters;
int withIdleThreads;
+ int withWaited;
int withPeers;
struct rx_debugStats tstats;
char *portName, *hostName;
+ char hoststr[20];
struct rx_debugConn tconn;
short noConns;
short showPeers;
@@ -217,7 +219,8 @@
dallyCounter = 0;
hostAddr.s_addr = host;
- printf("Trying %s (port %d):\n", inet_ntoa(hostAddr), ntohs(port));
+ afs_inet_ntoa_r(hostAddr.s_addr, hoststr);
+ printf("Trying %s (port %d):\n", hoststr, ntohs(port));
s = socket(AF_INET, SOCK_DGRAM, 0);
taddr.sin_family = AF_INET;
taddr.sin_port = 0;
@@ -258,6 +261,7 @@
withRxStats = (supportedDebugValues & RX_SERVER_DEBUG_RX_STATS);
withWaiters = (supportedDebugValues & RX_SERVER_DEBUG_WAITER_CNT);
withIdleThreads = (supportedDebugValues & RX_SERVER_DEBUG_IDLE_THREADS);
+ withWaited = (supportedDebugValues & RX_SERVER_DEBUG_WAITED_CNT);
withPeers = (supportedDebugValues & RX_SERVER_DEBUG_ALL_PEER);
printf("Free packets: %d, packet reclaims: %d, calls: %d, used FDs: %d\n",
@@ -270,6 +274,8 @@
printf("%d calls waiting for a thread\n", tstats.nWaiting);
if (withIdleThreads)
printf("%d threads are idle\n", tstats.idleThreads);
+ if (withWaited)
+ printf("%d calls have waited for a thread\n", tstats.nWaited);
if (rxstats) {
if (!withRxStats) {
@@ -323,8 +329,9 @@
}
if (onlyHost != -1) {
hostAddr.s_addr = onlyHost;
+ afs_inet_ntoa_r(hostAddr.s_addr, hoststr);
printf("Showing only connections from host %s\n",
- inet_ntoa(hostAddr));
+ hoststr);
}
if (onlyPort != -1)
printf("Showing only connections on port %u\n", ntohs(onlyPort));
@@ -338,7 +345,7 @@
printf("getconn call failed with code %d\n", code);
break;
}
- if (tconn.cid == 0xffffffff) {
+ if (tconn.cid == (afs_int32) 0xffffffff) {
printf("Done.\n");
break;
}
@@ -383,7 +390,8 @@
/* now display the connection */
hostAddr.s_addr = tconn.host;
- printf("Connection from host %s, port %hu, ", inet_ntoa(hostAddr),
+ afs_inet_ntoa_r(hostAddr.s_addr, hoststr);
+ printf("Connection from host %s, port %hu, ", hoststr,
ntohs(tconn.port));
if (tconn.epoch)
printf("Cuid %x/%x", tconn.epoch, tconn.cid);
@@ -456,10 +464,10 @@
((afs_uint32) tconn.secStats.expires -
time(0)) / 3600.0);
if (!(flags & 1)) {
- printf("\n Received %d bytes in %d packets\n",
+ printf("\n Received %u bytes in %u packets\n",
tconn.secStats.bytesReceived,
tconn.secStats.packetsReceived);
- printf(" Sent %d bytes in %d packets\n",
+ printf(" Sent %u bytes in %u packets\n",
tconn.secStats.bytesSent,
tconn.secStats.packetsSent);
} else
@@ -545,19 +553,20 @@
/* now display the peer */
hostAddr.s_addr = tpeer.host;
- printf("Peer at host %s, port %hu\n", inet_ntoa(hostAddr),
+ afs_inet_ntoa_r(hostAddr.s_addr, hoststr);
+ printf("Peer at host %s, port %hu\n", hoststr,
ntohs(tpeer.port));
printf("\tifMTU %hu\tnatMTU %hu\tmaxMTU %hu\n", tpeer.ifMTU,
tpeer.natMTU, tpeer.maxMTU);
- printf("\tpackets sent %d\tpacket resends %d\n", tpeer.nSent,
+ printf("\tpackets sent %u\tpacket resends %u\n", tpeer.nSent,
tpeer.reSends);
- printf("\tbytes sent high %d low %d\n", tpeer.bytesSent.high,
+ printf("\tbytes sent high %u low %u\n", tpeer.bytesSent.high,
tpeer.bytesSent.low);
- printf("\tbytes received high %d low %d\n",
+ printf("\tbytes received high %u low %u\n",
tpeer.bytesReceived.high, tpeer.bytesReceived.low);
- printf("\trtt %d msec, rtt_dev %d msec\n", tpeer.rtt >> 3,
+ printf("\trtt %u msec, rtt_dev %u msec\n", tpeer.rtt >> 3,
tpeer.rtt_dev >> 2);
- printf("\ttimeout %d.%03d sec\n", tpeer.timeout.sec,
+ printf("\ttimeout %u.%03u sec\n", tpeer.timeout.sec,
tpeer.timeout.usec / 1000);
if (!showLong)
continue;
diff -uNr openafs-1.4.2-beta1.orig/src/rxdebug/rxdebug.rc openafs-1.4.2-beta1/src/rxdebug/rxdebug.rc
--- openafs-1.4.2-beta1.orig/src/rxdebug/rxdebug.rc 2003-06-19 15:02:45.000000000 -0400
+++ openafs-1.4.2-beta1/src/rxdebug/rxdebug.rc 2003-11-22 23:53:37.000000000 -0500
@@ -13,5 +13,5 @@
#define AFS_VERINFO_NAME "rxdebug"
#define AFS_VERINFO_FILENAME "rxdebug.exe"
-#include "AFS_component_version_number.h"
+#include "RX_component_version_number.h"
#include "..\config\NTVersioninfo.rc"