Skip to content

Commit 6156806

Browse files
authored
Vendor in libmongoc 1.17.4 (#602)
1 parent b4a8357 commit 6156806

13 files changed

+97
-27
lines changed

Sources/CLibMongoC/bson/bson.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2586,7 +2586,7 @@ _bson_as_json_visit_int64 (const bson_iter_t *iter,
25862586

25872587
if (state->mode == BSON_JSON_MODE_CANONICAL) {
25882588
bson_string_append_printf (
2589-
state->str, "{ \"$numberLong\" : \"%" "lld" "\"}", v_int64);
2589+
state->str, "{ \"$numberLong\" : \"%" "lld" "\" }", v_int64);
25902590
} else {
25912591
bson_string_append_printf (state->str, "%" "lld", v_int64);
25922592
}

Sources/CLibMongoC/mongoc/mongoc-client-pool.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ mongoc_client_pool_new (const mongoc_uri_t *uri)
121121

122122
pool = (mongoc_client_pool_t *) bson_malloc0 (sizeof *pool);
123123
bson_mutex_init (&pool->mutex);
124+
mongoc_cond_init (&pool->cond);
124125
_mongoc_queue_init (&pool->queue);
125126
pool->uri = mongoc_uri_copy (uri);
126127
pool->min_pool_size = 0;

Sources/CLibMongoC/mongoc/mongoc-client-private.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,12 @@ typedef struct _mongoc_rr_data_t {
155155
char *txt_record_opts;
156156
} mongoc_rr_data_t;
157157

158+
#define MONGOC_RR_DEFAULT_BUFFER_SIZE 1024
158159
bool
159160
_mongoc_client_get_rr (const char *service,
160161
mongoc_rr_type_t rr_type,
161162
mongoc_rr_data_t *rr_data,
163+
size_t initial_buffer_size,
162164
bson_error_t *error);
163165

164166
mongoc_client_t *

Sources/CLibMongoC/mongoc/mongoc-client.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -414,14 +414,15 @@ static bool
414414
_mongoc_get_rr_search (const char *service,
415415
mongoc_rr_type_t rr_type,
416416
mongoc_rr_data_t *rr_data,
417+
size_t initial_buffer_size,
417418
bson_error_t *error)
418419
{
419420
#ifdef MONGOC_HAVE_RES_NSEARCH
420421
struct __res_state state = {0};
421422
#endif
422423
int size = 0;
423424
unsigned char *search_buf = NULL;
424-
size_t buffer_size = 1024;
425+
size_t buffer_size = initial_buffer_size;
425426
ns_msg ns_answer;
426427
int n;
427428
int i;
@@ -477,7 +478,7 @@ _mongoc_get_rr_search (const char *service,
477478
service,
478479
strerror (h_errno));
479480
}
480-
} while (size > buffer_size);
481+
} while (size >= buffer_size);
481482

482483
if (ns_initparse (search_buf, size, &ns_answer)) {
483484
DNS_ERROR ("Invalid %s answer for \"%s\"", rr_type_name, service);
@@ -585,12 +586,14 @@ bool
585586
_mongoc_client_get_rr (const char *service,
586587
mongoc_rr_type_t rr_type,
587588
mongoc_rr_data_t *rr_data,
589+
size_t initial_buffer_size,
588590
bson_error_t *error)
589591
{
590592
#ifdef MONGOC_HAVE_DNSAPI
591593
return _mongoc_get_rr_dnsapi (service, rr_type, rr_data, error);
592594
#elif (defined(MONGOC_HAVE_RES_NSEARCH) || defined(MONGOC_HAVE_RES_SEARCH))
593-
return _mongoc_get_rr_search (service, rr_type, rr_data, error);
595+
return _mongoc_get_rr_search (
596+
service, rr_type, rr_data, initial_buffer_size, error);
594597
#else
595598
bson_set_error (error,
596599
MONGOC_ERROR_STREAM,

Sources/CLibMongoC/mongoc/mongoc-cluster-cyrus.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ _mongoc_cluster_auth_node_cyrus (mongoc_cluster_t *cluster,
5757
for (;;) {
5858
mongoc_cmd_parts_init (
5959
&parts, cluster->client, "$external", MONGOC_QUERY_SLAVE_OK, &cmd);
60+
parts.prohibit_lsid = true;
6061

6162
/* If this is the first step, input buffer is NULL. */
6263
bson_free (outbuf);

Sources/CLibMongoC/mongoc/mongoc-cluster-sspi.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ _mongoc_cluster_auth_node_sspi (mongoc_cluster_t *cluster,
175175
for (step = 0;; step++) {
176176
mongoc_cmd_parts_init (
177177
&parts, cluster->client, "$external", MONGOC_QUERY_SLAVE_OK, &cmd);
178+
parts.prohibit_lsid = true;
178179
bson_init (&cmd);
179180

180181
if (res == MONGOC_SSPI_AUTH_GSS_CONTINUE) {

Sources/CLibMongoC/mongoc/mongoc-collection.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3414,6 +3414,11 @@ mongoc_collection_find_and_modify_with_opts (
34143414
done:
34153415
mongoc_server_stream_cleanup (server_stream);
34163416
mongoc_server_stream_cleanup (retry_server_stream);
3417+
3418+
if (ret && error) {
3419+
/* if a retry succeeded, clear the initial error */
3420+
memset (error, 0, sizeof (bson_error_t));
3421+
}
34173422
mongoc_cmd_parts_cleanup (&parts);
34183423
bson_destroy (&command);
34193424
if (&reply_local == reply_ptr) {

Sources/CLibMongoC/mongoc/mongoc-socket.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,9 @@ mongoc_socket_new (int domain, /* IN */
993993
#else
994994
int sd;
995995
#endif
996+
#ifdef SO_NOSIGPIPE
997+
int on = 1;
998+
#endif
996999

9971000
ENTRY;
9981001

@@ -1017,6 +1020,12 @@ mongoc_socket_new (int domain, /* IN */
10171020
_mongoc_socket_setkeepalive (sd);
10181021
}
10191022

1023+
/* Set SO_NOSIGPIPE, to ignore SIGPIPE on writes for platforms where
1024+
setting MSG_NOSIGNAL on writes is not supported (primarily OSX). */
1025+
#ifdef SO_NOSIGPIPE
1026+
setsockopt(sd, SOL_SOCKET, SO_NOSIGPIPE, &on, sizeof(on));
1027+
#endif
1028+
10201029
sock = (mongoc_socket_t *) bson_malloc0 (sizeof *sock);
10211030
sock->sd = sd;
10221031
sock->domain = domain;

Sources/CLibMongoC/mongoc/mongoc-stream-tls-openssl.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,12 +712,13 @@ mongoc_stream_tls_openssl_new (mongoc_stream_t *base_stream,
712712
#if OPENSSL_VERSION_NUMBER >= 0x10002000L && !defined(LIBRESSL_VERSION_NUMBER)
713713
if (!opt->allow_invalid_hostname) {
714714
struct in_addr addr;
715+
struct in6_addr addr6;
715716
X509_VERIFY_PARAM *param = X509_VERIFY_PARAM_new ();
716717

717718
X509_VERIFY_PARAM_set_hostflags (param,
718719
X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS);
719720
if (inet_pton (AF_INET, host, &addr) ||
720-
inet_pton (AF_INET6, host, &addr)) {
721+
inet_pton (AF_INET6, host, &addr6)) {
721722
X509_VERIFY_PARAM_set1_ip_asc (param, host);
722723
} else {
723724
X509_VERIFY_PARAM_set1_host (param, host, 0);

Sources/CLibMongoC/mongoc/mongoc-topology-background-monitoring.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ static BSON_THREAD_FUN (srv_polling_run, topology_void)
4848
}
4949

5050
/* This will check if a scan is due. */
51+
if (!mongoc_topology_should_rescan_srv (topology)) {
52+
TRACE ("%s\n", "topology ineligible for SRV polling, stopping");
53+
bson_mutex_unlock (&topology->mutex);
54+
break;
55+
}
56+
5157
mongoc_topology_rescan_srv (topology);
5258

5359
/* Unlock and sleep until next scan is due, or until shutdown signalled.
@@ -142,7 +148,8 @@ _mongoc_topology_background_monitoring_start (mongoc_topology_t *topology)
142148
/* Reconcile to create the first server monitors. */
143149
_mongoc_topology_background_monitoring_reconcile (topology);
144150
/* Start SRV polling thread. */
145-
if (mongoc_uri_get_service (topology->uri)) {
151+
if (mongoc_topology_should_rescan_srv (topology)) {
152+
topology->is_srv_polling = true;
146153
COMMON_PREFIX (thread_create)
147154
(&topology->srv_polling_thread, srv_polling_run, topology);
148155
}
@@ -270,7 +277,6 @@ _mongoc_topology_background_monitoring_stop (mongoc_topology_t *topology)
270277
{
271278
mongoc_server_monitor_t *server_monitor;
272279
int i;
273-
bool is_srv_polling;
274280

275281
BSON_ASSERT (!topology->single_threaded);
276282

@@ -281,9 +287,8 @@ _mongoc_topology_background_monitoring_stop (mongoc_topology_t *topology)
281287
topology->scanner_state = MONGOC_TOPOLOGY_SCANNER_SHUTTING_DOWN;
282288
TRACE ("%s", "background monitoring stopping");
283289

284-
is_srv_polling = NULL != mongoc_uri_get_service (topology->uri);
285290
/* Signal SRV polling to shut down (if it is started). */
286-
if (is_srv_polling) {
291+
if (topology->is_srv_polling) {
287292
mongoc_cond_signal (&topology->srv_polling_cond);
288293
}
289294

@@ -320,7 +325,7 @@ _mongoc_topology_background_monitoring_stop (mongoc_topology_t *topology)
320325
}
321326

322327
/* Wait for SRV polling thread. */
323-
if (is_srv_polling) {
328+
if (topology->is_srv_polling) {
324329
COMMON_PREFIX (thread_join) (topology->srv_polling_thread);
325330
}
326331

0 commit comments

Comments
 (0)