Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[fix] bslmongo: lazy creation of db table.

Since we can't specify inter-plugin dependencies yet, we need to wait
for everything to load before executing code from other plugins.
  • Loading branch information...
commit 91669868f19dcf094d495c5739604421df015964 1 parent 382ef19
@arthuraa arthuraa authored
Showing with 15 additions and 3 deletions.
  1. +15 −3 plugins/mongo/bslMongo.nodejs
View
18 plugins/mongo/bslMongo.nodejs
@@ -239,7 +239,19 @@ function getbool(b, dflt) {
return un_uniformize_bool(b)
}
-var databaseTable = new SimpleTable();
+// HACK: since we globalize package exports now and
+// we have no inter-plugin dependencies, we can't force
+// BslMongo to execute after opabsl is loaded. Therefore,
+// we need to make a lazy databaseTable.
+
+var databaseTable;
+
+function getDatabaseTable() {
+ if (typeof(databaseTable) == 'undefined') {
+ databaseTable = BslHashtbl_create();
+ }
+ return databaseTable;
+}
exports.server = BslMongo_NodeMongo_server
##register server : string, int, bool, int -> NodeMongo.server
@@ -276,11 +288,11 @@ exports.open = BslMongo_NodeMongo_open
continuation(tuple_2(string, NodeMongo.db)) -> void
##args(server, name, slaveok, k)
{
- var barrier = databaseTable.get(name);
+ var barrier = getDatabaseTable().get(name);
if(barrier == null){
var db = new Db(name, server, {slaveok: un_uniformize_bool(slaveok)});
barrier = new Barrier("mongo_database:"+name);
- databaseTable.put(name, barrier);
+ getDatabaseTable().put(name, barrier);
db.open(function(err, db){
var result;
if (err == null){

0 comments on commit 9166986

Please sign in to comment.
Something went wrong with that request. Please try again.