From 7bb451bb74dc5d749e48d4d9adf62953f6585b10 Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Mon, 14 Nov 1994 18:47:18 +0000 Subject: [PATCH] updated for changes in bucketLib.c --- src/rsrv/camessage.c | 30 +++++++++++++++++++----------- src/rsrv/camsgtask.c | 1 - src/rsrv/caservertask.c | 4 +++- src/rsrv/cast_server.c | 5 +++-- src/rsrv/server.h | 16 ++++++++++++++-- 5 files changed, 39 insertions(+), 17 deletions(-) diff --git a/src/rsrv/camessage.c b/src/rsrv/camessage.c index f38c49ee3..954be9963 100644 --- a/src/rsrv/camessage.c +++ b/src/rsrv/camessage.c @@ -182,7 +182,7 @@ LOCAL void access_rights_reply( struct channel_in_use *pciu ); -LOCAL unsigned long bucketID; +LOCAL unsigned bucketID; /* @@ -204,7 +204,7 @@ struct message_buffer *recv struct channel_in_use *pciu; if(!pCaBucket){ - pCaBucket = bucketCreate(NBBY*sizeof(mp->m_cid)); + pCaBucket = bucketCreate(CAS_HASH_TABLE_SIZE); if(!pCaBucket){ return ERROR; } @@ -1183,7 +1183,7 @@ struct client *client } FASTLOCK(&rsrv_free_addrq_lck); - status = bucketRemoveItem(pCaBucket, pciu->sid, pciu); + status = bucketRemoveItemUnsignedId (pCaBucket, &pciu->sid); if(status != BUCKET_SUCCESS){ logBadId(client, mp); } @@ -1544,12 +1544,12 @@ struct client *client ) { struct extmsg *search_reply; - struct extmsg *get_reply; unsigned short *pMinorVersion; int status; struct db_addr tmp_addr; struct channel_in_use *pchannel; - unsigned long sid; + unsigned sid; + unsigned *pCID; @@ -1606,7 +1606,11 @@ struct client *client pchannel->ticks_at_creation = tickGet(); pchannel->addr = tmp_addr; pchannel->client = client; - pchannel->cid = mp->m_cid; + /* + * bypass read only warning + */ + pCID = (unsigned *) &pchannel->cid; + *pCID = mp->m_cid; /* * allocate a server id and enter the channel pointer @@ -1614,8 +1618,12 @@ struct client *client */ FASTLOCK(&rsrv_free_addrq_lck); sid = bucketID++; - pchannel->sid = sid; - status = bucketAddItem(pCaBucket, sid, pchannel); + /* + * bypass read only warning + */ + pCID = (unsigned *) &pchannel->sid; + *pCID = sid; + status = bucketAddItemUnsignedId (pCaBucket, &pchannel->sid, pchannel); FASTUNLOCK(&rsrv_free_addrq_lck); if(status!=BUCKET_SUCCESS){ SEND_LOCK(client); @@ -1905,10 +1913,11 @@ struct client *pc */ LOCAL struct channel_in_use *MPTOPCIU(struct extmsg *mp) { - struct channel_in_use *pciu; + struct channel_in_use *pciu; + const unsigned id = mp->m_cid; FASTLOCK(&rsrv_free_addrq_lck); - pciu = bucketLookupItem(pCaBucket, mp->m_cid); + pciu = bucketLookupItemUnsignedId (pCaBucket, &id); FASTUNLOCK(&rsrv_free_addrq_lck); return pciu; @@ -1926,7 +1935,6 @@ LOCAL void casAccessRightsCB(ASCLIENTPVT ascpvt, asClientStatus type) struct client *pclient; struct channel_in_use *pciu; struct event_ext *pevext; - int status; pciu = asGetClientPvt(ascpvt); assert(pciu); diff --git a/src/rsrv/camsgtask.c b/src/rsrv/camsgtask.c index 8890ac34e..597256cb7 100644 --- a/src/rsrv/camsgtask.c +++ b/src/rsrv/camsgtask.c @@ -78,7 +78,6 @@ FAST int sock; int nchars; FAST int status; FAST struct client *client; - int i; int true = TRUE; client = NULL; diff --git a/src/rsrv/caservertask.c b/src/rsrv/caservertask.c index b815c4ad7..9c731a097 100644 --- a/src/rsrv/caservertask.c +++ b/src/rsrv/caservertask.c @@ -315,7 +315,9 @@ LOCAL int terminate_one_client(struct client *client) free(pciu->pPutNotify); } FASTLOCK(&rsrv_free_addrq_lck); - status = bucketRemoveItem(pCaBucket, pciu->sid, pciu); + status = bucketRemoveItemUnsignedId ( + pCaBucket, + &pciu->sid); FASTUNLOCK(&rsrv_free_addrq_lck); if(status != BUCKET_SUCCESS){ logMsg( diff --git a/src/rsrv/cast_server.c b/src/rsrv/cast_server.c index 638884a58..db4fe0cb2 100644 --- a/src/rsrv/cast_server.c +++ b/src/rsrv/cast_server.c @@ -339,11 +339,12 @@ LOCAL void clean_addrq() } if (delay > timeout) { - int status; ellDelete(&prsrv_cast_client->addrq, &pciu->node); FASTLOCK(&rsrv_free_addrq_lck); - s = bucketRemoveItem(pCaBucket, pciu->sid, pciu); + s = bucketRemoveItemUnsignedId ( + pCaBucket, + &pciu->sid); if(s != BUCKET_SUCCESS){ logMsg( "%s Bad id at close", diff --git a/src/rsrv/server.h b/src/rsrv/server.h index 3cb5a6e7f..d9b009b5b 100644 --- a/src/rsrv/server.h +++ b/src/rsrv/server.h @@ -45,6 +45,14 @@ static char *serverhSccsId = "@(#)server.h 1.19 5/6/94"; +#if defined(CAS_VERSION_GLOBAL) && 0 +# define HDRVERSIONID(NAME,VERS) VERSIONID(NAME,VERS) +#else /*CAS_VERSION_GLOBAL*/ +# define HDRVERSIONID(NAME,VERS) +#endif /*CAS_VERSION_GLOBAL*/ + +typedef int SOCKET; + #include #include #include @@ -54,6 +62,7 @@ static char *serverhSccsId = "@(#)server.h 1.19 5/6/94"; #include #include #include +#include #include #include @@ -112,8 +121,8 @@ struct channel_in_use{ ELLLIST eventq; struct client *client; RSRVPUTNOTIFY *pPutNotify; /* potential active put notify */ - unsigned long cid; /* client id */ - unsigned long sid; /* server id */ + const unsigned cid; /* client id */ + const unsigned sid; /* server id */ unsigned long ticks_at_creation; /* for UDP timeout */ struct db_addr addr; ASCLIENTPVT asClientPVT; @@ -158,6 +167,9 @@ GLBLTYPE FAST_LOCK rsrv_free_addrq_lck; GLBLTYPE FAST_LOCK rsrv_free_eventq_lck; GLBLTYPE struct client *prsrv_cast_client; GLBLTYPE BUCKET *pCaBucket; + +#define CAS_HASH_TABLE_SIZE 4096 + /* * set true if max memory block drops below MAX_BLOCK_THRESHOLD */