[OpenAFS-devel] [UNTESTED PATCH against CVS MAIN] consolidate rxdebug.c

Christopher Allen Wing wingc@engin.umich.edu
Wed, 21 Jun 2006 19:08:18 -0400 (EDT)


Here is the same patch, but against CVS MAIN instead of 1.4.x.

This folds the following deltas against rx/rxdebug.c into 
rxdebug/rxdebug.c:

 	jbeuhler-flexelint-bugs-found-20031128
 	rx-stats-calls-waited-ever-20040917
 	rxdebug-use-afs-ntoa-r-20041202
 	rxdebug-withWaited-20050125
 	rxdebug-unsigned-20040403
 	windows-64-bit-type-safety-20051105

adds the missing line:
 	#include <afs/afsutil.h>

and modifies the NTMakefiles so that rxdebug/rxdebug.c is built instead of 
rx/rxdebug.c.


Comments?


-Chris Wing
wingc@engin.umich.edu



diff -uNr openafs-20060621.orig/src/NTMakefile openafs-20060621/src/NTMakefile
--- openafs-20060621.orig/src/NTMakefile	2006-02-14 09:03:17.000000000 -0500
+++ openafs-20060621/src/NTMakefile	2006-06-21 18:34:20.000000000 -0400
@@ -137,6 +137,13 @@
  	$(NTMAKE)
  	$(CD) ..\..

+rxdebug: rx
+     echo ***** $@
+	$(DOCD) $(SRC)\$@
+	$(CD) $(SRC)\$@
+	$(NTMAKE)
+	$(CD) ..\..
+
  rxstat: rx
       echo ***** $@
  	$(DOCD) $(SRC)\$@
diff -uNr openafs-20060621.orig/src/rx/NTMakefile openafs-20060621/src/rx/NTMakefile
--- openafs-20060621.orig/src/rx/NTMakefile	2005-11-20 20:57:20.000000000 -0500
+++ openafs-20060621/src/rx/NTMakefile	2006-06-21 18:36:11.000000000 -0400
@@ -70,29 +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
-        $(_VC_MANIFEST_EMBED_EXE)
-	$(EXEPREP)
-
-install: $(LIBFILE) $(INCFILES) $(RXDEBUG)
+install: $(LIBFILE) $(INCFILES)

  install9x: $(LIBFILE) $(INCFILES)

diff -uNr openafs-20060621.orig/src/rxdebug/NTMakefile openafs-20060621/src/rxdebug/NTMakefile
--- openafs-20060621.orig/src/rxdebug/NTMakefile	1969-12-31 19:00:00.000000000 -0500
+++ openafs-20060621/src/rxdebug/NTMakefile	2006-06-21 18:47:00.000000000 -0400
@@ -0,0 +1,48 @@
+# 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
+	$(_VC_MANIFEST_EMBED_EXE)
+	$(EXEPREP)
+
+install: $(RXDEBUG)
+
+mkdir:
+ 
diff -uNr openafs-20060621.orig/src/rxdebug/rxdebug.c openafs-20060621/src/rxdebug/rxdebug.c
--- openafs-20060621.orig/src/rxdebug/rxdebug.c	2004-12-07 00:07:06.000000000 -0500
+++ openafs-20060621/src/rxdebug/rxdebug.c	2006-06-21 18:41:24.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>

@@ -90,7 +90,7 @@
       struct cmd_syndesc *as;
  {
      register int i;
-    int s;
+    osi_socket s;
      int j;
      struct sockaddr_in taddr;
      afs_int32 host;
@@ -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;
@@ -585,6 +594,9 @@
  {
      struct cmd_syndesc *ts;

+#ifdef RXDEBUG
+    rxi_DebugInit();
+#endif
  #ifdef AFS_NT40_ENV
      if (afs_winsockInit() < 0) {
  	printf("%s: Couldn't initialize winsock. Exiting...\n", argv[0]);
diff -uNr openafs-20060621.orig/src/rxdebug/rxdebug.rc openafs-20060621/src/rxdebug/rxdebug.rc
--- openafs-20060621.orig/src/rxdebug/rxdebug.rc	2003-06-19 15:02:45.000000000 -0400
+++ openafs-20060621/src/rxdebug/rxdebug.rc	2006-06-21 18:34:20.000000000 -0400
@@ -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"