@@ -80,12 +80,6 @@ void server_config_manager::ensure_loaded() {
8080
8181 if (!fs::exists (path)) {
8282 data.clear ();
83- last_write_time = {};
84- return ;
85- }
86-
87- const auto current_write_time = fs::last_write_time (path);
88- if (last_write_time == current_write_time) {
8983 return ;
9084 }
9185
@@ -96,35 +90,35 @@ void server_config_manager::ensure_loaded() {
9690
9791 std::string contents ((std::istreambuf_iterator<char >(file)), std::istreambuf_iterator<char >());
9892
99- static const auto & parser = * new common_peg_arena ( build_peg_parser ([](common_peg_parser_builder & p) {
93+ static const auto parser = build_peg_parser ([](auto & p) {
10094 const auto ws = p.space ();
10195 const auto new_line = p.choice ({p.literal (" \r\n " ), p.literal (" \n " ), p.literal (" \r " )});
10296
10397 const auto section_name = p.tag (" section-name" , p.until (" ]" ));
104- const auto section_line = p. zero_or_more (ws) + " [" + section_name + " ]" + p.optional (p. until_one_of ({" \r " , " \n " }) );
98+ const auto section_line = ws + " [" + section_name + " ]" + p.until_one_of ({" \r " , " \n " });
10599
106100 const auto key = p.tag (" key" , p.until (" =" ));
107101 const auto value = p.tag (" value" , p.until_one_of ({" \r " , " \n " }));
108- const auto key_value_line = p. zero_or_more (ws) + key + p. zero_or_more (ws) + " =" + p. zero_or_more (ws) + p. optional ( value) ;
102+ const auto key_value_line = ws + key + ws + " =" + ws + value;
109103
110- const auto comment = p.choice ({p.literal (" ;" ), p.literal (" #" )}) + p.optional (p. until_one_of ({" \r " , " \n " }) );
111- const auto comment_line = p. zero_or_more (ws) + comment;
104+ const auto comment = p.choice ({p.literal (" ;" ), p.literal (" #" )}) + p.until_one_of ({" \r " , " \n " });
105+ const auto comment_line = ws + comment;
112106
113- const auto blank_line = p. zero_or_more (ws) + new_line;
107+ const auto blank_line = ws + new_line;
114108
115109 const auto line = p.choice ({
116- section_line << p. optional ( new_line) ,
117- key_value_line << p. optional ( new_line) ,
118- comment_line << p. optional ( new_line) ,
110+ section_line + new_line,
111+ key_value_line + new_line,
112+ comment_line + new_line,
119113 blank_line,
120114 });
121115
122- return p.rule (" ini" , p.zero_or_more (line) << p.optional (p. zero_or_more ( ws)) << p.end ());
123- })) ;
116+ return p.rule (" ini" , p.zero_or_more (line) + p.optional (ws) + p.end ());
117+ });
124118
125119 common_peg_parse_context ctx (contents);
126120 const auto result = parser.parse (ctx);
127- if (!result.success () || result. end != contents. size () ) {
121+ if (!result.success ()) {
128122 throw std::runtime_error (" failed to parse server config file: " + path);
129123 }
130124
@@ -181,7 +175,6 @@ void server_config_manager::ensure_loaded() {
181175 }
182176
183177 data = std::move (parsed);
184- last_write_time = current_write_time;
185178}
186179
187180// write_locked expects the caller to hold `mutex`.
@@ -220,7 +213,6 @@ void server_config_manager::write_locked() {
220213 }
221214
222215 file.flush ();
223- last_write_time = fs::last_write_time (path);
224216}
225217
226218bool is_router_control_arg (const std::string & arg) {
0 commit comments