2323#include <ucs/debug/debug_int.h>
2424#include <ucs/sys/compiler.h>
2525#include <ucs/sys/string.h>
26+ #include <ucs/type/init_once.h>
2627#include <ucs/vfs/base/vfs_cb.h>
2728#include <ucs/vfs/base/vfs_obj.h>
2829#include <string.h>
@@ -863,6 +864,47 @@ ucs_status_t ucp_config_modify_internal(ucp_config_t *config, const char *name,
863864 value );
864865}
865866
867+ static void ucp_config_query_uct_components (void )
868+ {
869+ static ucs_init_once_t init_once = UCS_INIT_ONCE_INITIALIZER ;
870+ uct_component_h * components ;
871+ unsigned num_components ;
872+ ucs_status_t status ;
873+
874+ UCS_INIT_ONCE (& init_once ) {
875+ status = uct_query_components (& components , & num_components );
876+ if (status == UCS_OK ) {
877+ uct_release_component_list (components );
878+ } else {
879+ ucs_warn ("failed to query UCT components: %s" ,
880+ ucs_status_string (status ));
881+ }
882+ }
883+ }
884+
885+ static int ucp_config_global_list_has_field (const char * name )
886+ {
887+ const ucs_config_global_list_entry_t * entry ;
888+ const char * field_name ;
889+ size_t prefix_len ;
890+
891+ ucs_list_for_each (entry , & ucs_config_global_list , list ) {
892+ field_name = name ;
893+ if (entry -> prefix != NULL ) {
894+ prefix_len = strlen (entry -> prefix );
895+ if (!strncmp (entry -> prefix , field_name , prefix_len )) {
896+ field_name += prefix_len ;
897+ }
898+ }
899+
900+ if (ucs_config_parser_has_field (entry -> table , field_name )) {
901+ return 1 ;
902+ }
903+ }
904+
905+ return 0 ;
906+ }
907+
866908ucs_status_t ucp_config_modify (ucp_config_t * config , const char * name ,
867909 const char * value )
868910{
@@ -878,6 +920,17 @@ ucs_status_t ucp_config_modify(ucp_config_t *config, const char *name,
878920 return status ;
879921 }
880922
923+ if (ucs_global_opts_is_unmodifiable (name )) {
924+ ucs_debug ("%s configuration cannot be changed, the change is only "
925+ "available through the environment variable" , name );
926+ return UCS_ERR_UNSUPPORTED ;
927+ }
928+
929+ ucp_config_query_uct_components ();
930+ if (!ucp_config_global_list_has_field (name )) {
931+ return UCS_ERR_NO_ELEM ;
932+ }
933+
881934 return ucp_config_cached_key_add (& config -> cached_key_list , name , value );
882935}
883936
0 commit comments