Lytol / Mongo.jl

Mongo bindings for the Julia programming language
MIT License
30 stars 37 forks source link

Fix manualy client destroy #32

Open moisespsena opened 8 years ago

moisespsena commented 8 years ago

When I run the Mongo.destroy command to close the connection manually, it is closed as expected. But end of the program, Julia will call the handler finalizer which will try to close the connection. When the finalizer is called, the connection has been closed. At this time, called mongoc_client_destroy will release the error "segmentation fault".

To solve, I implemented the MongoClient._closed attribute and when Mongo.destroy is invoked, the function will check the value of the attribute. If you have false calls mongoc_client_destroy and changes the value of _closed to true. When Julia called finalizer, the mongoc_client_destroy will not be called again.