Skip to content

Commit e93dc32

Browse files
committed
Merge branch 'master' of github.com:mongodb/mongo-c-driver
* 'master' of github.com:mongodb/mongo-c-driver: CDRIVER-1985 Deprecate mongoc_collection_save CDRIVER-2003 readConcern option should not be included in getMore commands CDRIVER-1998: Bump the handshake configure flags CDRIVER-2000 Implement sasl logger and fail early on unsupported mechanism
2 parents 5bda9c8 + 7c7e5bf commit e93dc32

13 files changed

+175
-23
lines changed

doc/mongoc_collection_save.rst

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@
33
mongoc_collection_save()
44
========================
55

6+
Deprecated
7+
----------
8+
9+
This function is deprecated and should not be used in new code.
10+
11+
Please use :symbol:`mongoc_collection_insert() <mongoc_collection_insert>` or
12+
:symbol:`mongoc_collection_update() <mongoc_collection_update>` instead.
13+
14+
615
Synopsis
716
--------
817

@@ -12,7 +21,8 @@ Synopsis
1221
mongoc_collection_save (mongoc_collection_t *collection,
1322
const bson_t *document,
1423
const mongoc_write_concern_t *write_concern,
15-
bson_error_t *error);
24+
bson_error_t *error)
25+
BSON_GNUC_DEPRECATED_FOR (mongoc_collection_insert or mongoc_collection_update);
1626
1727
Parameters
1828
----------

examples/parse_handshake_cfg.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
"MONGOC_MD_FLAG_HAVE_WEAK_SYMBOLS",
2020
"MONGOC_MD_FLAG_NO_AUTOMATIC_GLOBALS",
2121
"MONGOC_MD_FLAG_ENABLE_SSL_LIBRESSL",
22+
"MONGOC_MD_FLAG_ENABLE_SASL_CYRUS",
23+
"MONGOC_MD_FLAG_ENABLE_SASL_SSPI",
24+
"MONGOC_MD_FLAG_HAVE_SOCKLEN",
2225
]
2326

2427
def main():

src/mongoc/mongoc-cluster-sasl.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,9 @@ _mongoc_cluster_auth_node_sasl (mongoc_cluster_t *cluster,
174174
_mongoc_sasl_init (&sasl);
175175

176176
if ((mechanism = mongoc_uri_get_auth_mechanism (cluster->uri))) {
177-
_mongoc_sasl_set_mechanism (&sasl, mechanism);
177+
if (!_mongoc_sasl_set_mechanism (&sasl, mechanism, error)) {
178+
goto failure;
179+
}
178180
}
179181

180182
_mongoc_sasl_set_pass (&sasl, mongoc_uri_get_password (cluster->uri));

src/mongoc/mongoc-collection.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,14 @@ mongoc_collection_aggregate (mongoc_collection_t *collection, /* IN */
457457
mongoc_read_concern_destroy (cursor->read_concern);
458458
cursor->read_concern = mongoc_read_concern_copy (
459459
mongoc_collection_get_read_concern (collection));
460+
461+
if (cursor->read_concern->level != NULL) {
462+
const bson_t *read_concern_bson;
463+
464+
read_concern_bson =
465+
_mongoc_read_concern_get_bson (cursor->read_concern);
466+
BSON_APPEND_DOCUMENT (&command, "readConcern", read_concern_bson);
467+
}
460468
}
461469

462470

src/mongoc/mongoc-collection.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ BSON_EXPORT (bool)
188188
mongoc_collection_save (mongoc_collection_t *collection,
189189
const bson_t *document,
190190
const mongoc_write_concern_t *write_concern,
191-
bson_error_t *error);
191+
bson_error_t *error)
192+
BSON_GNUC_DEPRECATED_FOR (mongoc_collection_insert or mongoc_collection_update);
192193
BSON_EXPORT (bool)
193194
mongoc_collection_remove (mongoc_collection_t *collection,
194195
mongoc_remove_flags_t flags,

src/mongoc/mongoc-cursor.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,12 +1265,6 @@ _mongoc_cursor_run_command (mongoc_cursor_t *cursor,
12651265
read_prefs_result.query_with_read_prefs);
12661266
}
12671267

1268-
if (cursor->read_concern &&
1269-
server_stream->sd->max_wire_version >= WIRE_VERSION_READ_CONCERN) {
1270-
mongoc_read_concern_append (cursor->read_concern,
1271-
read_prefs_result.query_with_read_prefs);
1272-
}
1273-
12741268
ret = mongoc_cluster_run_command_monitored (
12751269
cluster,
12761270
server_stream,

src/mongoc/mongoc-database.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ mongoc_database_add_user_legacy (mongoc_database_t *database,
414414
bson_append_utf8 (&user, "pwd", 3, pwd, -1);
415415
}
416416

417-
if (!mongoc_collection_save (collection, &user, NULL, error)) {
417+
if (!mongoc_collection_insert (collection, MONGOC_INSERT_NONE, &user, NULL, error)) {
418418
GOTO (failure_with_user);
419419
}
420420

src/mongoc/mongoc-handshake-private.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ typedef enum {
5555
MONGOC_MD_FLAG_HAVE_SASL_CLIENT_DONE = 1 << 11,
5656
MONGOC_MD_FLAG_HAVE_WEAK_SYMBOLS = 1 << 12,
5757
MONGOC_MD_FLAG_NO_AUTOMATIC_GLOBALS = 1 << 13,
58-
MONGOC_MD_FLAG_ENABLE_SSL_LIBRESSL = 1 << 14
58+
MONGOC_MD_FLAG_ENABLE_SSL_LIBRESSL = 1 << 14,
59+
MONGOC_MD_FLAG_ENABLE_SASL_CYRUS = 1 << 15,
60+
MONGOC_MD_FLAG_ENABLE_SASL_SSPI = 1 << 16,
61+
MONGOC_MD_FLAG_HAVE_SOCKLEN = 1 << 17,
5962
} mongoc_handshake_config_flags_t;
6063

6164

src/mongoc/mongoc-handshake.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,18 @@ _get_config_bitfield (void)
109109
bf |= MONGOC_MD_FLAG_ENABLE_SSL_LIBRESSL;
110110
#endif
111111

112+
#ifdef MONGOC_ENABLE_SASL_CYRUS
113+
bf |= MONGOC_MD_FLAG_ENABLE_SASL_CYRUS;
114+
#endif
115+
116+
#ifdef MONGOC_ENABLE_SASL_SSPI
117+
bf |= MONGOC_MD_FLAG_ENABLE_SASL_SSPI;
118+
#endif
119+
120+
#ifdef MONGOC_HAVE_SOCKLEN
121+
bf |= MONGOC_MD_FLAG_HAVE_SOCKLEN;
122+
#endif
123+
112124
return bf;
113125
}
114126

src/mongoc/mongoc-init.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545

4646
#ifdef MONGOC_ENABLE_SASL_CYRUS
4747
#include <sasl/sasl.h>
48+
#include "mongoc-sasl-private.h"
4849

4950
static void *
5051
mongoc_sasl_mutex_alloc (void)
@@ -88,6 +89,12 @@ mongoc_sasl_mutex_free (void *mutex)
8889

8990
static MONGOC_ONCE_FUN (_mongoc_do_init)
9091
{
92+
#ifdef MONGOC_ENABLE_SASL_CYRUS
93+
int status;
94+
sasl_callback_t callbacks[] = {
95+
{SASL_CB_LOG, SASL_CALLBACK_FN (_mongoc_sasl_log), NULL},
96+
{SASL_CB_LIST_END}};
97+
#endif
9198
#ifdef MONGOC_ENABLE_SSL_OPENSSL
9299
_mongoc_openssl_init ();
93100
#elif defined(MONGOC_ENABLE_SSL_LIBRESSL)
@@ -106,8 +113,8 @@ static MONGOC_ONCE_FUN (_mongoc_do_init)
106113
mongoc_sasl_mutex_unlock,
107114
mongoc_sasl_mutex_free);
108115

109-
/* TODO: logging callback? */
110-
sasl_client_init (NULL);
116+
status = sasl_client_init (callbacks);
117+
BSON_ASSERT (status == SASL_OK);
111118
#endif
112119

113120
_mongoc_counters_init ();

0 commit comments

Comments
 (0)