Skip to content

Commit ad65f71

Browse files
committed
CDRIVER-2001 mongoc_gridfs_file_writev takes const iovec
1 parent 5d33068 commit ad65f71

File tree

10 files changed

+50
-8
lines changed

10 files changed

+50
-8
lines changed

build/generate-future-functions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787

8888
# Const libmongoc.
8989
typedef("const_mongoc_find_and_modify_opts_ptr", "const mongoc_find_and_modify_opts_t *"),
90+
typedef("const_mongoc_iovec_ptr", "const mongoc_iovec_t *"),
9091
typedef("const_mongoc_read_prefs_ptr", "const mongoc_read_prefs_t *"),
9192
typedef("const_mongoc_write_concern_ptr", "const mongoc_write_concern_t *"),
9293
]
@@ -310,7 +311,7 @@
310311
future_function("ssize_t",
311312
"mongoc_gridfs_file_writev",
312313
[param("mongoc_gridfs_file_ptr", "file"),
313-
param("mongoc_iovec_ptr", "iov"),
314+
param("const_mongoc_iovec_ptr", "iov"),
314315
param("size_t", "iovcnt"),
315316
param("uint32_t", "timeout_msec")]),
316317

doc/mongoc_gridfs_file_writev.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Synopsis
1010
1111
ssize_t
1212
mongoc_gridfs_file_writev (mongoc_gridfs_file_t *file,
13-
mongoc_iovec_t *iov,
13+
const mongoc_iovec_t *iov,
1414
size_t iovcnt,
1515
uint32_t timeout_msec);
1616

src/mongoc/mongoc-gridfs-file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ mongoc_gridfs_file_readv (mongoc_gridfs_file_t *file,
481481
* timeout_msec is unused */
482482
ssize_t
483483
mongoc_gridfs_file_writev (mongoc_gridfs_file_t *file,
484-
mongoc_iovec_t *iov,
484+
const mongoc_iovec_t *iov,
485485
size_t iovcnt,
486486
uint32_t timeout_msec)
487487
{

src/mongoc/mongoc-gridfs-file.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ mongoc_gridfs_file_get_upload_date (mongoc_gridfs_file_t *file);
7979

8080
MONGOC_EXPORT (ssize_t)
8181
mongoc_gridfs_file_writev (mongoc_gridfs_file_t *file,
82-
mongoc_iovec_t *iov,
82+
const mongoc_iovec_t *iov,
8383
size_t iovcnt,
8484
uint32_t timeout_msec);
8585
MONGOC_EXPORT (ssize_t)

tests/mock_server/future-functions.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ background_mongoc_gridfs_file_writev (void *data)
642642
&return_value,
643643
mongoc_gridfs_file_writev (
644644
future_value_get_mongoc_gridfs_file_ptr (future_get_param (future, 0)),
645-
future_value_get_mongoc_iovec_ptr (future_get_param (future, 1)),
645+
future_value_get_const_mongoc_iovec_ptr (future_get_param (future, 1)),
646646
future_value_get_size_t (future_get_param (future, 2)),
647647
future_value_get_uint32_t (future_get_param (future, 3))
648648
));
@@ -1489,7 +1489,7 @@ future_gridfs_file_seek (
14891489
future_t *
14901490
future_gridfs_file_writev (
14911491
mongoc_gridfs_file_ptr file,
1492-
mongoc_iovec_ptr iov,
1492+
const_mongoc_iovec_ptr iov,
14931493
size_t iovcnt,
14941494
uint32_t timeout_msec)
14951495
{
@@ -1499,7 +1499,7 @@ future_gridfs_file_writev (
14991499
future_value_set_mongoc_gridfs_file_ptr (
15001500
future_get_param (future, 0), file);
15011501

1502-
future_value_set_mongoc_iovec_ptr (
1502+
future_value_set_const_mongoc_iovec_ptr (
15031503
future_get_param (future, 1), iov);
15041504

15051505
future_value_set_size_t (

tests/mock_server/future-functions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ future_t *
305305
future_gridfs_file_writev (
306306

307307
mongoc_gridfs_file_ptr file,
308-
mongoc_iovec_ptr iov,
308+
const_mongoc_iovec_ptr iov,
309309
size_t iovcnt,
310310
uint32_t timeout_msec
311311
);

tests/mock_server/future-value.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,20 @@ future_value_get_const_mongoc_find_and_modify_opts_ptr (future_value_t *future_v
434434
return future_value->const_mongoc_find_and_modify_opts_ptr_value;
435435
}
436436

437+
void
438+
future_value_set_const_mongoc_iovec_ptr (future_value_t *future_value, const_mongoc_iovec_ptr value)
439+
{
440+
future_value->type = future_value_const_mongoc_iovec_ptr_type;
441+
future_value->const_mongoc_iovec_ptr_value = value;
442+
}
443+
444+
const_mongoc_iovec_ptr
445+
future_value_get_const_mongoc_iovec_ptr (future_value_t *future_value)
446+
{
447+
BSON_ASSERT (future_value->type == future_value_const_mongoc_iovec_ptr_type);
448+
return future_value->const_mongoc_iovec_ptr_value;
449+
}
450+
437451
void
438452
future_value_set_const_mongoc_read_prefs_ptr (future_value_t *future_value, const_mongoc_read_prefs_ptr value)
439453
{

tests/mock_server/future-value.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ typedef mongoc_server_description_t * mongoc_server_description_ptr;
3939
typedef mongoc_topology_t * mongoc_topology_ptr;
4040
typedef mongoc_write_concern_t * mongoc_write_concern_ptr;
4141
typedef const mongoc_find_and_modify_opts_t * const_mongoc_find_and_modify_opts_ptr;
42+
typedef const mongoc_iovec_t * const_mongoc_iovec_ptr;
4243
typedef const mongoc_read_prefs_t * const_mongoc_read_prefs_ptr;
4344
typedef const mongoc_write_concern_t * const_mongoc_write_concern_ptr;
4445

@@ -73,6 +74,7 @@ typedef enum {
7374
future_value_mongoc_topology_ptr_type,
7475
future_value_mongoc_write_concern_ptr_type,
7576
future_value_const_mongoc_find_and_modify_opts_ptr_type,
77+
future_value_const_mongoc_iovec_ptr_type,
7678
future_value_const_mongoc_read_prefs_ptr_type,
7779
future_value_const_mongoc_write_concern_ptr_type,
7880
future_value_void_type,
@@ -112,6 +114,7 @@ typedef struct _future_value_t
112114
mongoc_topology_ptr mongoc_topology_ptr_value;
113115
mongoc_write_concern_ptr mongoc_write_concern_ptr_value;
114116
const_mongoc_find_and_modify_opts_ptr const_mongoc_find_and_modify_opts_ptr_value;
117+
const_mongoc_iovec_ptr const_mongoc_iovec_ptr_value;
115118
const_mongoc_read_prefs_ptr const_mongoc_read_prefs_ptr_value;
116119
const_mongoc_write_concern_ptr const_mongoc_write_concern_ptr_value;
117120

@@ -391,6 +394,15 @@ const_mongoc_find_and_modify_opts_ptr
391394
future_value_get_const_mongoc_find_and_modify_opts_ptr (
392395
future_value_t *future_value);
393396

397+
void
398+
future_value_set_const_mongoc_iovec_ptr(
399+
future_value_t *future_value,
400+
const_mongoc_iovec_ptr value);
401+
402+
const_mongoc_iovec_ptr
403+
future_value_get_const_mongoc_iovec_ptr (
404+
future_value_t *future_value);
405+
394406
void
395407
future_value_set_const_mongoc_read_prefs_ptr(
396408
future_value_t *future_value,

tests/mock_server/future.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,18 @@ future_get_const_mongoc_find_and_modify_opts_ptr (future_t *future)
373373
abort ();
374374
}
375375

376+
const_mongoc_iovec_ptr
377+
future_get_const_mongoc_iovec_ptr (future_t *future)
378+
{
379+
if (future_wait (future)) {
380+
return future_value_get_const_mongoc_iovec_ptr (&future->return_value);
381+
}
382+
383+
fprintf (stderr, "%s timed out\n", BSON_FUNC);
384+
fflush (stderr);
385+
abort ();
386+
}
387+
376388
const_mongoc_read_prefs_ptr
377389
future_get_const_mongoc_read_prefs_ptr (future_t *future)
378390
{

tests/mock_server/future.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ future_get_mongoc_write_concern_ptr (future_t *future);
129129
const_mongoc_find_and_modify_opts_ptr
130130
future_get_const_mongoc_find_and_modify_opts_ptr (future_t *future);
131131

132+
const_mongoc_iovec_ptr
133+
future_get_const_mongoc_iovec_ptr (future_t *future);
134+
132135
const_mongoc_read_prefs_ptr
133136
future_get_const_mongoc_read_prefs_ptr (future_t *future);
134137

0 commit comments

Comments
 (0)