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.
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 handlerfinalizer
which will try to close the connection. When thefinalizer
is called, the connection has been closed. At this time, calledmongoc_client_destroy
will release the error "segmentation fault".To solve, I implemented the
MongoClient._closed
attribute and whenMongo.destroy
is invoked, the function will check the value of the attribute. If you havefalse
callsmongoc_client_destroy
and changes the value of_closed
totrue
. When Julia calledfinalizer
, themongoc_client_destroy
will not be called again.