]> rtime.felk.cvut.cz Git - orte.git/commitdiff
JORTE: document hack that 'bypasses' erratic bug in liborte
authorMartin Vajnar <martin.vajnar@gmail.com>
Sat, 2 May 2015 13:24:55 +0000 (15:24 +0200)
committerMartin Vajnar <martin.vajnar@gmail.com>
Fri, 22 May 2015 11:33:21 +0000 (13:33 +0200)
The recvCallBack() could sometimes be invoked even after subscription's
destruction. In order to avoid dereferencing pointer to free()'d memory we
use this 'intermediary' pointer and during subscription destruction we
set it to null and test this value in recvCallBack().

orte/libjorte/JORTESubscriptionCreate.c
orte/libjorte/JORTESubscriptionDestroy.c

index e5d37ad41c5707f927bd8757db690f74b543e04c..f93d9e452f9f27db77d9a82cedf27fb007dcc96a 100644 (file)
@@ -54,7 +54,7 @@ recvCallBack(const ORTERecvInfo *info, void *vinstance, void *recvCallBackParam)
 
   JORTECallbackContext_t   *callback_cont;
 
-  // if the subscriber has been destroyed, return
+  // HACK: if the subscriber has been destroyed, return
   if ((*(JORTECallbackContext_t **)recvCallBackParam) == 0)
     return;
 
@@ -194,6 +194,8 @@ Java_org_ocera_orte_Subscription_jORTESubscriptionCreate
   void                   *buffer;
   int                     flag_ok = 0;
 
+  /* HACK: allocate space for callback context structure and than for a pointer to it */
+
   // memory alocation
   // don't forget use free() funct.!!
   callback_cont = (JORTECallbackContext_t *)malloc(sizeof(JORTECallbackContext_t));
index d499f6801da2c19b79402f11311e676fb8a1dd0c..f3ce893e2371e5fb04365ac28cb80965ca295aae 100644 (file)
@@ -88,8 +88,12 @@ Java_org_ocera_orte_Subscription_jORTESubscriptionDestroy
     if (h) {
       //JavaVM *jvm;
       //jint ret;
+
+      /* HACK */
       JORTECallbackContext_t *ctx = *((JORTECallbackContext_t **)h);
       *((JORTECallbackContext_t **)h) = 0;
+      /**/
+
       if (ctx->obj) {
        #ifdef TEST_STAGE
        printf(":c: deleting ctx->obj \n");