# HG changeset patch # User Merten Sach # Date 1317209617 -7200 # Node ID 412574e3da5ec3cd68a06890d12843e1b4f80a0c # Parent a82c0a48cdba7d6cff9833b863b5ce3a81d99474 Bugfix: Requests to hashtable weren't always cloned diff -r a82c0a48cdba -r 412574e3da5e SSR_PluginFns.c --- a/SSR_PluginFns.c Tue Sep 27 17:58:45 2011 +0200 +++ b/SSR_PluginFns.c Wed Sep 28 13:33:37 2011 +0200 @@ -80,7 +80,7 @@ case dissipate: handleDissipate( requestingPr, semEnv); break; case VMSSemantic: VMS__handle_VMSSemReq(req, requestingPr, semEnv, - &resume_procr); + (ResumePrFnPtr)&resume_procr); break; default: break; diff -r a82c0a48cdba -r 412574e3da5e SSR_Request_Handlers.c --- a/SSR_Request_Handlers.c Tue Sep 27 17:58:45 2011 +0200 +++ b/SSR_Request_Handlers.c Wed Sep 28 13:33:37 2011 +0200 @@ -11,6 +11,7 @@ #include "VMS/Queue_impl/PrivateQueue.h" #include "VMS/Hash_impl/PrivateHash.h" #include "SSR.h" +#include "SSR_Request_Handlers.h" @@ -28,7 +29,7 @@ SSRSemReq * cloneReq( SSRSemReq *semReq ) { SSRSemReq *clonedReq; - + clonedReq = VMS__malloc( sizeof(SSRSemReq) ); clonedReq->reqType = semReq->reqType; clonedReq->sendPr = semReq->sendPr; @@ -44,7 +45,7 @@ { HashEntry *entry; SSRSemReq *waitingReq; - entry = getEntryFromTable( (char *)key, commHashTbl ); + entry = getEntryFromTable( key, commHashTbl ); if( entry == NULL ) { //no waiting sends or receives, so add this request and exit // note: have to clone the request because it's on stack of sender @@ -54,7 +55,7 @@ waitingReq = (SSRSemReq *)entry->content; if( waitingReq == NULL ) //might happen when last waiting gets paired { //no waiting sends or receives, so add this request and exit - entry->content = semReq; + entry->content = cloneReq(semReq); return NULL; } return entry; @@ -84,8 +85,8 @@ void handleSendType( SSRSemReq *semReq, SSRSemEnv *semEnv ) { VirtProcr *sendPr, *receivePr; - int key[] = {0,0,0}; - SSRSemReq *waitingReq; + hashkey_t key; + SSRSemReq *waitingReq; HashEntry *entry; HashTable *commHashTbl = semEnv->commHashTbl; @@ -98,12 +99,10 @@ // *freed* -- this is bad. Want to stack up values in a linked // list when multiple have the same key. - //TODO: use a faster hash function -- see notes in intelligence gather - key[0] = (int)receivePr->procrID; - key[1] = (int)(semReq->msgType); - //key[2] acts as the 0 that terminates the string + key.parts[0] = (int)receivePr->procrID; + key.parts[1] = (int)(semReq->msgType); - entry = giveEntryElseInsertReqst( (char *)key, semReq, commHashTbl); + entry = giveEntryElseInsertReqst( (char*)&key, semReq, commHashTbl); if( entry == NULL ) return; //was just inserted waitingReq = (SSRSemReq *)entry->content; @@ -153,26 +152,26 @@ void handleSendFromTo( SSRSemReq *semReq, SSRSemEnv *semEnv) { VirtProcr *sendPr, *receivePr; - int key[] = {0,0,0}; - SSRSemReq *waitingReq; + hashkey_t key; + SSRSemReq *waitingReq; HashEntry *entry; HashTable *commHashTbl = semEnv->commHashTbl; receivePr = semReq->receivePr; //For "send", know both send & recv procrs sendPr = semReq->sendPr; - key[0] = (int)receivePr->procrID; - key[1] = (int)sendPr->procrID; - //key[2] acts at the 0 that terminates the string + key.parts[0] = (int)receivePr->procrID; + key.parts[1] = (int)sendPr->procrID; - entry = giveEntryElseInsertReqst( (char *)key, semReq, commHashTbl); + entry = giveEntryElseInsertReqst( (char*)&key, semReq, commHashTbl); if( entry == NULL ) return; //was just inserted waitingReq = (SSRSemReq *)entry->content; //At this point, know have waiting request(s) -- either sends or recv if( waitingReq->reqType == send_from_to ) - { printf("\n ERROR: shouldn't be two send-from-tos waiting \n"); + { + printf("\n ERROR: shouldn't be two send-from-tos waiting \n"); } else { //waiting request is a receive, so it completes pair with this send @@ -183,7 +182,7 @@ //can only be one waiting req for "from-to" semantics if( entry->content != NULL ) { - printf("\nERROR in handleSendFromTo\n"); + printf("\nERROR in handleSendFromTo\n"); } deleteEntryFromTable( entry->key, commHashTbl ); //frees HashEntry @@ -239,19 +238,18 @@ void handleReceiveType( SSRSemReq *semReq, SSRSemEnv *semEnv) { VirtProcr *sendPr, *receivePr; - int key[] = {0,0,0}; - SSRSemReq *waitingReq; + hashkey_t key; + SSRSemReq *waitingReq; HashEntry *entry; HashTable *commHashTbl = semEnv->commHashTbl; receivePr = semReq->receivePr; - key[0] = (int)receivePr->procrID; - key[1] = (int)(semReq->msgType); - //key[2] acts as the 0 that terminates the string + key.parts[0] = (int)receivePr->procrID; + key.parts[1] = (int)(semReq->msgType); - entry = giveEntryElseInsertReqst((char*)key, semReq, commHashTbl);//clones + entry = giveEntryElseInsertReqst((char*)&key, semReq, commHashTbl);//clones if( entry == NULL ) return; //was just inserted waitingReq = (SSRSemReq *)entry->content; //previously cloned by insert @@ -287,19 +285,18 @@ void handleReceiveFromTo( SSRSemReq *semReq, SSRSemEnv *semEnv) { VirtProcr *sendPr, *receivePr; - int key[] = {0,0,0}; - SSRSemReq *waitingReq; + hashkey_t key; + SSRSemReq *waitingReq; HashEntry *entry; HashTable *commHashTbl = semEnv->commHashTbl; receivePr = semReq->receivePr; sendPr = semReq->sendPr; //for receive from-to, know send procr - key[0] = (int)receivePr->procrID; - key[1] = (int)sendPr->procrID; - //key[2] acts at the 0 that terminates the string + key.parts[0] = (int)receivePr->procrID; + key.parts[1] = (int)sendPr->procrID; - entry = giveEntryElseInsertReqst( (char *)key, semReq, commHashTbl); + entry = giveEntryElseInsertReqst( (char*)&key, semReq, commHashTbl); if( entry == NULL ) return; //was just inserted waitingReq = (SSRSemReq *)entry->content; diff -r a82c0a48cdba -r 412574e3da5e SSR_lib.c --- a/SSR_lib.c Tue Sep 27 17:58:45 2011 +0200 +++ b/SSR_lib.c Wed Sep 28 13:33:37 2011 +0200 @@ -245,24 +245,11 @@ */ void SSR__cleanup_after_shutdown() - { SSRSemEnv *semanticEnv; - int coreIdx; - -/* It's all allocated inside VMS's big chunk -- that's about to be freed, so - * nothing to do here - semanticEnv = _VMSMasterEnv->semanticEnv; - - for( coreIdx = 0; coreIdx < NUM_CORES; coreIdx++ ) - { - VMS__free( semanticEnv->readyVPQs[coreIdx]->startOfData ); - VMS__free( semanticEnv->readyVPQs[coreIdx] ); - } - VMS__free( semanticEnv->readyVPQs ); - - freeHashTable( semanticEnv->commHashTbl ); - VMS__free( _VMSMasterEnv->semanticEnv ); - */ - VMS__cleanup_at_end_of_shutdown(); + { + /* It's all allocated inside VMS's big chunk -- that's about to be freed, so + * nothing to do here + */ + VMS__cleanup_at_end_of_shutdown(); } @@ -439,7 +426,7 @@ void * SSR__receive_any_to( VirtProcr *receivePr ) { - + return NULL; } void * @@ -567,7 +554,6 @@ VMS__send_sem_request( &reqData, animPr ); -EndSingletonInstrAddr: return; }