| commit 45: | 06aae28d491e |
| parent 44: | 4f02b0547f75 |
| branch: | default |
Make sure to strdup text-based config vars for inno (they changed the semantics of ib_cfg_set). Also make sure to enforce requirements on data_home_dir variables
dizzyd
5 months ago
5 months ago
Changed (Δ748 bytes):
raw changeset »
c_src/innostore_drv.c (7 lines added, 1 lines removed)
src/innostore.erl (11 lines added, 7 lines removed)
Up to file-list c_src/innostore_drv.c:
| … | … | @@ -395,7 +395,13 @@ static void do_set_cfg(void* arg) |
395 |
395 |
{ |
396 |
396 |
if (key_type == IB_CFG_TEXT) |
397 |
397 |
{ |
398 |
|
|
398 |
// HACK: Semantics of setting a text configuration value for innodb changed |
|
399 |
// to be pointer assignment (from copy) for vsn 1.0.6.6750. So, we strdup the |
|
400 |
// value to ensure everything works as expected. |
|
401 |
// TODO: Setup some sort of list of strdup'd values to ensure they all get |
|
402 |
// cleaned up properly. In typical usage, this isn't going to be a problem |
|
403 |
// as you only initialize once per run, but it bothers me just the same. |
|
404 |
error = ib_cfg_set(key, strdup(value)); |
|
399 |
405 |
} |
400 |
406 |
else |
401 |
407 |
{ |
Up to file-list src/innostore.erl:
| … | … | @@ -236,7 +236,7 @@ set_config([{Key, Value} | Rest], Port) |
236 |
236 |
case lists:keysearch(Key, 1, config_types()) of |
237 |
237 |
{value, {Key, Type}} -> |
238 |
238 |
KBin = atom_to_binary(Key, utf8), |
239 |
VBin = config_encode(Type, |
|
239 |
VBin = config_encode(Type, Key, Value), |
|
240 |
240 |
erlang:port_control(Port, ?CMD_SET_CFG, <<KBin/binary, 0:8, VBin/binary>>), |
241 |
241 |
receive |
242 |
242 |
innostore_ok -> |
| … | … | @@ -379,16 +379,20 @@ config_types() -> |
379 |
379 |
%% |
380 |
380 |
%% Encode configuration setting, based on type for passing through to inno api |
381 |
381 |
%% |
382 |
config_encode(integer, |
|
382 |
config_encode(integer, _Key, Value) -> |
|
383 |
383 |
case erlang:system_info(wordsize) of |
384 |
384 |
4 -> <<Value:32/unsigned-native>>; |
385 |
385 |
8 -> <<Value:64/unsigned-native>> |
386 |
386 |
end; |
387 |
config_encode(bool, true) -> |
|
388 |
config_encode(integer, 1); |
|
389 |
config_encode(bool, false) -> |
|
390 |
config_encode(integer, 0); |
|
391 |
config_encode( |
|
387 |
config_encode(bool, Key, true) -> |
|
388 |
config_encode(integer, Key, 1); |
|
389 |
config_encode(bool, Key, false) -> |
|
390 |
config_encode(integer, Key, 0); |
|
391 |
config_encode(string, data_home_dir, Value) -> |
|
392 |
%% Make sure that the last character is a path separator |
|
393 |
CleanedUp = filename:absname(Value) ++ "/", |
|
394 |
<<(list_to_binary(CleanedUp))/binary, 0:8>>; |
|
395 |
config_encode(string, _Key, Value) -> |
|
392 |
396 |
<<(list_to_binary(Value))/binary, 0:8>>. |
393 |
397 |
|
394 |
398 |
