Index: library/mongodb/README =================================================================== diff -u -r8e1d57baef8faa271aa354b70bd9d86076001539 -rb7029a446ac0be8caf5c230a7d022e72426040d3 --- library/mongodb/README (.../README) (revision 8e1d57baef8faa271aa354b70bd9d86076001539) +++ library/mongodb/README (.../README) (revision b7029a446ac0be8caf5c230a7d022e72426040d3) @@ -28,7 +28,7 @@ rm -rf mongo-c-driver ln -s mongo-c-driver-1.5.1 mongo-c-driver cd mongo-c-driver - ./configure --disable-sasl + ./configure --disable-automatic-init-and-cleanup make sudo make install @@ -37,7 +37,7 @@ cd /usr/local/src git clone https://github.com/mongodb/mongo-c-driver cd mongo-c-driver - sh autogen.sh --disable-sasl + sh autogen.sh --disable-automatic-init-and-cleanup make sudo make install @@ -47,9 +47,9 @@ If configure complains about not finding bson, you might have to do export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig - Version 1.5.1 of the c-driver leads on Mac OS X to a crash on exit, - when configured sasl support (from mac ports). Therefore, the - configure switch "--disable-sasl" is recommended for the time being. + Note: Version 1.5.1 of the c-driver leads on Mac OS X to a crash on + exit, when configured sasl support (from mac ports) and the flag + "--disable-automatic-init-and-cleanup" is mossing. COMPILING THE MONGO NSF INTERFACE: Index: library/mongodb/nsfmongo.c =================================================================== diff -u -r234590549e5597c7df7538439f7a75c2ca765826 -rb7029a446ac0be8caf5c230a7d022e72426040d3 --- library/mongodb/nsfmongo.c (.../nsfmongo.c) (revision 234590549e5597c7df7538439f7a75c2ca765826) +++ library/mongodb/nsfmongo.c (.../nsfmongo.c) (revision b7029a446ac0be8caf5c230a7d022e72426040d3) @@ -1726,6 +1726,11 @@ Tcl_DeleteThreadExitHandler(Nsfmongo_ThreadExit, clientData); #endif Tcl_Release(clientData); + + /* + * Release the state of mongo-c-driver explicitly. + */ + mongoc_cleanup(); } @@ -1773,15 +1778,21 @@ #endif /* - * Register global mongo Tcl_Objs. + * Register global mongo Tcl_Objs once. */ NsfMutexLock(&initMutex); if (NsfMongoGlobalObjs == NULL) { NsfMongoGlobalObjs = (Tcl_Obj **)ckalloc(sizeof(Tcl_Obj*)*nr_elements(NsfMongoGlobalStrings)); + for (i = 0; i < nr_elements(NsfMongoGlobalStrings); i++) { NsfMongoGlobalObjs[i] = Tcl_NewStringObj(NsfMongoGlobalStrings[i], -1); Tcl_IncrRefCount(NsfMongoGlobalObjs[i]); } + + /* + * Initializing state of mongo-c-driver explicitly. + */ + mongoc_init(); } NsfMutexUnlock(&initMutex); @@ -1804,11 +1815,12 @@ /* * Create all method commands (will use the namespaces above) */ - for (i=0; i < nr_elements(method_definitions)-1; i++) { + for (i = 0; i < nr_elements(method_definitions)-1; i++) { Tcl_CreateObjCommand(interp, method_definitions[i].methodName, method_definitions[i].proc, 0, 0); } Tcl_SetIntObj(Tcl_GetObjResult(interp), 1); + return TCL_OK; }