15
15
// specific language governing permissions and limitations
16
16
// under the License.
17
17
18
- use std:: {
19
- collections:: HashMap ,
20
- ffi:: { c_char, c_void, CString } ,
21
- } ;
22
-
23
18
use abi_stable:: {
24
19
std_types:: { RHashMap , RString } ,
25
20
StableAbi ,
26
21
} ;
27
22
use datafusion:: { config:: ConfigOptions , error:: Result } ;
28
23
use datafusion:: { error:: DataFusionError , prelude:: SessionConfig } ;
24
+ use std:: sync:: Arc ;
25
+ use std:: {
26
+ collections:: HashMap ,
27
+ ffi:: { c_char, c_void, CString } ,
28
+ } ;
29
29
30
30
/// A stable struct for sharing [`SessionConfig`] across FFI boundaries.
31
31
/// Instead of attempting to expose the entire SessionConfig interface, we
@@ -85,11 +85,9 @@ unsafe extern "C" fn release_fn_wrapper(config: &mut FFI_SessionConfig) {
85
85
86
86
unsafe extern "C" fn clone_fn_wrapper ( config : & FFI_SessionConfig ) -> FFI_SessionConfig {
87
87
let old_private_data = config. private_data as * mut SessionConfigPrivateData ;
88
- let old_config = & ( * old_private_data) . config ;
88
+ let old_config = Arc :: clone ( & ( * old_private_data) . config ) ;
89
89
90
- let private_data = Box :: new ( SessionConfigPrivateData {
91
- config : old_config. clone ( ) ,
92
- } ) ;
90
+ let private_data = Box :: new ( SessionConfigPrivateData { config : old_config } ) ;
93
91
94
92
FFI_SessionConfig {
95
93
config_options : config_options_fn_wrapper,
@@ -100,7 +98,7 @@ unsafe extern "C" fn clone_fn_wrapper(config: &FFI_SessionConfig) -> FFI_Session
100
98
}
101
99
102
100
struct SessionConfigPrivateData {
103
- pub config : ConfigOptions ,
101
+ pub config : Arc < ConfigOptions > ,
104
102
}
105
103
106
104
impl From < & SessionConfig > for FFI_SessionConfig {
@@ -120,7 +118,7 @@ impl From<&SessionConfig> for FFI_SessionConfig {
120
118
}
121
119
122
120
let private_data = Box :: new ( SessionConfigPrivateData {
123
- config : session. options ( ) . clone ( ) ,
121
+ config : Arc :: clone ( session. options ( ) ) ,
124
122
} ) ;
125
123
126
124
Self {
0 commit comments