#endif
{
int err;
- RWLOCK_INIT(&afs_xosi, "afs_xosi");
+ AFS_RWLOCK_INIT(&afs_xosi, "afs_xosi");
#if !defined(AFS_LINUX24_ENV)
/* obtain PAGE_OFFSET value */
int i;
nfssrv_list = 0;
- RWLOCK_INIT(&afs_xnfssrv, "afs_xnfssrv");
+ AFS_RWLOCK_INIT(&afs_xnfssrv, "afs_xnfssrv");
if (authtab && !IS_ERR(authtab))
afs_authtab = authtab;
{
struct xfreelist *xp, *nxp;
- RWLOCK_INIT(&afs_xaxs, "afs_xaxs");
+ AFS_RWLOCK_INIT(&afs_xaxs, "afs_xaxs");
xp = xfreemallocs;
while (xp) {
nxp = xp->next;
#endif
tb->hashIndex = 0;
tb->dirty = 0;
- RWLOCK_INIT(&tb->lock, "buffer lock");
+ AFS_RWLOCK_INIT(&tb->lock, "buffer lock");
}
return;
}
tc->fsport = AFS_FSPORT;
tc->vlport = AFS_VLPORT;
AFS_MD5_String(tc->cellHandle, tc->cellName, strlen(tc->cellName));
- RWLOCK_INIT(&tc->lock, "cell lock");
+ AFS_RWLOCK_INIT(&tc->lock, "cell lock");
newc = 1;
aflags |= CNoSUID;
}
void
afs_CellInit()
{
- RWLOCK_INIT(&afs_xcell, "afs_xcell");
+ AFS_RWLOCK_INIT(&afs_xcell, "afs_xcell");
#ifdef AFS_AFSDB_ENV
- RWLOCK_INIT(&afsdb_client_lock, "afsdb_client_lock");
- RWLOCK_INIT(&afsdb_req_lock, "afsdb_req_lock");
+ AFS_RWLOCK_INIT(&afsdb_client_lock, "afsdb_client_lock");
+ AFS_RWLOCK_INIT(&afsdb_req_lock, "afsdb_req_lock");
#endif
QInit(&CellLRU);
struct afs_q *cq, *tq;
struct cell *tc;
- RWLOCK_INIT(&afs_xcell, "afs_xcell");
+ AFS_RWLOCK_INIT(&afs_xcell, "afs_xcell");
for (cq = CellLRU.next; cq != &CellLRU; cq = tq) {
tc = QTOC(cq);
osi_Assert(0 == NBObtainWriteLock(&tdc->tlock, 676));
}
- RWLOCK_INIT(&tdc->lock, "dcache lock");
- RWLOCK_INIT(&tdc->tlock, "dcache tlock");
- RWLOCK_INIT(&tdc->mflock, "dcache flock");
+ AFS_RWLOCK_INIT(&tdc->lock, "dcache lock");
+ AFS_RWLOCK_INIT(&tdc->tlock, "dcache tlock");
+ AFS_RWLOCK_INIT(&tdc->mflock, "dcache flock");
ObtainReadLock(&tdc->tlock);
if (tmpdc == NULL)
osi_Assert(0 == NBObtainWriteLock(&tdc->tlock, 676));
}
- RWLOCK_INIT(&tdc->lock, "dcache lock");
- RWLOCK_INIT(&tdc->tlock, "dcache tlock");
- RWLOCK_INIT(&tdc->mflock, "dcache flock");
+ AFS_RWLOCK_INIT(&tdc->lock, "dcache lock");
+ AFS_RWLOCK_INIT(&tdc->tlock, "dcache tlock");
+ AFS_RWLOCK_INIT(&tdc->mflock, "dcache flock");
ObtainReadLock(&tdc->tlock);
/*
afs_freeDSList = &tdp[0];
for (i = 0; i < aDentries - 1; i++) {
tdp[i].lruq.next = (struct afs_q *)(&tdp[i + 1]);
- RWLOCK_INIT(&tdp[i].lock, "dcache lock");
- RWLOCK_INIT(&tdp[i].tlock, "dcache tlock");
- RWLOCK_INIT(&tdp[i].mflock, "dcache flock");
+ AFS_RWLOCK_INIT(&tdp[i].lock, "dcache lock");
+ AFS_RWLOCK_INIT(&tdp[i].tlock, "dcache tlock");
+ AFS_RWLOCK_INIT(&tdp[i].mflock, "dcache flock");
}
tdp[aDentries - 1].lruq.next = (struct afs_q *)0;
- RWLOCK_INIT(&tdp[aDentries - 1].lock, "dcache lock");
- RWLOCK_INIT(&tdp[aDentries - 1].tlock, "dcache tlock");
- RWLOCK_INIT(&tdp[aDentries - 1].mflock, "dcache flock");
+ AFS_RWLOCK_INIT(&tdp[aDentries - 1].lock, "dcache lock");
+ AFS_RWLOCK_INIT(&tdp[aDentries - 1].tlock, "dcache tlock");
+ AFS_RWLOCK_INIT(&tdp[aDentries - 1].mflock, "dcache flock");
afs_stats_cmperf.cacheBlocksOrig = afs_stats_cmperf.cacheBlocksTotal =
afs_cacheBlocks = ablocks;
{
if (afs_dynrootInit)
return 0;
- RWLOCK_INIT(&afs_dynrootDirLock, "afs_dynrootDirLock");
- RWLOCK_INIT(&afs_dynSymlinkLock, "afs_dynSymlinkLock");
+ AFS_RWLOCK_INIT(&afs_dynrootDirLock, "afs_dynrootDirLock");
+ AFS_RWLOCK_INIT(&afs_dynSymlinkLock, "afs_dynSymlinkLock");
afs_dynrootInit = 0;
return afs_dynrootCellInit();
}
usedihint = 0;
LOCK_INIT(&afs_ftf, "afs_ftf");
- RWLOCK_INIT(&afs_xaxs, "afs_xaxs");
+ AFS_RWLOCK_INIT(&afs_xaxs, "afs_xaxs");
#ifdef AFS_DISCON_ENV
- RWLOCK_INIT(&afs_discon_lock, "afs_discon_lock");
- RWLOCK_INIT(&afs_DDirtyVCListLock, "afs_DDirtyVCListLock");
+ AFS_RWLOCK_INIT(&afs_discon_lock, "afs_discon_lock");
+ AFS_RWLOCK_INIT(&afs_DDirtyVCListLock, "afs_DDirtyVCListLock");
#endif
osi_dnlc_init();
static struct rx_securityClass *secobj;
AFS_STATCNT(afs_ResourceInit);
- RWLOCK_INIT(&afs_xuser, "afs_xuser");
- RWLOCK_INIT(&afs_xvolume, "afs_xvolume");
- RWLOCK_INIT(&afs_xserver, "afs_xserver");
- RWLOCK_INIT(&afs_xsrvAddr, "afs_xsrvAddr");
- RWLOCK_INIT(&afs_icl_lock, "afs_icl_lock");
- RWLOCK_INIT(&afs_xinterface, "afs_xinterface");
+ AFS_RWLOCK_INIT(&afs_xuser, "afs_xuser");
+ AFS_RWLOCK_INIT(&afs_xvolume, "afs_xvolume");
+ AFS_RWLOCK_INIT(&afs_xserver, "afs_xserver");
+ AFS_RWLOCK_INIT(&afs_xsrvAddr, "afs_xsrvAddr");
+ AFS_RWLOCK_INIT(&afs_icl_lock, "afs_icl_lock");
+ AFS_RWLOCK_INIT(&afs_xinterface, "afs_xinterface");
LOCK_INIT(&afs_puttofileLock, "afs_puttofileLock");
#ifndef AFS_FBSD_ENV
LOCK_INIT(&osi_fsplock, "osi_fsplock");
LOCK_INIT(&osi_flplock, "osi_flplock");
#endif
- RWLOCK_INIT(&afs_xconn, "afs_xconn");
+ AFS_RWLOCK_INIT(&afs_xconn, "afs_xconn");
afs_CellInit();
afs_InitCBQueue(1); /* initialize callback queues */
afs_waitForever = afs_waitForeverCount = 0;
afs_FVIndex = -1;
afs_server = (struct rx_service *)0;
- RWLOCK_INIT(&afs_xconn, "afs_xconn");
+ AFS_RWLOCK_INIT(&afs_xconn, "afs_xconn");
memset((char *)&afs_rootFid, 0, sizeof(struct VenusFid));
- RWLOCK_INIT(&afs_xuser, "afs_xuser");
- RWLOCK_INIT(&afs_xvolume, "afs_xvolume");
- RWLOCK_INIT(&afs_xserver, "afs_xserver");
+ AFS_RWLOCK_INIT(&afs_xuser, "afs_xuser");
+ AFS_RWLOCK_INIT(&afs_xvolume, "afs_xvolume");
+ AFS_RWLOCK_INIT(&afs_xserver, "afs_xserver");
LOCK_INIT(&afs_puttofileLock, "afs_puttofileLock");
shutdown_cell();
rx_Init(htons(7001));
AFS_STATCNT(afs_ResourceInit);
- RWLOCK_INIT(&afs_xuser, "afs_xuser");
- RWLOCK_INIT(&afs_xpagcell, "afs_xpagcell");
- RWLOCK_INIT(&afs_xpagsys, "afs_xpagsys");
- RWLOCK_INIT(&afs_icl_lock, "afs_icl_lock");
+ AFS_RWLOCK_INIT(&afs_xuser, "afs_xuser");
+ AFS_RWLOCK_INIT(&afs_xpagcell, "afs_xpagcell");
+ AFS_RWLOCK_INIT(&afs_xpagsys, "afs_xpagsys");
+ AFS_RWLOCK_INIT(&afs_icl_lock, "afs_icl_lock");
#ifndef AFS_FBSD_ENV
LOCK_INIT(&osi_fsplock, "osi_fsplock");
LOCK_INIT(&osi_flplock, "osi_flplock");
tvc->uncred = 0;
#endif
- RWLOCK_INIT(&tvc->lock, "vcache lock");
+ AFS_RWLOCK_INIT(&tvc->lock, "vcache lock");
#if defined(AFS_SUN5_ENV)
- RWLOCK_INIT(&tvc->vlock, "vcache vlock");
+ AFS_RWLOCK_INIT(&tvc->vlock, "vcache vlock");
#endif /* defined(AFS_SUN5_ENV) */
tvc->parentVnode = 0;
freeVCList = NULL;
#endif
- RWLOCK_INIT(&afs_xvcache, "afs_xvcache");
+ AFS_RWLOCK_INIT(&afs_xvcache, "afs_xvcache");
LOCK_INIT(&afs_xvcb, "afs_xvcb");
#if !defined(AFS_OSF_ENV) && !defined(AFS_LINUX22_ENV)
#if !defined(AFS_OSF_ENV) && !defined(AFS_LINUX22_ENV)
freeVCList = Initial_freeVCList = 0;
#endif
- RWLOCK_INIT(&afs_xvcache, "afs_xvcache");
+ AFS_RWLOCK_INIT(&afs_xvcache, "afs_xvcache");
LOCK_INIT(&afs_xvcb, "afs_xvcb");
QInit(&VLRU);
for(i = 0; i < VCSIZE; ++i)
tv = afs_GetVolSlot();
memset((char *)tv, 0, sizeof(struct volume));
tv->cell = tcell->cellNum;
- RWLOCK_INIT(&tv->lock, "volume lock");
+ AFS_RWLOCK_INIT(&tv->lock, "volume lock");
tv->next = afs_volumes[i]; /* thread into list */
afs_volumes[i] = tv;
tv->volume = volid;
#define MReleaseWriteLock(lock) ReleaseWriteLock(lock)
#define MReleaseSharedLock(lock) ReleaseSharedLock(lock)
-#define RWLOCK_INIT(lock, nm) Lock_Init(lock)
+#define AFS_RWLOCK_INIT(lock, nm) Lock_Init(lock)
#undef LOCK_INIT
#define LOCK_INIT(lock, nm) Lock_Init(lock)
rx_multi.o: ${RX}/rx_multi.c
${CCRULE} ${RX}/rx_multi.c
-${RXOBJS}: ${RX}/rx.h ${RX}/rx_user.h ${RX}/rx_globals.h ${RX}/rx_clock.h ${RX}/rx_queue.h ${RX}/rx_event.h
+${RXOBJS}: ${RX}/rx.h ${RX}/rx_user.h ${RX}/rx_globals.h ${RX}/rx_clock.h ${RX}/rx_queue.h ${RX}/rx_event.h ${RX}/rx_internal.h
rxkad_client.o: ${RXKAD}/rxkad_client.c
${CCRULE} ${RXKAD}/rxkad_client.c
#define CV_SIGNAL(_cv) e_wakeup_one(_cv)
#define CV_BROADCAST(_cv) e_wakeup(_cv)
typedef simple_lock_data afs_kmutex_t;
+typedef afs_kmutex_t afs_krwlock_t;
typedef tid_t afs_kcondvar_t;
+#define RWLOCK_INIT(a, b, c, d) MUTEX_INIT(a,b,c,d)
+#define RWLOCK_DESTROY(l) MUTEX_DESTROY(l)
+#define RWLOCK_UPLOCK(l)
+#define RWLOCK_WRLOCK(l) MUTEX_ENTER(l)
+#define RWLOCK_RDLOCK(l) MUTEX_ENTER(l)
+#define RWLOCK_TRYWRLOCK(l) MUTEX_TRYENTER(l)
+#define RWLOCK_TRYRDLOCK(l) MUTEX_TRYENTER(l)
+#define RWLOCK_UNLOCK(l) MUTEX_EXIT(l)
+
#define LOCK_INIT(a, b) lock_alloc((void*)(a), LOCK_ALLOC_PIN, 1, 1), \
simple_lock_init((void *)(a))
#define MUTEX_INIT(a,b,c,d) lock_alloc((void*)(a), LOCK_ALLOC_PIN, 1, 1), \
struct proc *owner;
} afs_kmutex_t;
+typedef afs_kmutex_t afs_krwlock_t;
+#define RWLOCK_INIT(a, b, c, d) MUTEX_INIT(a,b,c,d)
+#define RWLOCK_DESTROY(l) MUTEX_DESTROY(l)
+#define RWLOCK_UPLOCK(l)
+#define RWLOCK_WRLOCK(l) MUTEX_ENTER(l)
+#define RWLOCK_RDLOCK(l) MUTEX_ENTER(l)
+#define RWLOCK_TRYWRLOCK(l) MUTEX_TRYENTER(l)
+#define RWLOCK_TRYRDLOCK(l) MUTEX_TRYENTER(l)
+#define RWLOCK_UNLOCK(l) MUTEX_EXIT(l)
+
#define MUTEX_INIT(a,b,c,d) \
do { \
(a)->owner = 0; \
#define AFS_RX_ORDER 30
+typedef afs_kmutex_t afs_krwlock_t;
+#define RWLOCK_INIT(a, b, c, d) MUTEX_INIT(a,b,c,d)
+#define RWLOCK_DESTROY(l) MUTEX_DESTROY(l)
+#define RWLOCK_UPLOCK(l)
+#define RWLOCK_WRLOCK(l) MUTEX_ENTER(l)
+#define RWLOCK_RDLOCK(l) MUTEX_ENTER(l)
+#define RWLOCK_TRYWRLOCK(l) MUTEX_TRYENTER(l)
+#define RWLOCK_TRYRDLOCK(l) MUTEX_TRYENTER(l)
+#define RWLOCK_UNLOCK(l) MUTEX_EXIT(l)
+
#define MUTEX_INIT(a,b,c,d) b_initsema((a), 1, AFS_RX_ORDER, (b))
#define MUTEX_DESTROY(a)
#define osirx_AssertMine(addr, msg)
+#define RWLOCK_INIT(a, b, c, d)
+#define RWLOCK_DESTROY(l)
+#define RWLOCK_UPLOCK(l)
+#define RWLOCK_WRLOCK(l)
+#define RWLOCK_RDLOCK(l)
+#define RWLOCK_TRYWRLOCK(l)
+#define RWLOCK_TRYRDLOCK(l)
+#define RWLOCK_UNLOCK(l)
+
#define MUTEX_DESTROY(a)
#define MUTEX_ENTER(a)
#define MUTEX_TRYENTER(a) 1
#define mutex_tryenter(m) cpsema(m)
#endif /* mutex_tryenter */
typedef kmutex_t afs_kmutex_t;
+typedef afs_kmutex_t afs_krwlock_t;
typedef kcondvar_t afs_kcondvar_t;
#ifndef CV_DEFAULT
#define MUTEX_DEFAULT 0
#endif
+#define RWLOCK_INIT(a, b, c, d) MUTEX_INIT(a,b,c,d)
+#define RWLOCK_DESTROY(l) MUTEX_DESTROY(l)
+#define RWLOCK_UPLOCK(l)
+#define RWLOCK_WRLOCK(l) MUTEX_ENTER(l)
+#define RWLOCK_RDLOCK(l) MUTEX_ENTER(l)
+#define RWLOCK_TRYWRLOCK(l) MUTEX_TRYENTER(l)
+#define RWLOCK_TRYRDLOCK(l) MUTEX_TRYENTER(l)
+#define RWLOCK_UNLOCK(l) MUTEX_EXIT(l)
+
#ifdef AFS_SGI62_ENV
#define MUTEX_INIT(m, nm, type , a) mutex_init(m, type, nm)
#else
int owner;
} afs_kmutex_t;
+typedef afs_kmutex_t afs_krwlock_t;
+
#ifndef set_current_state
#define set_current_state(X) current->state=X
#endif
return l->owner == current->pid;
}
+#define RWLOCK_INIT(a, b, c, d) MUTEX_INIT(a,b,c,d)
+#define RWLOCK_DESTROY(l) MUTEX_DESTROY(l)
+#define RWLOCK_UPLOCK(l)
+#define RWLOCK_WRLOCK(l) MUTEX_ENTER(l)
+#define RWLOCK_RDLOCK(l) MUTEX_ENTER(l)
+#define RWLOCK_TRYWRLOCK(l) MUTEX_TRYENTER(l)
+#define RWLOCK_TRYRDLOCK(l) MUTEX_TRYENTER(l)
+#define RWLOCK_UNLOCK(l) MUTEX_EXIT(l)
+
#define MUTEX_INIT(a,b,c,d) afs_mutex_init(a)
#define MUTEX_DESTROY(a)
#define MUTEX_ENTER afs_mutex_enter
RX_component_version_number.o: RX_component_version_number.c
-${RXOBJS}: ${BASICINCLS} rx.h rx_user.h rx_globals.h rx_prototypes.h
+${RXOBJS}: ${BASICINCLS} rx.h rx_user.h rx_globals.h rx_prototypes.h rx_internal.h
-${MULTIOBJS}: rx.h rx_multi.h rx_prototypes.h
+${MULTIOBJS}: rx.h rx_multi.h rx_prototypes.h rx_internal.h
${XDROBJS}: xdr.h xdr_prototypes.h
rxperf.o: rx.h rx_null.h rx_globals.h rx_prototypes.h
-rx_user.o: rx.h rx_user.h rx_prototypes.h
+rx_user.o: rx.h rx_user.h rx_prototypes.h rx_internal.h
-rx_packet.o: rx_packet.c rx_packet.h
+rx_packet.o: rx_packet.c rx_packet.h rx_internal.h rx.h
-rx_rdwr.o: rx_rdwr.c rx.h rx_prototypes.h
+rx_rdwr.o: rx_rdwr.c rx.h rx_prototypes.h rx_internal.h
-rx.o: rx.h rx_user.h rx_prototypes.h
+rx.o: rx.h rx_user.h rx_prototypes.h rx_internal.h
-rx_conncache.o: rx.h rx_prototypes.h
+rx_conncache.o: rx.h rx_prototypes.h rx_internal.h
-rx_trace.o: rx_trace.h
+rx_trace.o: rx_trace.h rx_internal.h
-rx_getaddr.o: rx.h rx_getaddr.c rx_prototypes.h
+rx_getaddr.o: rx.h rx_getaddr.c rx_prototypes.h rx_internal.h
-rx_globals.o: rx.h rx_user.h rx_globals.h rx_prototypes.h
+rx_globals.o: rx.h rx_user.h rx_globals.h rx_prototypes.h rx_internal.h
-xdr_rx.o: xdr.h rx.h xdr_prototypes.h rx_prototypes.h
+xdr_rx.o: xdr.h rx.h xdr_prototypes.h rx_prototypes.h rx_internal.h
-xdr_refernce.o: xdr_refernce.c xdr.h xdr_prototypes.h
+xdr_refernce.o: xdr_refernce.c xdr.h xdr_prototypes.h rx_internal.h
rxperf: rxperf.o librx.a
${CC} -o $@ rxperf.o ${LIBS}
struct lock__bsd__ lock;
thread_t owner;
} afs_kmutex_t;
+typedef afs_krwlock_t afs_kmutex_t;
typedef int afs_kcondvar_t;
+#define RWLOCK_INIT(a, b, c, d) MUTEX_INIT(a,b,c,d)
+#define RWLOCK_DESTROY(l) MUTEX_DESTROY(l)
+#define RWLOCK_UPLOCK(l)
+#define RWLOCK_WRLOCK(l) MUTEX_ENTER(l)
+#define RWLOCK_RDLOCK(l) MUTEX_ENTER(l)
+#define RWLOCK_TRYWRLOCK(l) MUTEX_TRYENTER(l)
+#define RWLOCK_TRYRDLOCK(l) MUTEX_TRYENTER(l)
+#define RWLOCK_UNLOCK(l) MUTEX_EXIT(l)
+
#define osi_rxWakeup(cv) thread_wakeup((event_t)(cv))
#define LOCK_INIT(a,b) \
typedef struct {
struct proc *owner;
} afs_kmutex_t;
+typedef afs_kmutex_t afs_krwlock_t;
#define MUTEX_DEFAULT 0
+#define RWLOCK_INIT(a, b, c, d) MUTEX_INIT(a,b,c,d)
+#define RWLOCK_DESTROY(l) MUTEX_DESTROY(l)
+#define RWLOCK_UPLOCK(l)
+#define RWLOCK_WRLOCK(l) MUTEX_ENTER(l)
+#define RWLOCK_RDLOCK(l) MUTEX_ENTER(l)
+#define RWLOCK_TRYWRLOCK(l) MUTEX_TRYENTER(l)
+#define RWLOCK_TRYRDLOCK(l) MUTEX_TRYENTER(l)
+#define RWLOCK_UNLOCK(l) MUTEX_EXIT(l)
+
#define MUTEX_INIT(a,b,c,d) \
do { \
(a)->owner = 0; \
#include <sys/mutex.h>
typedef kmutex_t afs_kmutex_t;
+typedef afs_kmutex_t afs_krwlock_t;
typedef kcondvar_t afs_kcondvar_t;
#undef osirx_AssertMine
#define RX_ENABLE_LOCKS 1
#define afs_kmutex_t usr_mutex_t
+#define afs_krwlock_t usr_mutex_t
#define afs_kcondvar_t usr_cond_t
+#define RWLOCK_INIT(a, b, c, d) usr_mutex_init(a)
+#define RWLOCK_DESTROY(l) usr_mutex_destroy(l)
+#define RWLOCK_UPLOCK(l)
+#define RWLOCK_WRLOCK(l) usr_mutex_lock(l)
+#define RWLOCK_RDLOCK(l) usr_mutex_lock(l)
+#define RWLOCK_TRYWRLOCK(l) usr_mutex_trylock(l)
+#define RWLOCK_TRYRDLOCK(l) usr_mutex_trylock(l)
+#define RWLOCK_UNLOCK(l) usr_mutex_unlock(l)
#define MUTEX_INIT(A,B,C,D) usr_mutex_init(A)
#define MUTEX_ENTER(A) usr_mutex_lock(A)
#define MUTEX_TRYENTER(A) usr_mutex_trylock(A)
#include "rx_kernel.h"
#include "rx_clock.h"
#include "rx_queue.h"
+#include "rx_internal.h"
#include "rx.h"
#include "rx_globals.h"
#include "rx_trace.h"
# include <netinet/in.h>
# include <sys/time.h>
#endif
+# include "rx_internal.h"
# include "rx.h"
# include "rx_user.h"
# include "rx_clock.h"
0);
CV_INIT(&rx_waitingForPackets_cv, "rx_waitingForPackets_cv", CV_DEFAULT,
0);
- MUTEX_INIT(&rx_peerHashTable_lock, "rx_peerHashTable_lock", MUTEX_DEFAULT,
+ RWLOCK_INIT(&rx_peerHashTable_lock, "rx_peerHashTable_lock", MUTEX_DEFAULT,
0);
- MUTEX_INIT(&rx_connHashTable_lock, "rx_connHashTable_lock", MUTEX_DEFAULT,
+ RWLOCK_INIT(&rx_connHashTable_lock, "rx_connHashTable_lock", MUTEX_DEFAULT,
0);
MUTEX_INIT(&rx_serverPool_lock, "rx_serverPool_lock", MUTEX_DEFAULT, 0);
MUTEX_INIT(&rxi_keyCreate_lock, "rxi_keyCreate_lock", MUTEX_DEFAULT, 0);
0);
CV_INIT(&rx_waitingForPackets_cv, "rx_waitingForPackets_cv", CV_DEFAULT,
0);
- MUTEX_INIT(&rx_peerHashTable_lock, "rx_peerHashTable_lock", MUTEX_DEFAULT,
+ RWLOCK_INIT(&rx_peerHashTable_lock, "rx_peerHashTable_lock", MUTEX_DEFAULT,
0);
- MUTEX_INIT(&rx_connHashTable_lock, "rx_connHashTable_lock", MUTEX_DEFAULT,
+ RWLOCK_INIT(&rx_connHashTable_lock, "rx_connHashTable_lock", MUTEX_DEFAULT,
0);
MUTEX_INIT(&rx_serverPool_lock, "rx_serverPool_lock", MUTEX_DEFAULT, 0);
#if defined(AFS_HPUX110_ENV)
rx_SetEpoch(tv.tv_sec); /* Start time of this package, rxkad
* will provide a randomer value. */
#endif
- MUTEX_ENTER(&rx_stats_mutex);
- rxi_dataQuota += rx_extraQuota; /* + extra pkts caller asked to rsrv */
- MUTEX_EXIT(&rx_stats_mutex);
+ rx_MutexAdd(rxi_dataQuota, rx_extraQuota, rx_stats_mutex); /* + extra pkts caller asked to rsrv */
/* *Slightly* random start time for the cid. This is just to help
* out with the hashing function at the peer */
rx_nextCid = ((tv.tv_sec ^ tv.tv_usec) << RX_CIDSHIFT);
* the case of kmem_alloc? */
NETPRI;
- MUTEX_ENTER(&rx_connHashTable_lock);
+ RWLOCK_WRLOCK(&rx_connHashTable_lock);
/* send in the clones */
for(cix = 0; cix <= nclones; ++cix) {
-
ptconn = tconn;
tconn = rxi_AllocConnection();
tconn->type = RX_CLIENT_CONNECTION;
tconn->delayedAbortEvent = NULL;
tconn->abortCount = 0;
tconn->error = 0;
- for (i = 0; i < RX_MAXCALLS; i++) {
- tconn->twind[i] = rx_initSendWindow;
- tconn->rwind[i] = rx_initReceiveWindow;
- }
+ for (i = 0; i < RX_MAXCALLS; i++) {
+ tconn->twind[i] = rx_initSendWindow;
+ tconn->rwind[i] = rx_initReceiveWindow;
+ }
tconn->parent = 0;
tconn->next_clone = 0;
tconn->nclones = nclones;
rx_MutexIncrement(rx_stats.nClientConns, rx_stats_mutex);
}
- MUTEX_EXIT(&rx_connHashTable_lock);
+ RWLOCK_UNLOCK(&rx_connHashTable_lock);
USERPRI;
return conn;
}
* idle time to now. rxi_ReapConnections will reap it if it's still
* idle (refCount == 0) after rx_idlePeerTime (60 seconds) have passed.
*/
- MUTEX_ENTER(&rx_peerHashTable_lock);
+ RWLOCK_WRLOCK(&rx_peerHashTable_lock);
if (conn->peer->refCount < 2) {
conn->peer->idleWhen = clock_Sec();
if (conn->peer->refCount < 1) {
conn->peer->refCount = 1;
- MUTEX_ENTER(&rx_stats_mutex);
- rxi_lowPeerRefCount++;
- MUTEX_EXIT(&rx_stats_mutex);
+ rx_MutexIncrement(rxi_lowPeerRefCount, rx_stats_mutex);
}
}
conn->peer->refCount--;
- MUTEX_EXIT(&rx_peerHashTable_lock);
+ RWLOCK_UNLOCK(&rx_peerHashTable_lock);
if (conn->type == RX_SERVER_CONNECTION)
rx_MutexDecrement(rx_stats.nServerConns, rx_stats_mutex);
rxi_DestroyConnection(register struct rx_connection *conn)
{
register struct rx_connection *tconn, *dtconn;
-
- MUTEX_ENTER(&rx_connHashTable_lock);
+
+ RWLOCK_WRLOCK(&rx_connHashTable_lock);
if(!(conn->flags & RX_CLONED_CONNECTION)) {
tconn = conn->next_clone;
/* destroyed? */
if (dtconn == rx_connCleanup_list) {
rx_connCleanup_list = rx_connCleanup_list->next;
- MUTEX_EXIT(&rx_connHashTable_lock);
+ RWLOCK_UNLOCK(&rx_connHashTable_lock);
/* rxi_CleanupConnection will free tconn */
rxi_CleanupConnection(dtconn);
- MUTEX_ENTER(&rx_connHashTable_lock);
+ RWLOCK_WRLOCK(&rx_connHashTable_lock);
(conn->nclones)--;
}
}
/* conn should be at the head of the cleanup list */
if (conn == rx_connCleanup_list) {
rx_connCleanup_list = rx_connCleanup_list->next;
- MUTEX_EXIT(&rx_connHashTable_lock);
+ RWLOCK_UNLOCK(&rx_connHashTable_lock);
rxi_CleanupConnection(conn);
}
#ifdef RX_ENABLE_LOCKS
else {
- MUTEX_EXIT(&rx_connHashTable_lock);
+ RWLOCK_UNLOCK(&rx_connHashTable_lock);
}
#endif /* RX_ENABLE_LOCKS */
}
if (conn->refCount > 0)
conn->refCount--;
else {
- MUTEX_ENTER(&rx_stats_mutex);
- rxi_lowConnRefCount++;
- MUTEX_EXIT(&rx_stats_mutex);
+ rx_MutexIncrement(rxi_lowConnRefCount, rx_stats_mutex);
}
if ((conn->refCount > 0) || (conn->flags & RX_CONN_BUSY)) {
if (havecalls) {
/* Don't destroy the connection if there are any call
* structures still in use */
- MUTEX_ENTER(&conn->conn_data_lock);
- conn->flags |= RX_CONN_DESTROY_ME;
- MUTEX_EXIT(&conn->conn_data_lock);
+ rx_MutexOr(conn->flags, RX_CONN_DESTROY_ME, conn->conn_data_lock);
USERPRI;
return;
}
SPLVAR;
NETPRI;
- MUTEX_ENTER(&conn->conn_data_lock);
- conn->refCount++;
- MUTEX_EXIT(&conn->conn_data_lock);
+ rx_MutexIncrement(conn->refCount, conn->conn_data_lock);
USERPRI;
}
#else
osi_rxSleep(conn);
#endif
- MUTEX_ENTER(&conn->conn_data_lock);
- conn->makeCallWaiters--;
- }
- MUTEX_EXIT(&conn->conn_data_lock);
+ rx_MutexDecrement(conn->makeCallWaiters, conn->conn_data_lock);
+ } else {
+ MUTEX_EXIT(&conn->conn_data_lock);
+ }
/* search for next free call on this connection or
* its clones, if any */
#else
osi_rxSleep(conn);
#endif
- MUTEX_ENTER(&conn->conn_data_lock);
- conn->makeCallWaiters--;
- MUTEX_EXIT(&conn->conn_data_lock);
+ rx_MutexDecrement(conn->makeCallWaiters, conn->conn_data_lock);
} /* for ;; */
/*
* Wake up anyone else who might be giving us a chance to
(*tservice->afterProc) (call, code);
rx_EndCall(call, code);
- MUTEX_ENTER(&rx_stats_mutex);
- rxi_nCalls++;
- MUTEX_EXIT(&rx_stats_mutex);
+ rx_MutexIncrement(rxi_nCalls, rx_stats_mutex);
}
}
if (call->flags & RX_CALL_WAIT_PROC) {
call->flags &= ~RX_CALL_WAIT_PROC;
- MUTEX_ENTER(&rx_stats_mutex);
- rx_nWaiting--;
- MUTEX_EXIT(&rx_stats_mutex);
+ rx_MutexDecrement(rx_nWaiting, rx_stats_mutex);
}
if (call->state != RX_STATE_PRECALL || call->error) {
}
rxi_DeleteCachedConnections();
if (rx_connHashTable) {
- MUTEX_ENTER(&rx_connHashTable_lock);
+ RWLOCK_WRLOCK(&rx_connHashTable_lock);
for (conn_ptr = &rx_connHashTable[0], conn_end =
&rx_connHashTable[rx_hashTableSize]; conn_ptr < conn_end;
conn_ptr++) {
struct rx_connection *conn;
conn = rx_connCleanup_list;
rx_connCleanup_list = rx_connCleanup_list->next;
- MUTEX_EXIT(&rx_connHashTable_lock);
+ RWLOCK_UNLOCK(&rx_connHashTable_lock);
rxi_CleanupConnection(conn);
- MUTEX_ENTER(&rx_connHashTable_lock);
+ RWLOCK_WRLOCK(&rx_connHashTable_lock);
}
- MUTEX_EXIT(&rx_connHashTable_lock);
+ RWLOCK_UNLOCK(&rx_connHashTable_lock);
#endif /* RX_ENABLE_LOCKS */
}
rxi_flushtrace();
* call lock held or are going through this section of code.
*/
if (conn->flags & RX_CONN_DESTROY_ME && !(conn->flags & RX_CONN_MAKECALL_WAITING)) {
- MUTEX_ENTER(&conn->conn_data_lock);
- conn->refCount++;
- MUTEX_EXIT(&conn->conn_data_lock);
+ rx_MutexIncrement(conn->refCount, conn->conn_data_lock);
#ifdef RX_ENABLE_LOCKS
if (haveCTLock)
rxi_DestroyConnectionNoLock(conn);
struct rx_peer **peer_ptr, **peer_end;
int hashIndex;
- MUTEX_ENTER(&rx_peerHashTable_lock);
+ RWLOCK_RDLOCK(&rx_peerHashTable_lock);
if (port == 0) {
for (peer_ptr = &rx_peerHashTable[0], peer_end =
&rx_peerHashTable[rx_hashTableSize]; peer_ptr < peer_end;
}
}
}
- MUTEX_EXIT(&rx_peerHashTable_lock);
+ RWLOCK_UNLOCK(&rx_peerHashTable_lock);
}
/* Find the peer process represented by the supplied (host,port)
register struct rx_peer *pp;
int hashIndex;
hashIndex = PEER_HASH(host, port);
- MUTEX_ENTER(&rx_peerHashTable_lock);
+ RWLOCK_RDLOCK(&rx_peerHashTable_lock);
for (pp = rx_peerHashTable[hashIndex]; pp; pp = pp->next) {
if ((pp->host == host) && (pp->port == port))
break;
MUTEX_INIT(&pp->peer_lock, "peer_lock", MUTEX_DEFAULT, 0);
queue_Init(&pp->congestionQueue);
queue_Init(&pp->rpcStats);
+ RWLOCK_UPLOCK(&rx_peerHashTable_lock);
pp->next = rx_peerHashTable[hashIndex];
rx_peerHashTable[hashIndex] = pp;
rxi_InitPeerParams(pp);
}
if (origPeer)
origPeer->refCount--;
- MUTEX_EXIT(&rx_peerHashTable_lock);
+ RWLOCK_UNLOCK(&rx_peerHashTable_lock);
return pp;
}
int hashindex, flag, i;
register struct rx_connection *conn;
hashindex = CONN_HASH(host, port, cid, epoch, type);
- MUTEX_ENTER(&rx_connHashTable_lock);
+ RWLOCK_RDLOCK(&rx_connHashTable_lock);
rxLastConn ? (conn = rxLastConn, flag = 0) : (conn =
rx_connHashTable[hashindex],
flag = 1);
* like this, and there seems to be some CM bug that makes this
* happen from time to time -- in which case, the fileserver
* asserts. */
- MUTEX_EXIT(&rx_connHashTable_lock);
+ RWLOCK_UNLOCK(&rx_connHashTable_lock);
return (struct rx_connection *)0;
}
if (pp->host == host && pp->port == port)
if (!conn) {
struct rx_service *service;
if (type == RX_CLIENT_CONNECTION) {
- MUTEX_EXIT(&rx_connHashTable_lock);
+ RWLOCK_UNLOCK(&rx_connHashTable_lock);
return (struct rx_connection *)0;
}
service = rxi_FindService(socket, serviceId);
if (!service || (securityIndex >= service->nSecurityObjects)
|| (service->securityObjects[securityIndex] == 0)) {
- MUTEX_EXIT(&rx_connHashTable_lock);
+ RWLOCK_UNLOCK(&rx_connHashTable_lock);
return (struct rx_connection *)0;
}
conn = rxi_AllocConnection(); /* This bzero's the connection */
MUTEX_INIT(&conn->conn_call_lock, "conn call lock", MUTEX_DEFAULT, 0);
MUTEX_INIT(&conn->conn_data_lock, "conn data lock", MUTEX_DEFAULT, 0);
CV_INIT(&conn->conn_call_cv, "conn call cv", CV_DEFAULT, 0);
- conn->next = rx_connHashTable[hashindex];
- rx_connHashTable[hashindex] = conn;
conn->peer = rxi_FindPeer(host, port, 0, 1);
conn->type = RX_SERVER_CONNECTION;
conn->lastSendTime = clock_Sec(); /* don't GC immediately */
conn->epoch = epoch;
- conn->cid = cid & RX_CIDMASK;
/* conn->serial = conn->lastSerial = 0; */
/* conn->timeout = 0; */
conn->ackRate = RX_FAST_ACK_RATE;
conn->twind[i] = rx_initSendWindow;
conn->rwind[i] = rx_initReceiveWindow;
}
+ RWLOCK_UPLOCK(&rx_connHashTable_lock);
+ conn->next = rx_connHashTable[hashindex];
+ rx_connHashTable[hashindex] = conn;
+ conn->cid = cid & RX_CIDMASK;
/* Notify security object of the new connection */
RXS_NewConnection(conn->securityObject, conn);
/* XXXX Connection timeout? */
rx_MutexIncrement(rx_stats.nServerConns, rx_stats_mutex);
}
- MUTEX_ENTER(&conn->conn_data_lock);
- conn->refCount++;
- MUTEX_EXIT(&conn->conn_data_lock);
+ rx_MutexIncrement(conn->refCount, conn->conn_data_lock);
rxLastConn = conn; /* store this connection as the last conn used */
- MUTEX_EXIT(&rx_connHashTable_lock);
+ RWLOCK_UNLOCK(&rx_connHashTable_lock);
return conn;
}
afs_int32 errcode = ntohl(rx_GetInt32(np, 0));
dpf(("rxi_ReceivePacket ABORT rx_GetInt32 = %d", errcode));
rxi_ConnectionError(conn, errcode);
- MUTEX_ENTER(&conn->conn_data_lock);
- conn->refCount--;
- MUTEX_EXIT(&conn->conn_data_lock);
+ rx_MutexDecrement(conn->refCount, conn->conn_data_lock);
return np;
}
case RX_PACKET_TYPE_CHALLENGE:
tnp = rxi_ReceiveChallengePacket(conn, np, 1);
- MUTEX_ENTER(&conn->conn_data_lock);
- conn->refCount--;
- MUTEX_EXIT(&conn->conn_data_lock);
+ rx_MutexDecrement(conn->refCount, conn->conn_data_lock);
return tnp;
case RX_PACKET_TYPE_RESPONSE:
tnp = rxi_ReceiveResponsePacket(conn, np, 1);
- MUTEX_ENTER(&conn->conn_data_lock);
- conn->refCount--;
- MUTEX_EXIT(&conn->conn_data_lock);
+ rx_MutexDecrement(conn->refCount, conn->conn_data_lock);
return tnp;
case RX_PACKET_TYPE_PARAMS:
case RX_PACKET_TYPE_PARAMS + 1:
case RX_PACKET_TYPE_PARAMS + 2:
/* ignore these packet types for now */
- MUTEX_ENTER(&conn->conn_data_lock);
- conn->refCount--;
- MUTEX_EXIT(&conn->conn_data_lock);
+ rx_MutexDecrement(conn->refCount, conn->conn_data_lock);
return np;
* it must be for the previous call.
*/
rx_MutexIncrement(rx_stats.spuriousPacketsRead, rx_stats_mutex);
- MUTEX_ENTER(&conn->conn_data_lock);
- conn->refCount--;
- MUTEX_EXIT(&conn->conn_data_lock);
+ rx_MutexDecrement(conn->refCount, conn->conn_data_lock);
return np;
}
}
if (call)
MUTEX_EXIT(&call->lock);
#endif
- MUTEX_ENTER(&conn->conn_data_lock);
- conn->refCount--;
- MUTEX_EXIT(&conn->conn_data_lock);
+ rx_MutexDecrement(conn->refCount, conn->conn_data_lock);
return np;
}
if (!call) {
rxi_CallError(call, rx_BusyError);
tp = rxi_SendCallAbort(call, np, 1, 0);
MUTEX_EXIT(&call->lock);
- MUTEX_ENTER(&conn->conn_data_lock);
- conn->refCount--;
- MUTEX_EXIT(&conn->conn_data_lock);
+ rx_MutexDecrement(conn->refCount, conn->conn_data_lock);
rx_MutexIncrement(rx_stats.nBusies, rx_stats_mutex);
return tp;
}
tp = rxi_SendSpecial(call, conn, np, RX_PACKET_TYPE_BUSY,
NULL, 0, 1);
MUTEX_EXIT(&call->lock);
- MUTEX_ENTER(&conn->conn_data_lock);
- conn->refCount--;
- MUTEX_EXIT(&conn->conn_data_lock);
+ rx_MutexDecrement(conn->refCount, conn->conn_data_lock);
return tp;
}
rxi_ResetCall(call, 0);
rxi_CallError(call, rx_BusyError);
tp = rxi_SendCallAbort(call, np, 1, 0);
MUTEX_EXIT(&call->lock);
- MUTEX_ENTER(&conn->conn_data_lock);
- conn->refCount--;
- MUTEX_EXIT(&conn->conn_data_lock);
+ rx_MutexDecrement(conn->refCount, conn->conn_data_lock);
rx_MutexIncrement(rx_stats.nBusies, rx_stats_mutex);
return tp;
}
MUTEX_EXIT(&call->lock);
}
#endif
- MUTEX_ENTER(&conn->conn_data_lock);
- conn->refCount--;
- MUTEX_EXIT(&conn->conn_data_lock);
+ rx_MutexDecrement(conn->refCount, conn->conn_data_lock);
return np;
}
MUTEX_EXIT(&call->lock);
}
#endif
- MUTEX_ENTER(&conn->conn_data_lock);
- conn->refCount--;
- MUTEX_EXIT(&conn->conn_data_lock);
+ rx_MutexDecrement(conn->refCount, conn->conn_data_lock);
return np;
}
/* If the service security object index stamped in the packet does not
#ifdef RX_ENABLE_LOCKS
MUTEX_EXIT(&call->lock);
#endif
- MUTEX_ENTER(&conn->conn_data_lock);
- conn->refCount--;
- MUTEX_EXIT(&conn->conn_data_lock);
+ rx_MutexDecrement(conn->refCount, conn->conn_data_lock);
return np;
}
if (ntohl(rx_GetInt32(np, FIRSTACKOFFSET)) < call->tfirst) {
rx_MutexIncrement(rx_stats.spuriousPacketsRead, rx_stats_mutex);
MUTEX_EXIT(&call->lock);
- MUTEX_ENTER(&conn->conn_data_lock);
- conn->refCount--;
- MUTEX_EXIT(&conn->conn_data_lock);
+ rx_MutexDecrement(conn->refCount, conn->conn_data_lock);
return np;
}
}
dpf(("rxi_ReceivePacket ABORT rx_DataOf = %d", errdata));
rxi_CallError(call, errdata);
MUTEX_EXIT(&call->lock);
- MUTEX_ENTER(&conn->conn_data_lock);
- conn->refCount--;
- MUTEX_EXIT(&conn->conn_data_lock);
+ rx_MutexDecrement(conn->refCount, conn->conn_data_lock);
return np; /* xmitting; drop packet */
}
case RX_PACKET_TYPE_BUSY:
break;
#else /* RX_ENABLE_LOCKS */
MUTEX_EXIT(&call->lock);
- MUTEX_ENTER(&conn->conn_data_lock);
- conn->refCount--;
- MUTEX_EXIT(&conn->conn_data_lock);
+ rx_MutexDecrement(conn->refCount, conn->conn_data_lock);
return np; /* xmitting; drop packet */
#endif /* RX_ENABLE_LOCKS */
}
* (if not, then the time won't actually be re-evaluated here). */
call->lastReceiveTime = clock_Sec();
MUTEX_EXIT(&call->lock);
- MUTEX_ENTER(&conn->conn_data_lock);
- conn->refCount--;
- MUTEX_EXIT(&conn->conn_data_lock);
+ rx_MutexDecrement(conn->refCount, conn->conn_data_lock);
return np;
}
call->flags &= ~RX_CALL_WAIT_PROC;
if (queue_IsOnQueue(call)) {
queue_Remove(call);
- MUTEX_ENTER(&rx_stats_mutex);
- rx_nWaiting--;
- MUTEX_EXIT(&rx_stats_mutex);
+ rx_MutexDecrement(rx_nWaiting, rx_stats_mutex);
}
}
call->state = RX_STATE_ACTIVE;
if (queue_IsOnQueue(call)) {
queue_Remove(call);
if (flags & RX_CALL_WAIT_PROC) {
- MUTEX_ENTER(&rx_stats_mutex);
- rx_nWaiting--;
- MUTEX_EXIT(&rx_stats_mutex);
+ rx_MutexDecrement(rx_nWaiting, rx_stats_mutex);
}
}
MUTEX_EXIT(call->call_queue_lock);
{
struct rx_connection **conn_ptr, **conn_end;
int i, havecalls = 0;
- MUTEX_ENTER(&rx_connHashTable_lock);
+ RWLOCK_WRLOCK(&rx_connHashTable_lock);
for (conn_ptr = &rx_connHashTable[0], conn_end =
&rx_connHashTable[rx_hashTableSize]; conn_ptr < conn_end;
conn_ptr++) {
struct rx_connection *conn;
conn = rx_connCleanup_list;
rx_connCleanup_list = rx_connCleanup_list->next;
- MUTEX_EXIT(&rx_connHashTable_lock);
+ RWLOCK_UNLOCK(&rx_connHashTable_lock);
rxi_CleanupConnection(conn);
- MUTEX_ENTER(&rx_connHashTable_lock);
+ RWLOCK_WRLOCK(&rx_connHashTable_lock);
}
- MUTEX_EXIT(&rx_connHashTable_lock);
+ RWLOCK_UNLOCK(&rx_connHashTable_lock);
#endif /* RX_ENABLE_LOCKS */
}
struct rx_peer **peer_ptr, **peer_end;
int code;
MUTEX_ENTER(&rx_rpc_stats);
- MUTEX_ENTER(&rx_peerHashTable_lock);
+ RWLOCK_RDLOCK(&rx_peerHashTable_lock);
for (peer_ptr = &rx_peerHashTable[0], peer_end =
&rx_peerHashTable[rx_hashTableSize]; peer_ptr < peer_end;
peer_ptr++) {
rxi_Free(rpc_stat, space);
rxi_rpc_peer_stat_cnt -= num_funcs;
}
- rxi_FreePeer(peer);
rx_MutexDecrement(rx_stats.nPeerStructs, rx_stats_mutex);
+ RWLOCK_UPLOCK(&rx_peerHashTable_lock);
if (peer == *peer_ptr) {
*peer_ptr = next;
prev = next;
} else
prev->next = next;
+ rxi_FreePeer(peer);
} else {
if (code) {
MUTEX_EXIT(&peer->peer_lock);
}
}
}
- MUTEX_EXIT(&rx_peerHashTable_lock);
+ RWLOCK_UNLOCK(&rx_peerHashTable_lock);
MUTEX_EXIT(&rx_rpc_stats);
}
{
struct rx_debugIn in;
afs_int32 *lp = (afs_int32 *) stat;
- int i;
afs_int32 rc = 0;
/*
for (queue_Scan
(&peer->rpcStats, rpc_stat, nrpc_stat,
rx_interface_stat)) {
- unsigned int num_funcs;
+ int num_funcs;
if (!rpc_stat)
break;
queue_Remove(&rpc_stat->queue_header);
sizeof(rx_function_entry_v1_t);
rxi_Free(rpc_stat, space);
- MUTEX_ENTER(&rx_rpc_stats);
- rxi_rpc_peer_stat_cnt -= num_funcs;
- MUTEX_EXIT(&rx_rpc_stats);
+ rx_MutexAdd(rxi_rpc_peer_stat_cnt, -num_funcs, rx_rpc_stats);
}
next = peer->next;
rxi_FreePeer(peer);
}
for (i = 0; i < rx_hashTableSize; i++) {
register struct rx_connection *tc, *ntc;
- MUTEX_ENTER(&rx_connHashTable_lock);
+ RWLOCK_RDLOCK(&rx_connHashTable_lock);
for (tc = rx_connHashTable[i]; tc; tc = ntc) {
ntc = tc->next;
for (j = 0; j < RX_MAXCALLS; j++) {
}
rxi_Free(tc, sizeof(*tc));
}
- MUTEX_EXIT(&rx_connHashTable_lock);
+ RWLOCK_UNLOCK(&rx_connHashTable_lock);
}
MUTEX_ENTER(&freeSQEList_lock);
MUTEX_EXIT(&freeSQEList_lock);
MUTEX_DESTROY(&freeSQEList_lock);
MUTEX_DESTROY(&rx_freeCallQueue_lock);
- MUTEX_DESTROY(&rx_connHashTable_lock);
- MUTEX_DESTROY(&rx_peerHashTable_lock);
+ RWLOCK_DESTROY(&rx_connHashTable_lock);
+ RWLOCK_DESTROY(&rx_peerHashTable_lock);
MUTEX_DESTROY(&rx_serverPool_lock);
osi_Free(rx_connHashTable,
rx_enable_stats = 0;
}
- MUTEX_ENTER(&rx_peerHashTable_lock);
+ RWLOCK_RDLOCK(&rx_peerHashTable_lock);
for (peer_ptr = &rx_peerHashTable[0], peer_end =
&rx_peerHashTable[rx_hashTableSize]; peer_ptr < peer_end;
peer_ptr++) {
}
}
}
- MUTEX_EXIT(&rx_peerHashTable_lock);
+ RWLOCK_UNLOCK(&rx_peerHashTable_lock);
MUTEX_EXIT(&rx_rpc_stats);
}
#endif
#endif /* KERNEL */
-
/* Configurable parameters */
#define RX_IDLE_DEAD_TIME 60 /* default idle dead time */
#define RX_MAX_SERVICES 20 /* Maximum number of services that may be installed */
afs_uint32 callNumber[RX_MAXCALLS]; /* Current call numbers */
afs_uint32 rwind[RX_MAXCALLS];
u_short twind[RX_MAXCALLS];
+ u_short serviceId; /* To stamp on requests (clients only) */
afs_uint32 serial; /* Next outgoing packet serial number */
afs_uint32 lastSerial; /* # of last packet received, for computing skew */
afs_int32 maxSerial; /* largest serial number seen on incoming packets */
int abortCount; /* count of abort messages sent */
/* client-- to retransmit the challenge */
struct rx_service *service; /* used by servers only */
- u_short serviceId; /* To stamp on requests (clients only) */
afs_uint32 refCount; /* Reference count */
u_char flags; /* Defined below */
u_char type; /* Type of connection, defined below */
u_short hardDeadTime; /* hard max for call execution */
u_short idleDeadTime; /* max time a call can be idle (no data) */
u_char ackRate; /* how many packets between ack requests */
- u_char makeCallWaiters; /* how many rx_NewCalls are waiting */
+ u_char spareb;
+ afs_int32 makeCallWaiters; /* how many rx_NewCalls are waiting */
afs_int32 idleDeadErr;
int nSpecific; /* number entries in specific data */
void **specific; /* pointer to connection specific data */
#define RX_STATS_SERVICE_ID 409
-#ifdef AFS_NT40_ENV
-#define rx_MutexIncrement(object, mutex) InterlockedIncrement(&object)
-#define rx_MutexAdd(object, addend, mutex) InterlockedAdd(&object, addend)
-#define rx_MutexDecrement(object, mutex) InterlockedDecrement(&object)
-#define rx_MutexAdd1Increment2(object1, addend, object2, mutex) \
- do { \
- MUTEX_ENTER(&mutex); \
- object1 += addend; \
- InterlockedIncrement(&object2); \
- MUTEX_EXIT(&mutex); \
- } while (0)
-#define rx_MutexAdd1Decrement2(object1, addend, object2, mutex) \
- do { \
- MUTEX_ENTER(&mutex); \
- object1 += addend; \
- InterlockedDecrement(&object2); \
- MUTEX_EXIT(&mutex); \
- } while (0)
-#else
-#define rx_MutexIncrement(object, mutex) \
- do { \
- MUTEX_ENTER(&mutex); \
- object++; \
- MUTEX_EXIT(&mutex); \
- } while(0)
-#define rx_MutexAdd(object, addend, mutex) \
- do { \
- MUTEX_ENTER(&mutex); \
- object += addend; \
- MUTEX_EXIT(&mutex); \
- } while(0)
-#define rx_MutexAdd1Increment2(object1, addend, object2, mutex) \
- do { \
- MUTEX_ENTER(&mutex); \
- object1 += addend; \
- object2++; \
- MUTEX_EXIT(&mutex); \
- } while(0)
-#define rx_MutexAdd1Decrement2(object1, addend, object2, mutex) \
- do { \
- MUTEX_ENTER(&mutex); \
- object1 += addend; \
- object2--; \
- MUTEX_EXIT(&mutex); \
- } while(0)
-#define rx_MutexDecrement(object, mutex) \
- do { \
- MUTEX_ENTER(&mutex); \
- object--; \
- MUTEX_EXIT(&mutex); \
- } while(0)
-#endif
-
#endif /* _RX_ End of rx.h */
#ifdef KERNEL
#else /* !UKERNEL */
#include "afs/sysincludes.h"
#include "afsincludes.h"
+#include "rx/rx_internal.h"
#include "rx/rx.h"
#include "rx/rx_clock.h"
#endif /* !UKERNEL */
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
+#include "rx_internal.h"
#include "rx.h"
#include "rx_clock.h"
#endif
#ifdef UKERNEL
#include "afs/sysincludes.h"
#include "afsincludes.h"
+#include "rx/rx_internal.h"
#include "rx/rx.h"
#else /* ! UKERNEL */
#include <sys/types.h>
#include <errno.h>
#include <assert.h>
+#include "rx_internal.h"
#include "rx.h"
#endif /* UKERNEL */
#include "rx/rx_kernel.h"
#include "rx_kmutex.h"
#ifdef RX_ENABLE_LOCKS
+#include "rx/rx_internal.h"
#include "rx/rx.h"
#endif /* RX_ENABLE_LOCKS */
#include "rx/rx_globals.h"
#include "rx_lwp.h"
#endif
#ifdef RX_ENABLE_LOCKS
+#include "rx_internal.h"
#include "rx.h"
#endif /* RX_ENABLE_LOCKS */
#include "rx_globals.h"
* By including this, we get any system dependencies. In particular,
* the pthreads for solaris requires the socket call to be mapped.
*/
+#include "rx_internal.h"
#include "rx.h"
#include "rx_globals.h"
#endif /* AFS_NT40_ENV */
#ifdef UKERNEL
#include "rx/rx_kcommon.h"
#else /* UKERNEL */
+#include "rx/rx_internal.h"
#include "rx/rx.h"
#endif /* UKERNEL */
#endif /* KERNEL */
EXT struct rx_connection *rx_connCleanup_list GLOBALSINIT(0);
EXT afs_uint32 rx_hashTableSize GLOBALSINIT(257); /* Prime number */
#ifdef RX_ENABLE_LOCKS
-EXT afs_kmutex_t rx_peerHashTable_lock;
-EXT afs_kmutex_t rx_connHashTable_lock;
+EXT afs_krwlock_t rx_peerHashTable_lock;
+EXT afs_krwlock_t rx_connHashTable_lock;
#endif /* RX_ENABLE_LOCKS */
#define CONN_HASH(host, port, cid, epoch, type) ((((cid)>>RX_CIDSHIFT)%rx_hashTableSize))
/*
- * 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
+ * Copyright (c) 2008, Your File System, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the company nor the names of its contributors may
+ * be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/* Remove this file */
+#ifndef _RX_INTERNAL_H_
+#define _RX_INTERNAL_H_
+
+#ifdef AFS_NT40_ENV
+#ifndef _WIN64
+#ifndef __cplusplus
+#include <intrin.h>
+#pragma intrinsic(_InterlockedOr)
+#pragma intrinsic(_InterlockedAnd)
+#define rx_MutexOr(object, operand, mutex) _InterlockedOr(&object, operand)
+#define rx_MutexAnd(object, operand, mutex) _InterlockedAnd(&object, operand)
+#endif
+#else
+#define rx_MutexOr(object, operand, mutex) InterlockedOr(&object, operand)
+#define rx_MutexAnd(object, operand, mutex) InterlockedAnd(&object, operand)
+#endif
+#define rx_MutexIncrement(object, mutex) InterlockedIncrement(&object)
+#define rx_MutexXor(object, operand, mutex) InterlockedXor(&object, operand)
+#define rx_MutexAdd(object, addend, mutex) InterlockedExchangeAdd(&object, addend)
+#define rx_MutexDecrement(object, mutex) InterlockedDecrement(&object)
+#define rx_MutexAdd1Increment2(object1, addend, object2, mutex) \
+ do { \
+ MUTEX_ENTER(&mutex); \
+ object1 += addend; \
+ InterlockedIncrement(&object2); \
+ MUTEX_EXIT(&mutex); \
+ } while (0)
+#define rx_MutexAdd1Decrement2(object1, addend, object2, mutex) \
+ do { \
+ MUTEX_ENTER(&mutex); \
+ object1 += addend; \
+ InterlockedDecrement(&object2); \
+ MUTEX_EXIT(&mutex); \
+ } while (0)
+#else
+#define rx_MutexIncrement(object, mutex) \
+ do { \
+ MUTEX_ENTER(&mutex); \
+ object++; \
+ MUTEX_EXIT(&mutex); \
+ } while(0)
+#define rx_MutexOr(object, operand, mutex) \
+ do { \
+ MUTEX_ENTER(&mutex); \
+ object |= operand; \
+ MUTEX_EXIT(&mutex); \
+ } while(0)
+#define rx_MutexAnd(object, operand, mutex) \
+ do { \
+ MUTEX_ENTER(&mutex); \
+ object &= operand; \
+ MUTEX_EXIT(&mutex); \
+ } while(0)
+#define rx_MutexXor(object, operand, mutex) \
+ do { \
+ MUTEX_ENTER(&mutex); \
+ object ^= operand; \
+ MUTEX_EXIT(&mutex); \
+ } while(0)
+#define rx_MutexAdd(object, addend, mutex) \
+ do { \
+ MUTEX_ENTER(&mutex); \
+ object += addend; \
+ MUTEX_EXIT(&mutex); \
+ } while(0)
+#define rx_MutexAdd1Increment2(object1, addend, object2, mutex) \
+ do { \
+ MUTEX_ENTER(&mutex); \
+ object1 += addend; \
+ object2++; \
+ MUTEX_EXIT(&mutex); \
+ } while(0)
+#define rx_MutexAdd1Decrement2(object1, addend, object2, mutex) \
+ do { \
+ MUTEX_ENTER(&mutex); \
+ object1 += addend; \
+ object2--; \
+ MUTEX_EXIT(&mutex); \
+ } while(0)
+#define rx_MutexDecrement(object, mutex) \
+ do { \
+ MUTEX_ENTER(&mutex); \
+ object--; \
+ MUTEX_EXIT(&mutex); \
+ } while(0)
+#endif
+
+#endif /* _RX_INTERNAL_H */
# include <sys/ioctl.h>
# include <sys/time.h>
#endif
+# include "rx_internal.h"
# include "rx.h"
# include "rx_globals.h"
# include <lwp.h>
#define MUTEX_ISMINE(a)
#define CV_INIT(a,b,c,d)
#define CV_DESTROY(a)
+#define RWLOCK_INIT(a, b, c, d)
+#define RWLOCK_DESTROY(l)
+#define RWLOCK_UPLOCK(l)
+#define RWLOCK_WRLOCK(l)
+#define RWLOCK_RDLOCK(l)
+#define RWLOCK_TRYWRLOCK(l) 1
+#define RWLOCK_TRYRDLOCK(l) 1
+#define RWLOCK_UNLOCK(l)
#define osirx_AssertMine(a, b)
#endif /* KERNEL */
#include <afs/errors.h>
#include "xdr.h"
#ifdef AFS_PTHREAD_ENV
+#include "rx_internal.h"
#include "rx.h"
#endif /* AFS_PTHREAD_ENV */
#include <stdlib.h>
#ifdef KERNEL
#include "afs/sysincludes.h"
+#include "rx/rx_internal.h"
#include "rx/rx.h"
#else /* KERNEL */
+# include "rx_internal.h"
# include "rx.h"
#endif /* KERNEL */
#else /* !UKERNEL */
#include "afs/sysincludes.h"
#endif /* !UKERNEL */
+#include "rx/rx_internal.h"
#include "rx/rx.h"
#else /* KERNEL */
+#include "rx_internal.h"
#include "rx.h"
#endif /* KERNEL */
#include <netinet/in.h>
#endif
#include "rx_clock.h"
+#include "rx_internal.h"
#include "rx.h"
#include "rx_queue.h"
#ifdef AFS_SUN5_ENV
(void)IOMGR_Poll();
#endif
#endif
- MUTEX_ENTER(&rx_connHashTable_lock);
+ RWLOCK_RDLOCK(&rx_connHashTable_lock);
/* We might be slightly out of step since we are not
* locking each call, but this is only debugging output.
*/
sizeof(afs_int32); i++)
DOHTONL(sparel[i]);
}
-
- MUTEX_EXIT(&rx_connHashTable_lock);
+
+ RWLOCK_UNLOCK(&rx_connHashTable_lock);
rx_packetwrite(ap, 0, sizeof(struct rx_debugConn),
(char *)&tconn);
tl = ap->length;
return ap;
}
}
- MUTEX_EXIT(&rx_connHashTable_lock);
+ RWLOCK_UNLOCK(&rx_connHashTable_lock);
}
/* if we make it here, there are no interesting packets */
tconn.cid = htonl(0xffffffff); /* means end */
(void)IOMGR_Poll();
#endif
#endif
- MUTEX_ENTER(&rx_peerHashTable_lock);
+ RWLOCK_RDLOCK(&rx_peerHashTable_lock);
+ /* XXX should copy out, then unlock and byteswap */
for (tp = rx_peerHashTable[i]; tp; tp = tp->next) {
if (tin.index-- <= 0) {
tpeer.host = tp->host;
tpeer.bytesReceived.low =
htonl(tp->bytesReceived.low);
- MUTEX_EXIT(&rx_peerHashTable_lock);
+ RWLOCK_UNLOCK(&rx_peerHashTable_lock);
rx_packetwrite(ap, 0, sizeof(struct rx_debugPeer),
(char *)&tpeer);
tl = ap->length;
return ap;
}
}
- MUTEX_EXIT(&rx_peerHashTable_lock);
+ RWLOCK_UNLOCK(&rx_peerHashTable_lock);
}
/* if we make it here, there are no interesting packets */
tpeer.host = htonl(0xffffffff); /* means end */
# include <sys/time.h>
#endif
#include <sys/stat.h>
+#include "rx_internal.h"
#include <rx/rx.h>
#include <rx/rx_globals.h>
#include <assert.h>
dpf(("Unable to create Rx event handling thread\n"));
exit(1);
}
- MUTEX_ENTER(&rx_stats_mutex);
- ++rxi_pthread_hinum;
- MUTEX_EXIT(&rx_stats_mutex);
+ rx_MutexIncrement(rxi_pthread_hinum, rx_stats_mutex);
AFS_SIGSET_RESTORE();
assert(pthread_mutex_lock(&listener_mutex) == 0);
dpf(("Unable to create socket listener thread\n"));
exit(1);
}
- MUTEX_ENTER(&rx_stats_mutex);
- ++rxi_pthread_hinum;
- MUTEX_EXIT(&rx_stats_mutex);
+ rx_MutexIncrement(rxi_pthread_hinum, rx_stats_mutex);
AFS_SIGSET_RESTORE();
return 0;
}
#include <pthread.h>
typedef pthread_mutex_t afs_kmutex_t;
+typedef pthread_rwlock_t afs_krwlock_t;
typedef pthread_cond_t afs_kcondvar_t;
#ifdef RX_ENABLE_LOCKS
#define MUTEX_ISMINE(l) (pthread_mutex_trylock(l) == EDEADLK)
#include <pthread.h>
typedef pthread_mutex_t afs_kmutex_t;
+typedef pthread_rwlock_t afs_krwlock_t;
typedef pthread_cond_t afs_kcondvar_t;
#if !defined(pthread_yield) && defined(AFS_SUN5_ENV)
extern void osirx_AssertMine(afs_kmutex_t * lockaddr, char *msg);
#ifdef AFS_PTHREAD_ENV
+#if !defined(PTHREAD_RWLOCK_INITIALIZER) && defined(AFS_DARWIN80_ENV)
+#define PTHREAD_RWLOCK_INITIALIZER {0x2DA8B3B4, {0}}
+#endif
+
#ifdef MUTEX_INIT
#undef MUTEX_INIT
#endif
#endif
#define CV_BROADCAST(cv) osi_Assert(pthread_cond_broadcast(cv) == 0)
+#ifdef RWLOCK_INIT
+#undef RWLOCK_INIT
+#endif
+#define RWLOCK_INIT(a, b, c, d) osi_Assert(pthread_rwlock_init(a, NULL) == 0)
+
+#ifdef RWLOCK_DESTROY
+#undef RWLOCK_DESTROY
+#endif
+#define RWLOCK_DESTROY(l) osi_Assert(pthread_rwlock_destroy(l) == 0)
+
+#ifdef RWLOCK_UPLOCK
+#undef RWLOCK_UPLOCK
+#endif
+#define RWLOCK_UPLOCK(l) do {osi_Assert(pthread_rwlock_unlock(l) == 0); osi_Assert(pthread_rwlock_wrlock(l) == 0);} while (0)
+
+#ifdef RWLOCK_WRLOCK
+#undef RWLOCK_WRLOCK
+#endif
+#define RWLOCK_WRLOCK(l) osi_Assert(pthread_rwlock_wrlock(l) == 0)
+
+#ifdef RWLOCK_RDLOCK
+#undef RWLOCK_RDLOCK
+#endif
+#define RWLOCK_RDLOCK(l) osi_Assert(pthread_rwlock_rdlock(l) == 0)
+
+#ifdef RWLOCK_TRYWRLOCK
+#undef RWLOCK_TRYWRLOCK
+#endif
+#define RWLOCK_TRYWRLOCK(l) pthread_rwlock_trywrlock(l) ? 0 : 1
+
+#ifdef RWLOCK_TRYRDLOCK
+#undef RWLOCK_TRYRDLOCK
+#endif
+#define RWLOCK_TRYRDLOCK(l) pthread_rwlock_tryrdlock(l) ? 0 : 1
+
+#ifdef RWLOCK_UNLOCK
+#undef RWLOCK_UNLOCK
+#endif
+#define RWLOCK_UNLOCK(l) osi_Assert(pthread_rwlock_unlock(l) == 0)
+
#endif /* AFS_PTHREAD_ENV */
#include "rx/rx_kernel.h"
#include "rx/rx_clock.h"
#include "rx/rx_queue.h"
+#include "rx/rx_internal.h"
#include "rx/rx.h"
#include "rx/rx_globals.h"
#include "afs/lock.h"
# include "rx_user.h"
# include "rx_clock.h"
# include "rx_queue.h"
+# include "rx_internal.h"
# include "rx.h"
# include "rx_globals.h"
#endif /* KERNEL */
#include <sys/file.h>
#include <unistd.h>
#endif
+#include "rx_internal.h"
#include "rx.h"
#include "rx_globals.h"
#include "rx_trace.h"
#ifndef AFS_NT40_ENV
# include <sys/time.h>
#endif
+# include "rx_internal.h"
# include "rx.h"
# include "rx_globals.h"
#include <winsock2.h>
+#include "rx_internal.h"
#include "rx.h"
#include "rx_packet.h"
#include "rx_globals.h"
#include <stdio.h>
#endif
#include "xdr.h"
+#include "rx_internal.h"
#include "rx.h"
/*
*/
#include <afsconfig.h>
#include <afs/param.h>
+#include "rx_internal.h"
#include "rx.h"
RCSID
*/
#include <afsconfig.h>
#include <afs/param.h>
+#include "rx_internal.h"
#include "rx.h"
RCSID
#include "rpc/types.h"
#include "rpc/xdr.h"
#endif /* !UKERNEL */
+#include "rx/rx_internal.h"
#include "rx/rx.h"
#else /* KERNEL */
#ifndef AFS_NT40_ENV
#include <netinet/in.h>
#endif
+#include "rx_internal.h"
#include "rx.h"
#include "xdr.h"
#endif /* KERNEL */