@@ -4469,28 +4469,39 @@ nc_server_set_unix_socket_path(const char *endpoint_name, const char *socket_pat
44694469 return rc ;
44704470}
44714471
4472- API const char *
4473- nc_server_get_unix_socket_path (const char * endpoint_name )
4472+ API int
4473+ nc_server_get_unix_socket_path (const char * endpoint_name , char * * socket_path )
44744474{
4475- const char * socket_path = NULL ;
4475+ int rc = 0 ;
4476+ char * p = NULL ;
44764477 LY_ARRAY_COUNT_TYPE i ;
44774478
4478- NC_CHECK_ARG_RET (NULL , endpoint_name , NULL );
4479+ NC_CHECK_ARG_RET (NULL , endpoint_name , socket_path , 1 );
4480+
4481+ * socket_path = NULL ;
44794482
44804483 /* CONFIG READ LOCK */
44814484 pthread_rwlock_rdlock (& server_opts .config_lock );
44824485
44834486 /* try to find the path for this endpoint */
44844487 LY_ARRAY_FOR (server_opts .unix_paths , i ) {
44854488 if (!strcmp (server_opts .unix_paths [i ].endpt_name , endpoint_name )) {
4486- socket_path = server_opts .unix_paths [i ].path ;
4489+ p = server_opts .unix_paths [i ].path ;
44874490 break ;
44884491 }
44894492 }
44904493
4494+ if (!p ) {
4495+ goto cleanup ;
4496+ }
4497+
4498+ * socket_path = strdup (p );
4499+ NC_CHECK_ERRMEM_GOTO (!* socket_path , rc = 1 , cleanup );
4500+
4501+ cleanup :
44914502 /* CONFIG READ UNLOCK */
44924503 pthread_rwlock_unlock (& server_opts .config_lock );
4493- return socket_path ;
4504+ return rc ;
44944505}
44954506
44964507API int
@@ -4510,3 +4521,24 @@ nc_server_set_unix_socket_dir(const char *dir)
45104521 pthread_rwlock_unlock (& server_opts .config_lock );
45114522 return rc ;
45124523}
4524+
4525+ API int
4526+ nc_server_get_unix_socket_dir (char * * dir )
4527+ {
4528+ int rc = 0 ;
4529+
4530+ * dir = NULL ;
4531+
4532+ /* CONFIG READ LOCK */
4533+ pthread_rwlock_rdlock (& server_opts .config_lock );
4534+
4535+ if (server_opts .unix_socket_dir ) {
4536+ * dir = strdup (server_opts .unix_socket_dir );
4537+ NC_CHECK_ERRMEM_GOTO (!* dir , rc = 1 , cleanup );
4538+ }
4539+
4540+ cleanup :
4541+ /* CONFIG READ UNLOCK */
4542+ pthread_rwlock_unlock (& server_opts .config_lock );
4543+ return rc ;
4544+ }
0 commit comments