Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > SSR_impls > SSR__MC_shared_impl
changeset 37:412574e3da5e
Bugfix: Requests to hashtable weren't always cloned
| author | Merten Sach <msach@mailbox.tu-berlin.de> |
|---|---|
| date | Wed, 28 Sep 2011 13:33:37 +0200 |
| parents | a82c0a48cdba |
| children | ecc95d6a413d |
| files | SSR_PluginFns.c SSR_Request_Handlers.c SSR_lib.c |
| diffstat | 3 files changed, 34 insertions(+), 51 deletions(-) [+] |
line diff
1.1 --- a/SSR_PluginFns.c Tue Sep 27 17:58:45 2011 +0200 1.2 +++ b/SSR_PluginFns.c Wed Sep 28 13:33:37 2011 +0200 1.3 @@ -80,7 +80,7 @@ 1.4 case dissipate: handleDissipate( requestingPr, semEnv); 1.5 break; 1.6 case VMSSemantic: VMS__handle_VMSSemReq(req, requestingPr, semEnv, 1.7 - &resume_procr); 1.8 + (ResumePrFnPtr)&resume_procr); 1.9 break; 1.10 default: 1.11 break;
2.1 --- a/SSR_Request_Handlers.c Tue Sep 27 17:58:45 2011 +0200 2.2 +++ b/SSR_Request_Handlers.c Wed Sep 28 13:33:37 2011 +0200 2.3 @@ -11,6 +11,7 @@ 2.4 #include "VMS/Queue_impl/PrivateQueue.h" 2.5 #include "VMS/Hash_impl/PrivateHash.h" 2.6 #include "SSR.h" 2.7 +#include "SSR_Request_Handlers.h" 2.8 2.9 2.10 2.11 @@ -28,7 +29,7 @@ 2.12 SSRSemReq * 2.13 cloneReq( SSRSemReq *semReq ) 2.14 { SSRSemReq *clonedReq; 2.15 - 2.16 + 2.17 clonedReq = VMS__malloc( sizeof(SSRSemReq) ); 2.18 clonedReq->reqType = semReq->reqType; 2.19 clonedReq->sendPr = semReq->sendPr; 2.20 @@ -44,7 +45,7 @@ 2.21 { HashEntry *entry; 2.22 SSRSemReq *waitingReq; 2.23 2.24 - entry = getEntryFromTable( (char *)key, commHashTbl ); 2.25 + entry = getEntryFromTable( key, commHashTbl ); 2.26 if( entry == NULL ) 2.27 { //no waiting sends or receives, so add this request and exit 2.28 // note: have to clone the request because it's on stack of sender 2.29 @@ -54,7 +55,7 @@ 2.30 waitingReq = (SSRSemReq *)entry->content; 2.31 if( waitingReq == NULL ) //might happen when last waiting gets paired 2.32 { //no waiting sends or receives, so add this request and exit 2.33 - entry->content = semReq; 2.34 + entry->content = cloneReq(semReq); 2.35 return NULL; 2.36 } 2.37 return entry; 2.38 @@ -84,8 +85,8 @@ 2.39 void 2.40 handleSendType( SSRSemReq *semReq, SSRSemEnv *semEnv ) 2.41 { VirtProcr *sendPr, *receivePr; 2.42 - int key[] = {0,0,0}; 2.43 - SSRSemReq *waitingReq; 2.44 + hashkey_t key; 2.45 + SSRSemReq *waitingReq; 2.46 HashEntry *entry; 2.47 HashTable *commHashTbl = semEnv->commHashTbl; 2.48 2.49 @@ -98,12 +99,10 @@ 2.50 // *freed* -- this is bad. Want to stack up values in a linked 2.51 // list when multiple have the same key. 2.52 2.53 - //TODO: use a faster hash function -- see notes in intelligence gather 2.54 - key[0] = (int)receivePr->procrID; 2.55 - key[1] = (int)(semReq->msgType); 2.56 - //key[2] acts as the 0 that terminates the string 2.57 + key.parts[0] = (int)receivePr->procrID; 2.58 + key.parts[1] = (int)(semReq->msgType); 2.59 2.60 - entry = giveEntryElseInsertReqst( (char *)key, semReq, commHashTbl); 2.61 + entry = giveEntryElseInsertReqst( (char*)&key, semReq, commHashTbl); 2.62 if( entry == NULL ) return; //was just inserted 2.63 2.64 waitingReq = (SSRSemReq *)entry->content; 2.65 @@ -153,26 +152,26 @@ 2.66 void 2.67 handleSendFromTo( SSRSemReq *semReq, SSRSemEnv *semEnv) 2.68 { VirtProcr *sendPr, *receivePr; 2.69 - int key[] = {0,0,0}; 2.70 - SSRSemReq *waitingReq; 2.71 + hashkey_t key; 2.72 + SSRSemReq *waitingReq; 2.73 HashEntry *entry; 2.74 HashTable *commHashTbl = semEnv->commHashTbl; 2.75 2.76 receivePr = semReq->receivePr; //For "send", know both send & recv procrs 2.77 sendPr = semReq->sendPr; 2.78 2.79 - key[0] = (int)receivePr->procrID; 2.80 - key[1] = (int)sendPr->procrID; 2.81 - //key[2] acts at the 0 that terminates the string 2.82 + key.parts[0] = (int)receivePr->procrID; 2.83 + key.parts[1] = (int)sendPr->procrID; 2.84 2.85 - entry = giveEntryElseInsertReqst( (char *)key, semReq, commHashTbl); 2.86 + entry = giveEntryElseInsertReqst( (char*)&key, semReq, commHashTbl); 2.87 if( entry == NULL ) return; //was just inserted 2.88 2.89 waitingReq = (SSRSemReq *)entry->content; 2.90 2.91 //At this point, know have waiting request(s) -- either sends or recv 2.92 if( waitingReq->reqType == send_from_to ) 2.93 - { printf("\n ERROR: shouldn't be two send-from-tos waiting \n"); 2.94 + { 2.95 + printf("\n ERROR: shouldn't be two send-from-tos waiting \n"); 2.96 } 2.97 else 2.98 { //waiting request is a receive, so it completes pair with this send 2.99 @@ -183,7 +182,7 @@ 2.100 //can only be one waiting req for "from-to" semantics 2.101 if( entry->content != NULL ) 2.102 { 2.103 - printf("\nERROR in handleSendFromTo\n"); 2.104 + printf("\nERROR in handleSendFromTo\n"); 2.105 } 2.106 deleteEntryFromTable( entry->key, commHashTbl ); //frees HashEntry 2.107 2.108 @@ -239,19 +238,18 @@ 2.109 void 2.110 handleReceiveType( SSRSemReq *semReq, SSRSemEnv *semEnv) 2.111 { VirtProcr *sendPr, *receivePr; 2.112 - int key[] = {0,0,0}; 2.113 - SSRSemReq *waitingReq; 2.114 + hashkey_t key; 2.115 + SSRSemReq *waitingReq; 2.116 HashEntry *entry; 2.117 HashTable *commHashTbl = semEnv->commHashTbl; 2.118 2.119 receivePr = semReq->receivePr; 2.120 2.121 - key[0] = (int)receivePr->procrID; 2.122 - key[1] = (int)(semReq->msgType); 2.123 - //key[2] acts as the 0 that terminates the string 2.124 + key.parts[0] = (int)receivePr->procrID; 2.125 + key.parts[1] = (int)(semReq->msgType); 2.126 2.127 2.128 - entry = giveEntryElseInsertReqst((char*)key, semReq, commHashTbl);//clones 2.129 + entry = giveEntryElseInsertReqst((char*)&key, semReq, commHashTbl);//clones 2.130 if( entry == NULL ) return; //was just inserted 2.131 2.132 waitingReq = (SSRSemReq *)entry->content; //previously cloned by insert 2.133 @@ -287,19 +285,18 @@ 2.134 void 2.135 handleReceiveFromTo( SSRSemReq *semReq, SSRSemEnv *semEnv) 2.136 { VirtProcr *sendPr, *receivePr; 2.137 - int key[] = {0,0,0}; 2.138 - SSRSemReq *waitingReq; 2.139 + hashkey_t key; 2.140 + SSRSemReq *waitingReq; 2.141 HashEntry *entry; 2.142 HashTable *commHashTbl = semEnv->commHashTbl; 2.143 2.144 receivePr = semReq->receivePr; 2.145 sendPr = semReq->sendPr; //for receive from-to, know send procr 2.146 2.147 - key[0] = (int)receivePr->procrID; 2.148 - key[1] = (int)sendPr->procrID; 2.149 - //key[2] acts at the 0 that terminates the string 2.150 + key.parts[0] = (int)receivePr->procrID; 2.151 + key.parts[1] = (int)sendPr->procrID; 2.152 2.153 - entry = giveEntryElseInsertReqst( (char *)key, semReq, commHashTbl); 2.154 + entry = giveEntryElseInsertReqst( (char*)&key, semReq, commHashTbl); 2.155 if( entry == NULL ) return; //was just inserted 2.156 2.157 waitingReq = (SSRSemReq *)entry->content;
3.1 --- a/SSR_lib.c Tue Sep 27 17:58:45 2011 +0200 3.2 +++ b/SSR_lib.c Wed Sep 28 13:33:37 2011 +0200 3.3 @@ -245,24 +245,11 @@ 3.4 */ 3.5 void 3.6 SSR__cleanup_after_shutdown() 3.7 - { SSRSemEnv *semanticEnv; 3.8 - int coreIdx; 3.9 - 3.10 -/* It's all allocated inside VMS's big chunk -- that's about to be freed, so 3.11 - * nothing to do here 3.12 - semanticEnv = _VMSMasterEnv->semanticEnv; 3.13 - 3.14 - for( coreIdx = 0; coreIdx < NUM_CORES; coreIdx++ ) 3.15 - { 3.16 - VMS__free( semanticEnv->readyVPQs[coreIdx]->startOfData ); 3.17 - VMS__free( semanticEnv->readyVPQs[coreIdx] ); 3.18 - } 3.19 - VMS__free( semanticEnv->readyVPQs ); 3.20 - 3.21 - freeHashTable( semanticEnv->commHashTbl ); 3.22 - VMS__free( _VMSMasterEnv->semanticEnv ); 3.23 - */ 3.24 - VMS__cleanup_at_end_of_shutdown(); 3.25 + { 3.26 + /* It's all allocated inside VMS's big chunk -- that's about to be freed, so 3.27 + * nothing to do here 3.28 + */ 3.29 + VMS__cleanup_at_end_of_shutdown(); 3.30 } 3.31 3.32 3.33 @@ -439,7 +426,7 @@ 3.34 void * 3.35 SSR__receive_any_to( VirtProcr *receivePr ) 3.36 { 3.37 - 3.38 + return NULL; 3.39 } 3.40 3.41 void * 3.42 @@ -567,7 +554,6 @@ 3.43 3.44 VMS__send_sem_request( &reqData, animPr ); 3.45 3.46 -EndSingletonInstrAddr: 3.47 return; 3.48 } 3.49
