Skip to content

Commit 1ca2bfa

Browse files
authored
CDRIVER-1330 remove automatic init/cleanup (#1938)
* remove automatic init/cleanup * add check that `mongoc_init` is called on client creation
1 parent 82a294f commit 1ca2bfa

19 files changed

+34
-94
lines changed

.evergreen/benchmark.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ variables:
3535
set -o errexit
3636
set -o verbose
3737
38-
cmake -DENABLE_TESTS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=mongoc -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF . && make -j8 && make install
38+
cmake -DENABLE_TESTS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=mongoc . && make -j8 && make install
3939
git clone https://github.com/mongodb/mongo-c-driver-performance.git
4040
cd mongo-c-driver-performance
4141
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=../mongoc . && make -j8

.evergreen/scripts/compile-openssl-static.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ configure_flags_append_if_not_null() {
4141
}
4242

4343
configure_flags_append "-DCMAKE_SKIP_RPATH=TRUE" # Avoid hardcoding absolute paths to dependency libraries.
44-
configure_flags_append "-DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF"
4544
configure_flags_append "-DENABLE_MAINTAINER_FLAGS=ON"
4645
configure_flags_append "-DENABLE_SSL=OPENSSL"
4746
configure_flags_append "-DOPENSSL_USE_STATIC_LIBS=ON"

.evergreen/scripts/compile-scan-build.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ configure_flags_append_if_not_null() {
3232

3333
configure_flags_append "-DCMAKE_PREFIX_PATH=${cmake_prefix_path}"
3434
configure_flags_append "-DCMAKE_SKIP_RPATH=TRUE" # Avoid hardcoding absolute paths to dependency libraries.
35-
configure_flags_append "-DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF"
3635
configure_flags_append "-DENABLE_CLIENT_SIDE_ENCRYPTION=ON"
3736
configure_flags_append "-DENABLE_DEBUG_ASSERTIONS=ON"
3837
configure_flags_append "-DENABLE_MAINTAINER_FLAGS=ON"

.evergreen/scripts/compile-std.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ configure_flags_append_if_not_null() {
4040

4141
configure_flags_append "-DCMAKE_PREFIX_PATH=${install_dir}"
4242
configure_flags_append "-DCMAKE_SKIP_RPATH=TRUE" # Avoid hardcoding absolute paths to dependency libraries.
43-
configure_flags_append "-DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF"
4443
configure_flags_append "-DENABLE_CLIENT_SIDE_ENCRYPTION=ON"
4544
configure_flags_append "-DENABLE_DEBUG_ASSERTIONS=ON"
4645
configure_flags_append "-DENABLE_MAINTAINER_FLAGS=ON"

.evergreen/scripts/compile-unix.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ configure_flags_append_if_not_null() {
6868
configure_flags_append "-DCMAKE_INSTALL_PREFIX=${install_dir}"
6969
configure_flags_append "-DCMAKE_PREFIX_PATH=${cmake_prefix_path}"
7070
configure_flags_append "-DCMAKE_SKIP_RPATH=TRUE" # Avoid hardcoding absolute paths to dependency libraries.
71-
configure_flags_append "-DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF"
7271
configure_flags_append "-DENABLE_HTML_DOCS=OFF"
7372
configure_flags_append "-DENABLE_MAINTAINER_FLAGS=ON"
7473
configure_flags_append "-DENABLE_MAN_PAGES=OFF"

CMakeLists.txt

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -186,29 +186,6 @@ mongo_bool_setting(
186186
)
187187

188188
# Deprecated options:
189-
mongo_bool_setting(
190-
ENABLE_AUTOMATIC_INIT_AND_CLEANUP
191-
"[Deprecated] Enable automatic initialization of the C driver library"
192-
DEFAULT EVAL [[
193-
set(DEFAULT OFF)
194-
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
195-
message(VERBOSE "For backwards compatibility, when using GCC the default of "
196-
"ENABLE_AUTOMATIC_INIT_AND_CLEANUP is ON")
197-
set(DEFAULT ON)
198-
endif()
199-
]]
200-
DEVEL VALUE OFF
201-
VALIDATE CODE [[
202-
if(ENABLE_AUTOMATIC_INIT_AND_CLEANUP)
203-
if(NOT CMAKE_C_COMPILER_ID STREQUAL "GNU")
204-
message(WARNING "ENABLE_AUTOMATIC_INIT_AND_CLEANUP is only supported on GCC.")
205-
endif()
206-
message(DEPRECATION
207-
"Enabling ENABLE_AUTOMATIC_INIT_AND_CLEANUP is deprecated and "
208-
"may be removed in a future release")
209-
endif()
210-
]]
211-
)
212189
mongo_bool_setting(
213190
ENABLE_EXTRA_ALIGNMENT
214191
"[Deprecated] Enable extra alignment on libbson types"

Earthfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ build:
3737
COPY +version-current/ $source_dir
3838
ENV CCACHE_HOME=/root/.cache/ccache
3939
RUN cmake -S "$source_dir" -B "$build_dir" -G "Ninja Multi-Config" \
40-
-D ENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF \
4140
-D ENABLE_MAINTAINER_FLAGS=ON \
4241
-D ENABLE_SHM_COUNTERS=ON \
4342
-D ENABLE_EXTRA_ALIGNMENT=OFF \

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Unreleased (2.0.0)
4444
* The associated Windows-only option `CYRUS_PLUGIN_PATH_PREFIX` is removed.
4545
* Support for the deprecated `minPoolSize` URI option is removed along with associated API: `MONGOC_URI_MINPOOLSIZE` and `mongoc_client_pool_min_size`.
4646
* Support for LibreSSL (the CMake option `ENABLE_SSL=LIBRESSL`) is removed. Associated API is removed (`MONGOC_ENABLE_SSL_LIBRESSL` and `mongoc_stream_tls_libressl_new`).
47+
* The deprecated CMake option `ENABLE_AUTOMATIC_INIT_AND_CLEANUP` is removed. See [Initialization and cleanup](https://mongoc.org/libmongoc/1.30.2/init-cleanup.html) for expected use of `mongoc_init()` and `mongoc_cleanup()`.
4748

4849
### Forwarding headers (`#include <bson.h>` and `#include <mongoc.h>`)
4950

src/libmongoc/CMakeLists.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -380,12 +380,6 @@ add_feature_info(
380380
"authenticate with MongoDB servers using SASL: “Simple Authentication and Security Layer” (${SASL_BACKEND})"
381381
)
382382

383-
if (ENABLE_AUTOMATIC_INIT_AND_CLEANUP)
384-
set (MONGOC_NO_AUTOMATIC_GLOBALS 0)
385-
else ()
386-
set (MONGOC_NO_AUTOMATIC_GLOBALS 1)
387-
endif ()
388-
389383
if (WIN32)
390384
SET (CMAKE_EXTRA_INCLUDE_FILES "ws2tcpip.h")
391385
else ()

src/libmongoc/doc/errors.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ Many C Driver functions report errors by returning ``false`` or -1 and filling o
3535
+-----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
3636
| | ``MONGOC_ERROR_CLIENT_INVALID_LOAD_BALANCER`` | You attempted to connect to a MongoDB server behind a load balancer, but the server does not advertize load balanced support. |
3737
+-----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
38+
| | ``MONGOC_ERROR_CLIENT_NOT_READY`` | You attempted to create a client but did not previously call :symbol:`mongoc_init` |
39+
+-----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
3840
| ``MONGOC_ERROR_STREAM`` | ``MONGOC_ERROR_STREAM_NAME_RESOLUTION`` | DNS failure. |
3941
+-----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
4042
| | ``MONGOC_ERROR_STREAM_SOCKET`` | Timeout communicating with server, or connection closed. |

0 commit comments

Comments
 (0)