Changeset: c7d1cd0d0bbb for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c7d1cd0d0bbb
Modified Files:
        MonetDB5/src/optimizer/opt_mapreduce.mx
Branch: default
Log Message:

fix ref-counting mess after help from Stefan


diffs (81 lines):

diff -r ef56c2dc61d7 -r c7d1cd0d0bbb MonetDB5/src/optimizer/opt_mapreduce.mx
--- a/MonetDB5/src/optimizer/opt_mapreduce.mx   Wed Jun 09 14:19:44 2010 +0200
+++ b/MonetDB5/src/optimizer/opt_mapreduce.mx   Wed Jun 09 15:30:45 2010 +0200
@@ -64,7 +64,6 @@
 } mapnode;
 
 static mapnode *mapnodes;
-static BAT *cloud;
 
 static void
 MRcleanCloud()
@@ -81,9 +80,6 @@
                        GDKfree(mapnodes[i].pass);
                mapnodes[i].uri = mapnodes[i].user = mapnodes[i].pass = 0;
        }
-       if (cloud)
-               BBPreleaseref(cloud->batCacheid);
-       cloud = 0;
        mal_unset_lock(mal_contextLock, "mapreduce");
 }
 
@@ -91,6 +87,7 @@
 MRgetCloud(int *ret, str *mrcluster)
 {
        str msg;
+       BAT *cloud;
        BUN p, q;
        BATiter bi;
        char nodes[BUFSIZ];
@@ -99,20 +96,14 @@
 
        snprintf(nodes, sizeof(nodes), "*/%s/node/*", *mrcluster);
        
-       msg = RMTresolve(ret, &n);
-       if (msg ) 
+       if ((msg = RMTresolve(ret, &n)) != MAL_SUCCEED)
                return msg;
 
-       if (cloud)
-               /* cleanup remains of previous call */
-               MRcleanCloud();
-       
        mal_set_lock(mal_contextLock, "mapreduce");
        cloud = BATdescriptor(*ret); /* should succeed */
-       BBPkeepref(*ret);       /* keep if during the session */
 
        mapnodes = (mapnode*)GDKzalloc(sizeof(mapnode) * (BATcount(cloud) + 1));
-       if (mapnodes == 0) {
+       if (mapnodes == NULL) {
                BBPreleaseref(*ret);
                throw(MAL, "mapreduce.getCloud", MAL_MALLOC_FAIL);
        }
@@ -126,6 +117,8 @@
                mapcount++;
        }
 
+       BBPkeepref(*ret); /* we're done, keep for caller */
+       cloud = NULL;
        mal_unset_lock(mal_contextLock, "mapreduce");
 
        return MAL_SUCCEED;
@@ -136,13 +129,18 @@
 {
        str msg;
        int bid;
+       BAT *cloud;
+       int cnt;
 
        msg = MRgetCloud(&bid, &mrcluster);
        if (msg) {
                GDKfree(msg); /* bad programming */
                return 0;
        }
-       return (int) BATcount(cloud);
+       cloud = BATdescriptor(bid);
+       cnt = BATcount(cloud);
+       BBPreleaseref(bid); /* we're done with it */
+       return(cnt);
 }
 
 
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to