Click here to Skip to main content
15,911,891 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Static Analysis code reqired for C++ Pin
Joe Woodbury22-Nov-13 5:37
professionalJoe Woodbury22-Nov-13 5:37 
GeneralRe: Static Analysis code reqired for C++ Pin
Stefan_Lang26-Nov-13 22:51
Stefan_Lang26-Nov-13 22:51 
GeneralRe: Static Analysis code reqired for C++ Pin
Joe Woodbury27-Nov-13 4:19
professionalJoe Woodbury27-Nov-13 4:19 
QuestionCancelWaitableTimer bug when used with socket? Pin
ehaerim17-Nov-13 15:13
ehaerim17-Nov-13 15:13 
AnswerRe: CancelWaitableTimer bug when used with socket? Pin
Orjan Westin19-Nov-13 5:28
professionalOrjan Westin19-Nov-13 5:28 
GeneralRe: CancelWaitableTimer bug when used with socket? Pin
ehaerim19-Nov-13 18:19
ehaerim19-Nov-13 18:19 
AnswerRe: CancelWaitableTimer bug when used with socket? Pin
Randor 20-Nov-13 7:29
professional Randor 20-Nov-13 7:29 
GeneralRe: CancelWaitableTimer bug when used with socket? Pin
ehaerim20-Nov-13 9:46
ehaerim20-Nov-13 9:46 
David,

First of all thx for your kind response.
But, I think you have read the code a bit wrong way withing the limit of my knowledge.

Randor wrote:
Your due time is set to the minimum 0xA value (one NT quantum).

This is wrong because I set the initial due time and period as follows at line 15-16
#define WAITABLETIMER_PERIOD								(USER_TIMER_MINIMUM * 1)
#define WAITABLETIMER_DUETIME_INITIALLY			(0)

It is the period that set to 0xA, not the initial due time.
The initial due time and period is intentionally set to 0 and 0xA to fire the timer 'immediately first time and ,after then, in the period of every 0xA milliseconds'.
Because of 'immediate due time', the timer gets signaled 'immediately' literally, and therefore 'case WAIT_OBJECT_0 + 1:' statement is the first statement executed without any delay.
Then socket Connect fails with WSAEWOULDBLOCK error and finally CWT call returns TRUE in sequence.
So, the overall code flow is like this:

pWTDlg->m_hTimerRC = CreateWaitableTimer(NULL, FALSE, NULL);	// automatic reset timer
bRet = SetWaitableTimer(pWTDlg->m_hTimerRC, 0, 0xA, NULL, NULL, NULL);	// immediate, periodic(10ms) timer // TRUE
pWTDlg->m_bCreated = sock.Create(); // TRUE
pWTDlg->m_bConnected = sock.Connect(...);  // FALSE with WSAEWOULDBLOCK
bRet = CancelWaitableTimer(pWTDlg->m_hTimerRC); // TRUE

Since the last CancelWaitableTimer returns TRUE, it should stop the timer right away, but the timer gets signaled just one more time. That's the issue!
Questions here are
- Why is the timer not stopped even after CWT returns TRUE?
- Why is the timer always signaled just one more time, not two or three and so on even if I admit the timer can be signaled more times after CWT returns TRUE(of course, I don't admit this, but just for the discussion of this issue, though)?
- What's the use of CWT if it is not guaranteed to stop the timer immediately? I'd rather set INFINITE due time and/or INFINITE period for SWT instead of using CWT.

I hope I miss something but unfortunately I don't know what are they.
Please be very specific and detail explaining what's going on about this issue.

regards
GeneralRe: CancelWaitableTimer bug when used with socket? Pin
Randor 20-Nov-13 10:55
professional Randor 20-Nov-13 10:55 
GeneralRe: CancelWaitableTimer bug when used with socket? Pin
ehaerim20-Nov-13 11:36
ehaerim20-Nov-13 11:36 
QuestionIs it possible to enumerate symbols in a PDB file using DBGHELP.LIB - NO Process Loaded. Pin
Blake Miller15-Nov-13 13:02
Blake Miller15-Nov-13 13:02 
AnswerRe: Is it possible to enumerate symbols in a PDB file using DBGHELP.LIB - NO Process Loaded. Pin
Randor 18-Nov-13 5:54
professional Randor 18-Nov-13 5:54 
QuestionCatch ENTER key on CBitmapButton Pin
_Flaviu15-Nov-13 2:38
_Flaviu15-Nov-13 2:38 
QuestionRe: Catch ENTER key on CBitmapButton Pin
Richard MacCutchan15-Nov-13 3:01
mveRichard MacCutchan15-Nov-13 3:01 
AnswerRe: Catch ENTER key on CBitmapButton Pin
_Flaviu15-Nov-13 3:02
_Flaviu15-Nov-13 3:02 
AnswerRe: Catch ENTER key on CBitmapButton Pin
_Flaviu17-Nov-13 21:33
_Flaviu17-Nov-13 21:33 
GeneralRe: Catch ENTER key on CBitmapButton Pin
Richard MacCutchan17-Nov-13 22:01
mveRichard MacCutchan17-Nov-13 22:01 
GeneralRe: Catch ENTER key on CBitmapButton Pin
_Flaviu17-Nov-13 22:06
_Flaviu17-Nov-13 22:06 
QuestionSendMessage for WM_GETTEXT not working in case of unicode data. Pin
Le@rner15-Nov-13 0:50
Le@rner15-Nov-13 0:50 
QuestionRe: SendMessage for WM_GETTEXT not working in case of unicode data. Pin
Richard MacCutchan15-Nov-13 2:54
mveRichard MacCutchan15-Nov-13 2:54 
AnswerRe: SendMessage for WM_GETTEXT not working in case of unicode data. Pin
Le@rner15-Nov-13 17:12
Le@rner15-Nov-13 17:12 
QuestionStack overflow after calling SetLocalTime in visual studio 2008 Pin
corina.beer14-Nov-13 0:21
corina.beer14-Nov-13 0:21 
QuestionRe: Stack overflow after calling SetLocalTime in visual studio 2008 Pin
David Crow14-Nov-13 7:57
David Crow14-Nov-13 7:57 
AnswerRe: Stack overflow after calling SetLocalTime in visual studio 2008 Pin
corina.beer14-Nov-13 8:18
corina.beer14-Nov-13 8:18 
QuestionRe: Stack overflow after calling SetLocalTime in visual studio 2008 Pin
David Crow14-Nov-13 9:12
David Crow14-Nov-13 9:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.