Quantcast
Channel: WE MOVED to github.com/microsoft/cpprestsdk. This site is not monitored!
Viewing all articles
Browse latest Browse all 4845

Closed Unassigned: Deadlock in Windows XP [374]

$
0
0
If cpprest compiled with CPPREST_FORCE_PPLX and CPPREST_TARGET_XP macroses application can be catch the deadlock in Windows XP. This sample can easy demonstrate deadlock only in Windows XP:
```
#include "stdafx.h"
#include <cpprest/http_client.h>
#include <thread>

int _tmain(int argc, _TCHAR* argv[])
{
std::cout << std::this_thread::get_id() << std::endl;
pplx::create_task([](){
std::cout << std::this_thread::get_id() << std::endl;
pplx::create_task([](){
std::cout << std::this_thread::get_id() << std::endl;
}).get();
}).get();
return 0;
}
```
Output:
3768
3104

There is happend due to the fact that the QueueUserWorkItem function using WT_EXECUTEDEFAULT flag. If I am changing it on WT_EXECUTELONGFUNCTION, the deadlock is gone.

Maybe you have more effective solution...

p.s.
I am using CPPREST_FORCE_PPLX because the scheduler of PPL on the Concurrency Runtime has deadlock problem too but more complex. Emulation switching context in crt is bad idea)
I am using CPPREST_TARGET_XP because unfortunately my company has 25% users on Windows XP.

Sorry my english is poor.

Viewing all articles
Browse latest Browse all 4845