[PATCH v2 3/9] box: rework func cache update machinery

Vladimir Davydov vdavydov.dev at gmail.com
Mon Jun 10 12:44:33 MSK 2019


On Thu, Jun 06, 2019 at 03:03:59PM +0300, Kirill Shcherbatov wrote:
> diff --git a/src/box/func.c b/src/box/func.c
> index 098bc02b6..5051286a3 100644
> --- a/src/box/func.c
> +++ b/src/box/func.c
> @@ -475,17 +475,18 @@ func_call(struct func *func, box_function_ctx_t *ctx, const char *args,
>  }
>  
>  void
> -func_update(struct func *func, struct func_def *def)
> +func_delete(struct func *func)
>  {
>  	func_unload(func);
>  	free(func->def);
> -	func->def = def;
> +	free(func);
>  }
>  
>  void
> -func_delete(struct func *func)
> +func_reuse_runtime(struct func *new_func, struct func *old_func)
>  {
> -	func_unload(func);
> -	free(func->def);
> -	free(func);
> +	new_func->module = old_func->module;
> +	new_func->func = old_func->func;
> +	old_func->module = NULL;
> +	old_func->func = NULL;
>  }

If you look at the code coverage, you'll see that this function isn't
covered by any test, because we never update functions - only create or
drop them. Since this code leads to a new virtual function, let's simply
drop it?

I mean,

  - raise ER_UNSUPPORTED in on_replace_dd_func/UPDATE,
  - replace func_cache_replace with func_cache_insert, which would panic
    if the function with the same id/name already exists.

This would simplify the code quite a bit. If anybody needs to alter the
definition of an existing function, we can do it later.



More information about the Tarantool-patches mailing list