# HG changeset patch # User James Callahan # Date 1323827767 -39600 # Node ID 9831506dcfd6df459457e0f30e9b3a0a6971833b # Parent 46f578da4ff05658011ec31017ba913a3431043a mod_storage_mongodb: move database connecting to inside driver:open diff -r 46f578da4ff0 -r 9831506dcfd6 mod_storage_mongodb/mod_storage_mongodb.lua --- a/mod_storage_mongodb/mod_storage_mongodb.lua Wed Dec 14 12:47:49 2011 +1100 +++ b/mod_storage_mongodb/mod_storage_mongodb.lua Wed Dec 14 12:56:07 2011 +1100 @@ -5,9 +5,7 @@ local mongo = require "mongo"; -local conn = mongo.Connection.New ( true ); -conn:connect ( params.server ); -conn:auth ( params ); +local conn local keyval_store = {}; keyval_store.__index = keyval_store; @@ -47,6 +45,12 @@ local driver = { name = "mongodb" }; function driver:open(store, typ) + if not conn then + conn = assert ( mongo.Connection.New ( true ) ); + assert ( conn:connect ( params.server ) ); + assert ( conn:auth ( params ) ); + end + if not typ then -- default key-value store return setmetatable({ store = store }, keyval_store); end;