@@ -156,7 +156,6 @@ static bool http_reload_config(std::shared_ptr<CONFIG_FILE> xcfg = nullptr,
156156
157157int main (int argc, char **argv)
158158{
159- char temp_buff[256 ];
160159 int retcode = EXIT_FAILURE;
161160 char host_name[UDOM_SIZE], *ptoken;
162161 const char *dns_name, *dns_domain, *netbios_name;
@@ -193,13 +192,12 @@ int main(int argc, char **argv)
193192
194193 auto str_val = g_config_file->get_value (" host_id" );
195194 if (str_val == NULL ) {
196- memset (temp_buff, 0 , std::size (temp_buff));
197- gethostname (temp_buff, std::size (temp_buff));
198- temp_buff[std::size (temp_buff)-1 ] = ' \0 ' ;
199- g_config_file->set_value (" host_id" , temp_buff);
200- str_val = temp_buff;
201- if (strchr (str_val, ' .' ) == nullptr )
202- mlog (LV_NOTICE, " System hostname \" %s\" has no dot, which may point to a misconfiguration" , str_val);
195+ std::string hn;
196+ auto ret = canonical_hostname (hn);
197+ if (ret != 0 )
198+ return EXIT_FAILURE;
199+ g_config_file->set_value (" host_id" , hn.c_str ());
200+ str_val = g_config_file->get_value (" host_id" );
203201 }
204202 mlog (LV_INFO, " system: host ID is \" %s\" " , str_val);
205203 gx_strlcpy (host_name, str_val, std::size (host_name));
@@ -238,6 +236,7 @@ int main(int argc, char **argv)
238236 thread_init_num);
239237
240238 unsigned int context_aver_mem = g_config_file->get_ll (" context_average_mem" ) / (64 * 1024 );
239+ char temp_buff[256 ];
241240 HX_unit_size (temp_buff, std::size (temp_buff), context_aver_mem * 64 * 1024 , 1024 , 0 );
242241 mlog (LV_INFO, " http: context average memory is %s" , temp_buff);
243242
0 commit comments