]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
rx-magic-check-20060607
authorChaskiel M Grundman <cg2v@andrew.cmu.edu>
Wed, 7 Jun 2006 05:31:33 +0000 (05:31 +0000)
committerDerrick Brashear <shadow@dementia.org>
Wed, 7 Jun 2006 05:31:33 +0000 (05:31 +0000)
for pullup as /afs/andrew/usr18/cg2v/rx-magic-check.diff

src/rx/rx.c
src/rx/rx.h
src/rx/rx_null.c
src/rxkad/rxkad_client.c
src/rxkad/rxkad_server.c
src/util/Makefile.in
src/util/magic.h [new file with mode: 0644]

index f091b283a3465cede2c04ee46dba6498befd0ff9..7545b085dc44430dcd2e903d2923733bef13d709 100644 (file)
@@ -77,6 +77,7 @@ extern afs_int32 afs_termState;
 #include "sys/lock_def.h"
 #endif /* AFS_AIX41_ENV */
 # include "rxgen_consts.h"
+# include "afs/magic.h"
 #else /* KERNEL */
 # include <sys/types.h>
 # include <errno.h>
@@ -107,6 +108,7 @@ extern afs_int32 afs_termState;
 # include "rx_globals.h"
 # include "rx_trace.h"
 # include <afs/rxgen_consts.h>
+# include <afs/magic.h>
 #endif /* KERNEL */
 
 int (*registerProgram) () = 0;
@@ -834,6 +836,7 @@ rx_NewConnectionAddrs(struct sockaddr_storage *saddr, int *type, int *slen,
 
     SPLVAR;
 
+    osi_Assert(securityObject->magic == MAGIC_RXSECURITY);
     clock_NewTime();
     dpf(("rx_NewConnection(host %x, port %u, service %u, securityObject %x, serviceSecurityIndex %d)\n", ntohl(rx_ss2v4addr(saddr)), ntohs(rx_ss2pn(saddr)), sservice, securityObject, serviceSecurityIndex));
 
@@ -848,6 +851,7 @@ rx_NewConnectionAddrs(struct sockaddr_storage *saddr, int *type, int *slen,
     NETPRI;
     MUTEX_ENTER(&rx_connHashTable_lock);
     cid = (rx_nextCid += RX_MAXCALLS);
+    conn->magic = MAGIC_RXCONN;
     conn->type = RX_CLIENT_CONNECTION;
     conn->cid = cid;
     conn->epoch = rx_epoch;
@@ -911,11 +915,15 @@ int rxi_lowConnRefCount = 0;
 void
 rxi_CleanupConnection(struct rx_connection *conn)
 {
+    osi_Assert(conn->magic == MAGIC_RXCONN);
+
     /* Notify the service exporter, if requested, that this connection
      * is being destroyed */
     if (conn->type == RX_SERVER_CONNECTION && conn->service->destroyConnProc)
        (*conn->service->destroyConnProc) (conn);
 
+    conn->magic = MAGIC_RXCONN_FREE;
+
     /* Notify the security module that this connection is being destroyed */
     RXS_DestroyConnection(conn->securityObject, conn);
 
@@ -968,6 +976,8 @@ rxi_CleanupConnection(struct rx_connection *conn)
 void
 rxi_DestroyConnection(register struct rx_connection *conn)
 {
+    osi_Assert(conn->magic == MAGIC_RXCONN);
+
     MUTEX_ENTER(&rx_connHashTable_lock);
     rxi_DestroyConnectionNoLock(conn);
     /* conn should be at the head of the cleanup list */
@@ -1126,6 +1136,7 @@ rx_GetConnection(register struct rx_connection *conn)
 {
     SPLVAR;
 
+    osi_Assert(conn->magic == MAGIC_RXCONN);
     NETPRI;
     MUTEX_ENTER(&conn->conn_data_lock);
     conn->refCount++;
@@ -1150,6 +1161,7 @@ rx_NewCall(register struct rx_connection *conn)
     struct clock queueTime;
     SPLVAR;
 
+    osi_Assert(conn->magic == MAGIC_RXCONN);
     clock_NewTime();
     dpf(("rx_MakeCall(conn %x)\n", conn));
 
@@ -1421,6 +1433,7 @@ rx_NewService(u_short port, u_short serviceId, char *serviceName,
                }
            }
            service = tservice;
+           service->magic = MAGIC_RXSVC;
            service->socket = socket;
            service->servicePort = port;
            service->serviceId = serviceId;
@@ -1593,6 +1606,8 @@ rx_GetCall(int tno, struct rx_service *cur_service, osi_socket * socketp)
     struct rx_service *service = NULL;
     SPLVAR;
 
+    osi_Assert(cur_service->magic == MAGIC_RXSVC);
+
     MUTEX_ENTER(&freeSQEList_lock);
 
     if ((sq = rx_FreeSQEList)) {
@@ -1760,6 +1775,8 @@ rx_GetCall(int tno, struct rx_service *cur_service, osi_socket * socketp)
     struct rx_service *service = NULL;
     SPLVAR;
 
+    osi_Assert(cur_service->magic == MAGIC_RXSVC);
+
     NETPRI;
     MUTEX_ENTER(&freeSQEList_lock);
 
@@ -1936,6 +1953,7 @@ rx_EndCall(register struct rx_call *call, afs_int32 rc)
     register struct rx_service *service;
     afs_int32 error;
     SPLVAR;
+    osi_Assert(call->magic == MAGIC_RXCALL);
 
 
 
@@ -2170,6 +2188,8 @@ rxi_NewCall(register struct rx_connection *conn, register int channel)
     register struct rx_call *nxp;      /* Next call pointer, for queue_Scan */
 #endif /* AFS_GLOBAL_RXLOCK_KERNEL */
 
+    osi_Assert(conn->magic == MAGIC_RXCONN);
+
     /* Grab an existing call structure, or allocate a new one.
      * Existing call structures are assumed to have been left reset by
      * rxi_FreeCall */
@@ -2241,6 +2261,8 @@ rxi_NewCall(register struct rx_connection *conn, register int channel)
     if (*call->callNumber == 0)
        *call->callNumber = 1;
 
+    call->magic = MAGIC_RXCALL;
+    
     return call;
 }
 
@@ -2262,11 +2284,15 @@ rxi_FreeCall(register struct rx_call *call)
     register struct rx_connection *conn = call->conn;
 
 
+    osi_Assert(call->magic == MAGIC_RXCALL);
+
     if (call->state == RX_STATE_DALLY || call->state == RX_STATE_HOLD)
        (*call->callNumber)++;
     rxi_ResetCall(call, 0);
     call->conn->call[channel] = (struct rx_call *)0;
 
+    call->magic = MAGIC_RXCALL_FREE;
+
     MUTEX_ENTER(&rx_freeCallQueue_lock);
     SET_CALL_QUEUE_LOCK(call, &rx_freeCallQueue_lock);
 #ifdef AFS_GLOBAL_RXLOCK_KERNEL
@@ -2367,6 +2393,7 @@ rxi_FindPeer(struct sockaddr_storage *saddr, int slen, int stype,
     if (!pp) {
        if (create) {
            pp = rxi_AllocPeer();       /* This bzero's *pp */
+           pp->magic = MAGIC_RXPEER;
            memcpy(&pp->saddr, saddr, slen);
            pp->saddrlen = slen;
            pp->socktype = stype;
@@ -2421,8 +2448,10 @@ rxi_FindPeer(struct sockaddr_storage *saddr, int slen, int stype,
     if (pp && create) {
        pp->refCount++;
     }
-    if (origPeer)
+    if (origPeer) {
+       osi_Assert(origPeer->magic == MAGIC_RXPEER);
        origPeer->refCount--;
+    }
     MUTEX_EXIT(&rx_peerHashTable_lock);
     return pp;
 }
@@ -2501,6 +2530,7 @@ rxi_FindConnection(osi_socket socket, struct sockaddr_storage *saddr,
        CV_INIT(&conn->conn_call_cv, "conn call cv", CV_DEFAULT, 0);
        conn->next = rx_connHashTable[hashindex];
        rx_connHashTable[hashindex] = conn;
+       conn->magic = MAGIC_RXCONN;
        conn->peer = rxi_FindPeer(saddr, slen, socktype, 0, 1);
        conn->type = RX_SERVER_CONNECTION;
        conn->lastSendTime = clock_Sec();       /* don't GC immediately */
@@ -6016,6 +6046,7 @@ rxi_ReapConnections(void)
             peer_ptr++) {
            struct rx_peer *peer, *next, *prev;
            for (prev = peer = *peer_ptr; peer; peer = next) {
+               osi_Assert(peer->magic == MAGIC_RXPEER);
                next = peer->next;
                code = MUTEX_TRYENTER(&peer->peer_lock);
                if ((code) && (peer->refCount == 0)
@@ -6095,6 +6126,8 @@ rxi_ReapConnections(void)
 int
 rxs_Release(struct rx_securityClass *aobj)
 {
+    osi_Assert(aobj->magic == MAGIC_RXSECURITY);
+
     return RXS_Close(aobj);
 }
 
@@ -6942,7 +6975,9 @@ void
 rx_SetSpecific(struct rx_connection *conn, int key, void *ptr)
 {
     int i;
+    osi_Assert(conn->magic == MAGIC_RXCONN);
     MUTEX_ENTER(&conn->conn_data_lock);
+    osi_Assert(conn->magic == MAGIC_RXCONN);
     if (!conn->specific) {
        conn->specific = (void **)malloc((key + 1) * sizeof(void *));
        for (i = 0; i < key; i++)
@@ -6968,7 +7003,9 @@ void *
 rx_GetSpecific(struct rx_connection *conn, int key)
 {
     void *ptr;
+    osi_Assert(conn->magic == MAGIC_RXCONN);
     MUTEX_ENTER(&conn->conn_data_lock);
+    osi_Assert(conn->magic == MAGIC_RXCONN);
     if (key >= conn->nSpecific)
        ptr = NULL;
     else
index 333b5fcb3825e04254d8495a5d6301d886cb35cc..f4dd0b2ca8473b15a5ea50979d7d95651086279a 100644 (file)
@@ -229,10 +229,12 @@ returned with an error code of RX_CALL_DEAD ( transient error ) */
    limited multiple asynchronous conversations. */
 #ifdef KDUMP_RX_LOCK
 struct rx_connection_rx_lock {
+    int magic;
     struct rx_connection_rx_lock *next;        /*  on hash chain _or_ free list */
     struct rx_peer_rx_lock *peer;
 #else
 struct rx_connection {
+    int magic;
     struct rx_connection *next;        /*  on hash chain _or_ free list */
     struct rx_peer *peer;
 #endif
@@ -306,6 +308,7 @@ struct rx_connection {
  * requests. */
 
 struct rx_service {
+    int magic;
     u_short serviceId;         /* Service number */
     u_short servicePort;       /* UDP port for this service */
     char *serviceName;         /* Name of the service */
@@ -365,9 +368,11 @@ struct rx_serverQueueEntry {
 /* A peer refers to a peer process, specified by a (host,port) pair.  There may be more than one peer on a given host. */
 #ifdef KDUMP_RX_LOCK
 struct rx_peer_rx_lock {
+    int magic;
     struct rx_peer_rx_lock *next;      /* Next in hash conflict or free list */
 #else
 struct rx_peer {
+    int magic;
     struct rx_peer *next;      /* Next in hash conflict or free list */
 #endif
 #ifdef RX_ENABLE_LOCKS
@@ -453,6 +458,7 @@ struct rx_call_rx_lock {
 #else
 struct rx_call {
 #endif
+    int magic;
     struct rx_queue queue_item_header; /* Call can be on various queues (one-at-a-time) */
     struct rx_queue tq;                /* Transmit packet queue */
     struct rx_queue rq;                /* Receive packet queue */
@@ -719,6 +725,7 @@ struct rx_securityObjectStats {
  * provide routines to create these objects.  Rx provides a basic routine to
  * allocate one of these objects; this routine must be called by the class. */
 struct rx_securityClass {
+    int magic;
     struct rx_securityOps {
        int (*op_Close) (struct rx_securityClass * aobj);
        int (*op_NewConnection) (struct rx_securityClass * aobj,
index d8ff2c119e08abad8022f9c04bd769bbf1c0ab22..7f888580b6bffc5337cc12bf51ec8fa5512d3d07 100644 (file)
@@ -24,14 +24,16 @@ RCSID
 #include "afs/sysincludes.h"
 #endif /* !UKERNEL */
 #include "rx/rx.h"
+#include "afs/magic.h"
 #else /* KERNEL */
 #include "rx.h"
+#include <afs/magic.h>
 #endif /* KERNEL */
 
 /* The null security object.  No authentication, no nothing. */
 
 static struct rx_securityOps null_ops;
-static struct rx_securityClass null_object = { &null_ops, 0, 0 };
+static struct rx_securityClass null_object = { MAGIC_RXSECURITY, &null_ops, 0, 0 };
 
 struct rx_securityClass *
 rxnull_NewServerSecurityObject(void)
index 1f83e2c17bbabfa57c4111448b1dca0e67897c6b..547db7295fa309c474c38b6f56e394b94220b8cd 100644 (file)
@@ -43,6 +43,7 @@ RCSID
 #include "rx/xdr.h"
 #endif
 #include "rx/rx.h"
+#include "afs/magic.h"
 #else /* ! KERNEL */
 #include <afs/stds.h>
 #include <sys/types.h>
@@ -64,6 +65,7 @@ RCSID
 #ifdef AFS_PTHREAD_ENV
 #include "rx/rxkad.h"
 #endif /* AFS_PTHREAD_ENV */
+#include <afs/magic.h>
 #endif /* KERNEL */
 
 #include <des/stats.h>
@@ -186,6 +188,7 @@ rxkad_NewClientSecurityObject(rxkad_level level,
     size = sizeof(struct rx_securityClass);
     tsc = (struct rx_securityClass *)rxi_Alloc(size);
     memset((void *)tsc, 0, size);
+    tsc->magic = MAGIC_RXSECURITY;
     tsc->refCount = 1;         /* caller gets one for free */
     tsc->ops = &rxkad_client_ops;
 
index 92097da21b8e066d0d1df68c6a0ef9b0bf7c295a..f47c4f6281406c0e7c371428cbe45e4ee8793b28 100644 (file)
@@ -38,6 +38,7 @@ RCSID
 #include <rx/rx.h>
 #include <rx/xdr.h>
 #include <des.h>
+#include <afs/magic.h>
 #include <afs/afsutil.h>
 #include <des/stats.h>
 #include "private_data.h"
@@ -150,6 +151,7 @@ rxkad_NewServerSecurityObject(rxkad_level level, char *get_key_rock,
     size = sizeof(struct rx_securityClass);
     tsc = (struct rx_securityClass *)osi_Alloc(size);
     memset(tsc, 0, size);
+    tsc->magic = MAGIC_RXSECURITY;
     tsc->refCount = 1;         /* caller has one reference */
     tsc->ops = &rxkad_server_ops;
     size = sizeof(struct rxkad_sprivate);
index ccf3446695eaeb9109eae8e6b0355673bf0e66dd..12341afc1eab83a3f15e4edc3fcbb0fa4acee3c6 100644 (file)
@@ -33,6 +33,7 @@ includes = \
        ${TOP_INCDIR}/afs/afs_atomlist.h \
        ${TOP_INCDIR}/afs/afs_lhash.h \
        ${TOP_INCDIR}/afs/softsig.h \
+       ${TOP_INCDIR}/afs/magic.h \
        ${TOP_INCDIR}/potpourri.h 
 
 all: ${includes} \
@@ -166,6 +167,7 @@ install: \
        ${DESTDIR}${includedir}/afs/afs_atomlist.h \
        ${DESTDIR}${includedir}/afs/afs_lhash.h \
        ${DESTDIR}${includedir}/afs/softsig.h \
+       ${DESTDIR}${includedir}/afs/magic.h \
        ${DESTDIR}${includedir}/potpourri.h \
        ${DESTDIR}${libdir}/afs/util.a \
        ${DESTDIR}${libdir}/afs/libafsutil.a \
@@ -219,6 +221,9 @@ ${TOP_INCDIR}/afs/afs_lhash.h: ${srcdir}/afs_lhash.h
 ${TOP_INCDIR}/afs/softsig.h: ${srcdir}/softsig.h
        ${INSTALL} $? $@
 
+${TOP_INCDIR}/afs/magic.h: ${srcdir}/magic.h
+       ${INSTALL} $? $@
+
 ${TOP_INCDIR}/potpourri.h: ${srcdir}/potpourri.h
        ${INSTALL} $? $@
 
diff --git a/src/util/magic.h b/src/util/magic.h
new file mode 100644 (file)
index 0000000..821f658
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * 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
+ */
+
+#ifndef AFS_MAGIC_H
+#define AFS_MAGIC_H
+typedef enum afs_structmagic_t {
+       MAGIC_RXCONN = 0xFF010001,
+       MAGIC_RXCALL = 0xFF010002,
+       MAGIC_RXPEER = 0xFF010003,
+       MAGIC_RXSVC = 0xFF010004,
+       MAGIC_RXSECURITY = 0xFF010005,
+       MAGIC_UBIK = 0xFF010101,
+       MAGIC_VICED_HOST = 0xFF010201,
+       MAGIC_VICED_CLIENT = 0xFF010202,
+       MAGIC_RXCONN_FREE = 0xFF020001,
+       MAGIC_RXCALL_FREE = 0xFF020002,
+       MAGIC_RXPEER_FREE = 0xFF010003,
+       /*MAGIC_RXSVC_FREE = 0xFF020004,*/
+       MAGIC_RXSEC_FREE = 0xFF020005,
+       MAGIC_UBIK_FREE = 0xFF020101,
+       MAGIC_VICED_HOST_FREE = 0xFF020101,
+       MAGIC_VICED_CLIENT_FREE = 0xFF020102
+} afs_structmagic;
+#endif