@@ -150,8 +150,10 @@ static int cdb2cfg_override = CDB2CFG_OVERRIDE_DEFAULT;
150150#define CDB2_REQUEST_FP_DEFAULT 0
151151static int CDB2_REQUEST_FP = CDB2_REQUEST_FP_DEFAULT ;
152152
153+ /* Request host name of a connection obtained from sockpool */
153154#define CDB2_GET_HOSTNAME_FROM_SOCKPOOL_FD_DEFAULT 1
154- static int CDB2_GET_HOSTNAME_FROM_SOCKPOOL_FD = CDB2_GET_HOSTNAME_FROM_SOCKPOOL_FD_DEFAULT ;
155+ static int get_hostname_from_sockpool_fd = CDB2_GET_HOSTNAME_FROM_SOCKPOOL_FD_DEFAULT ;
156+ static int cdb2_get_hostname_from_sockpool_fd_set_from_env = 0 ;
155157
156158static void * cdb2_protobuf_alloc (void * allocator_data , size_t size )
157159{
@@ -187,6 +189,13 @@ static int cdb2_use_env_vars = 1;
187189
188190static int default_type_override_env = 0 ;
189191
192+ static int iam_identity = 0 ;
193+ static int cdb2_iam_identity_set_from_env = 0 ;
194+
195+ #define CDB2_ALLOW_PMUX_ROUTE_DEFAULT 0
196+ static int cdb2_allow_pmux_route = CDB2_ALLOW_PMUX_ROUTE_DEFAULT ;
197+ static int cdb2_allow_pmux_route_set_from_env = 0 ;
198+
190199/* ssl client mode */
191200static ssl_mode cdb2_c_ssl_mode = SSL_ALLOW ;
192201/* path to ssl certificate directory. searches 'client.crt', 'client.key', 'root.crt'
@@ -230,12 +239,6 @@ static int cdb2_add_ssl_session(cdb2_hndl_tp *hndl);
230239
231240static pthread_mutex_t cdb2_cfg_lock = PTHREAD_MUTEX_INITIALIZER ;
232241
233- #define CDB2_ALLOW_PMUX_ROUTE_DEFAULT 0
234- static int cdb2_allow_pmux_route = CDB2_ALLOW_PMUX_ROUTE_DEFAULT ;
235- static int cdb2_allow_pmux_route_set_from_env = 0 ;
236-
237- static int iam_identity = 0 ;
238-
239242pthread_mutex_t cdb2_sockpool_mutex = PTHREAD_MUTEX_INITIALIZER ;
240243#define MAX_SOCKPOOL_FDS 8
241244
@@ -363,7 +366,7 @@ static void reset_the_configuration(void)
363366 cdb2_allow_pmux_route = CDB2_ALLOW_PMUX_ROUTE_DEFAULT ;
364367 cdb2cfg_override = CDB2CFG_OVERRIDE_DEFAULT ;
365368 CDB2_REQUEST_FP = CDB2_REQUEST_FP_DEFAULT ;
366- CDB2_GET_HOSTNAME_FROM_SOCKPOOL_FD = CDB2_GET_HOSTNAME_FROM_SOCKPOOL_FD_DEFAULT ;
369+ get_hostname_from_sockpool_fd = CDB2_GET_HOSTNAME_FROM_SOCKPOOL_FD_DEFAULT ;
367370
368371 cdb2_c_ssl_mode = SSL_ALLOW ;
369372
@@ -1341,6 +1344,7 @@ static void read_comdb2db_environment_cfg(cdb2_hndl_tp *hndl, const char *comdb2
13411344 pthread_mutex_lock (& cdb2_sockpool_mutex );
13421345 if (!have_read_env ) {
13431346 // Do these once.
1347+ process_env_var_str_on_off ("COMDB2_FEATURE_IAM_IDENTITY" , & iam_identity , & cdb2_iam_identity_set_from_env );
13441348 process_env_var_str ("COMDB2_CONFIG_ROOM" , (char * )& cdb2_machine_room , sizeof (cdb2_machine_room ),
13451349 & cdb2_machine_room_set_from_env );
13461350 process_env_var_int ("COMDB2_CONFIG_PORTMUXPORT" , & CDB2_PORTMUXPORT , & cdb2_portmuxport_set_from_env );
@@ -1351,6 +1355,8 @@ static void read_comdb2db_environment_cfg(cdb2_hndl_tp *hndl, const char *comdb2
13511355 & cdb2_dnssuffix_set_from_env );
13521356 process_env_var_str_on_off ("COMDB2_CONFIG_ALLOW_PMUX_ROUTE" , & cdb2_allow_pmux_route ,
13531357 & cdb2_allow_pmux_route_set_from_env );
1358+ process_env_var_str_on_off ("COMDB2_CONFIG_GET_HOSTNAME_FROM_SOCKPOOL_FD" , & get_hostname_from_sockpool_fd ,
1359+ & cdb2_get_hostname_from_sockpool_fd_set_from_env );
13541360 process_env_var_str ("COMDB2_CONFIG_DEFAULT_TYPE" , (char * )& cdb2_default_cluster , sizeof (cdb2_default_cluster ),
13551361 & cdb2_default_cluster_set_from_env );
13561362 process_env_var_int ("COMDB2_CONFIG_CONNECT_TIMEOUT" , & CDB2_CONNECT_TIMEOUT , & cdb2_connect_timeout_set_from_env );
@@ -1441,7 +1447,7 @@ static void read_comdb2db_cfg(cdb2_hndl_tp *hndl, SBUF2 *s, const char *comdb2db
14411447 }
14421448 } else if (strcasecmp ("comdb2_feature" , tok ) == 0 ) {
14431449 tok = strtok_r (NULL , " =:," , & last );
1444- if ((strcasecmp ("iam_identity_v6" ,tok ) == 0 )) {
1450+ if (! cdb2_iam_identity_set_from_env && (strcasecmp ("iam_identity_v6" , tok ) == 0 )) {
14451451 tok = strtok_r (NULL , " =:," , & last );
14461452 if (tok )
14471453 iam_identity = value_on_off (tok , & err , 0 );
@@ -1566,10 +1572,11 @@ static void read_comdb2db_cfg(cdb2_hndl_tp *hndl, SBUF2 *s, const char *comdb2db
15661572 * stack_at_open = 0 ;
15671573 }
15681574 }
1569- } else if (strcasecmp ("get_hostname_from_sockpool_fd" , tok ) == 0 ) {
1575+ } else if (!cdb2_get_hostname_from_sockpool_fd_set_from_env &&
1576+ (strcasecmp ("get_hostname_from_sockpool_fd_v3" , tok ) == 0 )) {
15701577 tok = strtok_r (NULL , " :," , & last );
15711578 if (tok )
1572- CDB2_GET_HOSTNAME_FROM_SOCKPOOL_FD = ( strncasecmp ( tok , "true" , 4 ) == 0 );
1579+ get_hostname_from_sockpool_fd = value_on_off ( tok , & err , 1 );
15731580 } else if (strcasecmp ("ssl_mode" , tok ) == 0 ) {
15741581 tok = strtok_r (NULL , " :," , & last );
15751582 if (tok != NULL ) {
@@ -2506,7 +2513,7 @@ static void get_host_and_port_from_fd(int fd, char *buf, size_t n, int *port)
25062513 struct sockaddr_in addr ;
25072514 socklen_t addr_size = sizeof (struct sockaddr_in );
25082515
2509- if (!CDB2_GET_HOSTNAME_FROM_SOCKPOOL_FD )
2516+ if (!get_hostname_from_sockpool_fd )
25102517 return ;
25112518
25122519 if (fd == -1 )
0 commit comments