Skip to content

Commit bc90fd7

Browse files
committed
Add max timeout for Spoolman HTTP requests
1 parent cbc5e98 commit bc90fd7

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/slic3r/Utils/Spoolman.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ namespace {
1212
template<class Type> Type get_opt(pt::ptree& data, string path) { return data.get_optional<Type>(path).value_or(Type()); }
1313
} // namespace
1414

15+
// Max timout in seconds for Spoolman HTTP requests
16+
static constexpr long MAX_TIMEOUT = 5;
17+
1518
//---------------------------------
1619
// Spoolman
1720
//---------------------------------
@@ -57,6 +60,7 @@ pt::ptree Spoolman::get_spoolman_json(const string& api_endpoint)
5760
res_body = std::move(body);
5861
res = true;
5962
})
63+
.timeout_max(MAX_TIMEOUT)
6064
.perform_sync();
6165

6266
if (!res)
@@ -100,6 +104,7 @@ pt::ptree Spoolman::put_spoolman_json(const string& api_endpoint, const pt::ptre
100104
res_body = std::move(body);
101105
res = true;
102106
})
107+
.timeout_max(MAX_TIMEOUT)
103108
.perform_sync();
104109

105110
if (!res)
@@ -362,7 +367,9 @@ bool Spoolman::is_server_valid()
362367
Http::get(get_spoolman_api_url() + "info").on_complete([&res](std::string, unsigned http_status) {
363368
if (http_status == 200)
364369
res = true;
365-
}).perform_sync();
370+
})
371+
.timeout_max(MAX_TIMEOUT)
372+
.perform_sync();
366373
return res;
367374
}
368375

0 commit comments

Comments
 (0)