Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build/generate-future-functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
typedef("size_t", None),
typedef("ssize_t", None),
typedef("uint32_t", None),
typedef("void_ptr", "void *"),

# Const fundamental.
typedef("const_char_ptr", "const char *"),
Expand Down
2 changes: 2 additions & 0 deletions src/libmongoc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,7 @@ set (SOURCES ${SOURCES}
${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-host-list.c
${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-index.c
${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-init.c
${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-interrupt.c
${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-list.c
${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-linux-distro-scanner.c
${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-log.c
Expand Down Expand Up @@ -896,6 +897,7 @@ set (test-libmongoc-sources
${PROJECT_SOURCE_DIR}/tests/test-mongoc-gridfs.c
${PROJECT_SOURCE_DIR}/tests/test-mongoc-handshake.c
${PROJECT_SOURCE_DIR}/tests/test-mongoc-hedged-reads.c
${PROJECT_SOURCE_DIR}/tests/test-mongoc-interrupt.c
${PROJECT_SOURCE_DIR}/tests/test-mongoc-linux-distro-scanner.c
${PROJECT_SOURCE_DIR}/tests/test-mongoc-list.c
${PROJECT_SOURCE_DIR}/tests/test-mongoc-log.c
Expand Down
2 changes: 2 additions & 0 deletions src/libmongoc/src/mongoc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ set (src_libmongoc_src_mongoc_DIST_noinst_hs
mongoc-handshake-os-private.h
mongoc-handshake-private.h
mongoc-host-list-private.h
mongoc-interrupt-private.h
mongoc-libressl-private.h
mongoc-linux-distro-scanner-private.h
mongoc-list-private.h
Expand Down Expand Up @@ -197,6 +198,7 @@ set (src_libmongoc_src_mongoc_DIST_cs
mongoc-find-and-modify.c
mongoc-host-list.c
mongoc-init.c
mongoc-interrupt.c
mongoc-gridfs.c
mongoc-gridfs-bucket.c
mongoc-gridfs-bucket-file.c
Expand Down
57 changes: 57 additions & 0 deletions src/libmongoc/src/mongoc/mongoc-interrupt-private.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright 2020-present MongoDB, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "mongoc-prelude.h"

#ifndef MONGOC_STREAM_INTERRUPTIBLE_PRIVATE_H
#define MONGOC_STREAM_INTERRUPTIBLE_PRIVATE_H

#include "mongoc-stream.h"

/* Creates a stream to use to interrupt calls to mongoc_stream_poll.
*
* The expected use is to cancel in-progress ismaster commands (especially for
* awaitable ismaster). An ismaster command may not respond for a long time, so
* reading the reply may block on mongoc_stream_poll until data is readable. To
* interrupt mongoc_stream_poll, a stream retrieved by
* _mongoc_interrupt_get_stream can be added to the call of poll. Any other
* thread can call _mongoc_interrupt_interrupt to write to that stream.
*/
typedef struct _mongoc_interrupt_t mongoc_interrupt_t;

mongoc_interrupt_t *
_mongoc_interrupt_new (uint32_t timeout_ms);

/* Interrupt the stream. An in progress poll for POLLIN should return. */
bool
_mongoc_interrupt_interrupt (mongoc_interrupt_t *interrupt);

/* Returns a socket stream, that can be polled alongside other
* socket streams. */
mongoc_stream_t *
_mongoc_interrupt_get_stream (mongoc_interrupt_t *interrupt);

/* Flushes queued data on an interrupt.
*
* This is not guaranteed to flush all data, but it does not block.
*/
bool
_mongoc_interrupt_flush (mongoc_interrupt_t *interrupt);

void
_mongoc_interrupt_destroy (mongoc_interrupt_t *interrupt);

#endif /* MONGOC_STREAM_INTERRUPTIBLE_PRIVATE_H */
Loading