WMI: add timeout to prevent CI from hanging

Hard coded 5 seconds
This commit is contained in:
李通洲
2023-01-29 10:10:31 +08:00
parent 679162c762
commit 517e3fcff9
2 changed files with 6 additions and 4 deletions
+1 -3
View File
@@ -111,9 +111,7 @@ FFWmiQuery::FFWmiQuery(const wchar_t* queryStr, FFstrbuf* error, FFWmiNamespace
}
// Use the IWbemServices pointer to make requests of WMI
HRESULT hres;
hres = ((IWbemServices*)context)->ExecQuery(
HRESULT hres = ((IWbemServices*)context)->ExecQuery(
bstr_t(L"WQL"),
bstr_t(queryStr),
WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY,
+5 -1
View File
@@ -18,6 +18,10 @@ enum class FFWmiNamespace {
LAST,
};
enum {
FF_WMI_QUERY_TIMEOUT = 5000
};
struct FFWmiRecord
{
IWbemClassObject* obj;
@@ -26,7 +30,7 @@ struct FFWmiRecord
if(!pEnumerator) return;
ULONG ret;
bool ok = SUCCEEDED(pEnumerator->Next((LONG)WBEM_INFINITE, 1, &obj, &ret)) && ret;
bool ok = SUCCEEDED(pEnumerator->Next(FF_WMI_QUERY_TIMEOUT, 1, &obj, &ret)) && ret;
if(!ok) obj = nullptr;
}
FFWmiRecord(const FFWmiRecord&) = delete;