@@ -407,7 +407,7 @@ class connection_handle::impl : public std::enable_shared_from_this<connection_h
407
407
408
408
void start ()
409
409
{
410
- worker = std::thread ([self = shared_from_this ()]() { self->ctx_ .run (); });
410
+ worker_ = std::thread ([self = shared_from_this ()]() { self->ctx_ .run (); });
411
411
}
412
412
413
413
void stop ()
@@ -418,8 +418,8 @@ class connection_handle::impl : public std::enable_shared_from_this<connection_h
418
418
cluster_->close ([barrier]() { barrier->set_value (); });
419
419
f.wait ();
420
420
cluster_.reset ();
421
- if (worker .joinable ()) {
422
- worker .join ();
421
+ if (worker_ .joinable ()) {
422
+ worker_ .join ();
423
423
}
424
424
}
425
425
}
@@ -574,10 +574,33 @@ class connection_handle::impl : public std::enable_shared_from_this<connection_h
574
574
return couchbase::cluster (*cluster_).bucket (bucket).scope (scope).collection (collection);
575
575
}
576
576
577
+ void notify_fork (fork_event event)
578
+ {
579
+ switch (event) {
580
+ case fork_event::prepare:
581
+ ctx_.stop ();
582
+ worker_.join ();
583
+ ctx_.notify_fork (asio::execution_context::fork_prepare);
584
+ break ;
585
+
586
+ case fork_event::parent:
587
+ ctx_.notify_fork (asio::execution_context::fork_parent);
588
+ ctx_.restart ();
589
+ worker_ = std::thread ([self = shared_from_this ()]() { self->ctx_ .run (); });
590
+ break ;
591
+
592
+ case fork_event::child:
593
+ ctx_.notify_fork (asio::execution_context::fork_child);
594
+ ctx_.restart ();
595
+ worker_ = std::thread ([self = shared_from_this ()]() { self->ctx_ .run (); });
596
+ break ;
597
+ }
598
+ }
599
+
577
600
private:
578
601
asio::io_context ctx_{};
579
602
std::shared_ptr<couchbase::core::cluster> cluster_{ std::make_shared<couchbase::core::cluster>(ctx_) };
580
- std::thread worker ;
603
+ std::thread worker_ ;
581
604
core::origin origin_;
582
605
};
583
606
@@ -620,6 +643,12 @@ connection_handle::replicas_configured_for_bucket(const zend_string* bucket_name
620
643
return impl_->replicas_configured_for_bucket (cb_string_new (bucket_name));
621
644
}
622
645
646
+ void
647
+ connection_handle::notify_fork (fork_event event) const
648
+ {
649
+ return impl_->notify_fork (event);
650
+ }
651
+
623
652
COUCHBASE_API
624
653
core_error_info
625
654
connection_handle::bucket_open (const std::string& name)
@@ -2659,9 +2688,9 @@ zval_to_search_index(couchbase::core::operations::management::search_index_upser
2659
2688
if (auto e = cb_assign_string (idx.plan_params_json , index, " planParams" ); e.ec ) {
2660
2689
return e;
2661
2690
}
2662
- request.index = idx;
2691
+ request.index = idx;
2663
2692
2664
- return {};
2693
+ return {};
2665
2694
}
2666
2695
2667
2696
COUCHBASE_API
@@ -2844,7 +2873,10 @@ connection_handle::search_index_control_plan_freeze(zval* return_value, const ze
2844
2873
2845
2874
COUCHBASE_API
2846
2875
core_error_info
2847
- connection_handle::search_index_analyze_document (zval* return_value, const zend_string* index_name, const zend_string* document, const zval* options)
2876
+ connection_handle::search_index_analyze_document (zval* return_value,
2877
+ const zend_string* index_name,
2878
+ const zend_string* document,
2879
+ const zval* options)
2848
2880
{
2849
2881
couchbase::core::operations::management::search_index_analyze_document_request request{};
2850
2882
request.index_name = cb_string_new (index_name);
@@ -2867,7 +2899,11 @@ connection_handle::search_index_analyze_document(zval* return_value, const zend_
2867
2899
2868
2900
COUCHBASE_API
2869
2901
core_error_info
2870
- connection_handle::scope_search_index_get (zval* return_value, const zend_string* bucket_name, const zend_string* scope_name, const zend_string* index_name, const zval* options)
2902
+ connection_handle::scope_search_index_get (zval* return_value,
2903
+ const zend_string* bucket_name,
2904
+ const zend_string* scope_name,
2905
+ const zend_string* index_name,
2906
+ const zval* options)
2871
2907
{
2872
2908
couchbase::core::operations::management::search_index_get_request request{ cb_string_new (index_name) };
2873
2909
@@ -2892,7 +2928,10 @@ connection_handle::scope_search_index_get(zval* return_value, const zend_string*
2892
2928
2893
2929
COUCHBASE_API
2894
2930
core_error_info
2895
- connection_handle::scope_search_index_get_all (zval* return_value, const zend_string* bucket_name, const zend_string* scope_name, const zval* options)
2931
+ connection_handle::scope_search_index_get_all (zval* return_value,
2932
+ const zend_string* bucket_name,
2933
+ const zend_string* scope_name,
2934
+ const zval* options)
2896
2935
{
2897
2936
couchbase::core::operations::management::search_index_get_all_request request{};
2898
2937
@@ -2922,7 +2961,11 @@ connection_handle::scope_search_index_get_all(zval* return_value, const zend_str
2922
2961
2923
2962
COUCHBASE_API
2924
2963
core_error_info
2925
- connection_handle::scope_search_index_upsert (zval* return_value, const zend_string* bucket_name, const zend_string* scope_name, const zval* index, const zval* options)
2964
+ connection_handle::scope_search_index_upsert (zval* return_value,
2965
+ const zend_string* bucket_name,
2966
+ const zend_string* scope_name,
2967
+ const zval* index,
2968
+ const zval* options)
2926
2969
{
2927
2970
couchbase::core::operations::management::search_index_upsert_request request{};
2928
2971
@@ -2951,7 +2994,11 @@ connection_handle::scope_search_index_upsert(zval* return_value, const zend_stri
2951
2994
2952
2995
COUCHBASE_API
2953
2996
core_error_info
2954
- connection_handle::scope_search_index_drop (zval* return_value, const zend_string* bucket_name, const zend_string* scope_name, const zend_string* index_name, const zval* options)
2997
+ connection_handle::scope_search_index_drop (zval* return_value,
2998
+ const zend_string* bucket_name,
2999
+ const zend_string* scope_name,
3000
+ const zend_string* index_name,
3001
+ const zval* options)
2955
3002
{
2956
3003
couchbase::core::operations::management::search_index_drop_request request{ cb_string_new (index_name) };
2957
3004
@@ -2973,7 +3020,11 @@ connection_handle::scope_search_index_drop(zval* return_value, const zend_string
2973
3020
2974
3021
COUCHBASE_API
2975
3022
core_error_info
2976
- connection_handle::scope_search_index_get_documents_count (zval* return_value, const zend_string* bucket_name, const zend_string* scope_name, const zend_string* index_name, const zval* options)
3023
+ connection_handle::scope_search_index_get_documents_count (zval* return_value,
3024
+ const zend_string* bucket_name,
3025
+ const zend_string* scope_name,
3026
+ const zend_string* index_name,
3027
+ const zval* options)
2977
3028
{
2978
3029
couchbase::core::operations::management::search_index_get_documents_count_request request{ cb_string_new (index_name) };
2979
3030
@@ -2997,7 +3048,12 @@ connection_handle::scope_search_index_get_documents_count(zval* return_value, co
2997
3048
2998
3049
COUCHBASE_API
2999
3050
core_error_info
3000
- connection_handle::scope_search_index_control_ingest (zval* return_value, const zend_string* bucket_name, const zend_string* scope_name, const zend_string* index_name, bool pause, const zval* options)
3051
+ connection_handle::scope_search_index_control_ingest (zval* return_value,
3052
+ const zend_string* bucket_name,
3053
+ const zend_string* scope_name,
3054
+ const zend_string* index_name,
3055
+ bool pause,
3056
+ const zval* options)
3001
3057
{
3002
3058
couchbase::core::operations::management::search_index_control_ingest_request request{};
3003
3059
@@ -3022,7 +3078,12 @@ connection_handle::scope_search_index_control_ingest(zval* return_value, const z
3022
3078
3023
3079
COUCHBASE_API
3024
3080
core_error_info
3025
- connection_handle::scope_search_index_control_query (zval* return_value, const zend_string* bucket_name, const zend_string* scope_name, const zend_string* index_name, bool allow, const zval* options)
3081
+ connection_handle::scope_search_index_control_query (zval* return_value,
3082
+ const zend_string* bucket_name,
3083
+ const zend_string* scope_name,
3084
+ const zend_string* index_name,
3085
+ bool allow,
3086
+ const zval* options)
3026
3087
{
3027
3088
couchbase::core::operations::management::search_index_control_query_request request{};
3028
3089
@@ -3047,7 +3108,12 @@ connection_handle::scope_search_index_control_query(zval* return_value, const ze
3047
3108
3048
3109
COUCHBASE_API
3049
3110
core_error_info
3050
- connection_handle::scope_search_index_control_plan_freeze (zval* return_value, const zend_string* bucket_name, const zend_string* scope_name, const zend_string* index_name, bool freeze, const zval* options)
3111
+ connection_handle::scope_search_index_control_plan_freeze (zval* return_value,
3112
+ const zend_string* bucket_name,
3113
+ const zend_string* scope_name,
3114
+ const zend_string* index_name,
3115
+ bool freeze,
3116
+ const zval* options)
3051
3117
{
3052
3118
couchbase::core::operations::management::search_index_control_plan_freeze_request request{};
3053
3119
@@ -3072,7 +3138,12 @@ connection_handle::scope_search_index_control_plan_freeze(zval* return_value, co
3072
3138
3073
3139
COUCHBASE_API
3074
3140
core_error_info
3075
- connection_handle::scope_search_index_analyze_document (zval* return_value, const zend_string* bucket_name, const zend_string* scope_name, const zend_string* index_name, const zend_string* document, const zval* options)
3141
+ connection_handle::scope_search_index_analyze_document (zval* return_value,
3142
+ const zend_string* bucket_name,
3143
+ const zend_string* scope_name,
3144
+ const zend_string* index_name,
3145
+ const zend_string* document,
3146
+ const zval* options)
3076
3147
{
3077
3148
couchbase::core::operations::management::search_index_analyze_document_request request{};
3078
3149
@@ -3286,7 +3357,8 @@ zval_to_bucket_settings(const zval* bucket_settings)
3286
3357
} else if (e.ec ) {
3287
3358
return { e, {} };
3288
3359
}
3289
- if (auto e = cb_assign_boolean (bucket.history_retention_collection_default , bucket_settings, " historyRetentionCollectionDefault" ); e.ec ) {
3360
+ if (auto e = cb_assign_boolean (bucket.history_retention_collection_default , bucket_settings, " historyRetentionCollectionDefault" );
3361
+ e.ec ) {
3290
3362
return { e, {} };
3291
3363
}
3292
3364
if (auto e = cb_assign_integer (bucket.history_retention_bytes , bucket_settings, " historyRetentionBytes" ); e.ec ) {
@@ -3655,7 +3727,12 @@ connection_handle::scope_drop(zval* return_value, const zend_string* bucket_name
3655
3727
3656
3728
COUCHBASE_API
3657
3729
core_error_info
3658
- connection_handle::collection_create (zval* return_value, const zend_string* bucket_name, const zend_string* scope_name, const zend_string* collection_name, const zval* settings, const zval* options)
3730
+ connection_handle::collection_create (zval* return_value,
3731
+ const zend_string* bucket_name,
3732
+ const zend_string* scope_name,
3733
+ const zend_string* collection_name,
3734
+ const zval* settings,
3735
+ const zval* options)
3659
3736
{
3660
3737
couchbase::core::operations::management::collection_create_request request{};
3661
3738
@@ -3686,7 +3763,11 @@ connection_handle::collection_create(zval* return_value, const zend_string* buck
3686
3763
3687
3764
COUCHBASE_API
3688
3765
core_error_info
3689
- connection_handle::collection_drop (zval* return_value, const zend_string* bucket_name, const zend_string* scope_name, const zend_string* collection_name, const zval* options)
3766
+ connection_handle::collection_drop (zval* return_value,
3767
+ const zend_string* bucket_name,
3768
+ const zend_string* scope_name,
3769
+ const zend_string* collection_name,
3770
+ const zval* options)
3690
3771
{
3691
3772
couchbase::core::operations::management::collection_drop_request request{};
3692
3773
@@ -3709,7 +3790,12 @@ connection_handle::collection_drop(zval* return_value, const zend_string* bucket
3709
3790
3710
3791
COUCHBASE_API
3711
3792
core_error_info
3712
- connection_handle::collection_update (zval* return_value, const zend_string* bucket_name, const zend_string* scope_name, const zend_string* collection_name, const zval* settings, const zval* options)
3793
+ connection_handle::collection_update (zval* return_value,
3794
+ const zend_string* bucket_name,
3795
+ const zend_string* scope_name,
3796
+ const zend_string* collection_name,
3797
+ const zval* settings,
3798
+ const zval* options)
3713
3799
{
3714
3800
couchbase::core::operations::management::collection_update_request request{};
3715
3801
0 commit comments