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

C / C++ / MFC

 
QuestionTracking application crashes in 'C' Pin
coder21k8-Nov-10 19:08
coder21k8-Nov-10 19:08 
AnswerRe: Tracking application crashes in 'C' Pin
Cedric Moonen8-Nov-10 20:27
Cedric Moonen8-Nov-10 20:27 
AnswerRe: Tracking application crashes in 'C' Pin
Moak9-Nov-10 2:13
Moak9-Nov-10 2:13 
Questionconverting function float to string for sprintf Pin
rezen858-Nov-10 14:07
rezen858-Nov-10 14:07 
AnswerRe: converting function float to string for sprintf Pin
KingsGambit8-Nov-10 17:08
KingsGambit8-Nov-10 17:08 
AnswerRe: converting function float to string for sprintf Pin
CPallini8-Nov-10 23:19
mveCPallini8-Nov-10 23:19 
GeneralRe: converting function float to string for sprintf Pin
rezen859-Nov-10 14:53
rezen859-Nov-10 14:53 
QuestionWhat to do when GetOverlappedResult results in ERROR_IO_INCOMPLETE Pin
Code-o-mat8-Nov-10 9:05
Code-o-mat8-Nov-10 9:05 
Hello people!

I have the following (simplified) code:
OVERLAPPED Overlap = {0};
Overlap.hEvent = event_reader_with_CreateEvent;
if (ReadFile(handle_for_com_port, pBuffer, buffer_size, &bytes_read, &Overlap)) ...data read, go on happily...
else if (GetLastError() == ERROR_IO_PENDING)
{
  if (WaitForMultipleObjects(1, &Overlap.hEvent, FALSE, dwTimeOut) == WAIT_OBJECT_0)
  {
    if (GetOverlappedResult(handle_for_com_port, &Overlap, &bytes_read, FALSE)) ...data read, go on happily ...
    else if (GetLastError() == ERROR_IO_INCOMPLETE)
    {
       What to do here???
    } else ...IO error, report and go on not so happily...
  }
}

So what to do in case of ERROR_IO_INCOMPLETE? Googling around i found code sniplts where they simply try GetOverlappedResult again and again for a while until it succeeds OR some timeout or somesuch occurs. However, time to time i run into the following confusing situation:

1. ReadFile called resulting in ERROR_IO_PENDING
2. Waiting on the event returns with WAIT_OBJECT_0, the event is signalled
3. GetOverlappedResult returns FALSE and the last error code is ERROR_IO_INCOMPLETE, however, if i check the buffer (pBuffer) with the debugger i see that the data is already fully in it, however, bytes_read is 0 and it remains zero and repeatedly calling GetOverlappedResult will always result in ERROR_IO_INCOMPLETE for all ethernity (or at least as long as i was willing to wait).

Anyone knows why this is happening and what i can do to solve it? Another thing that turned up is that if i try to "timeout" from this, i mean, call GetOverlappedResult a few times giving up after a while and continuing will result in "damaged memory block", maybe because the buffer pointed at pBuffer goes out of scope but someone, somewhere still tries to write into it (just a guess)? Anyways, timeouting still can't be a solution because i lose the data that was actually read into the buffer, confusing confusing confusing...help!!!

p.s: if i call GetOverlappedResult with TRUE as the last parameter than it just seem to hang...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world.
Fry: But this is HDTV. It's got better resolution than the real world <

modified on Monday, November 8, 2010 3:13 PM

AnswerRe: What to do when GetOverlappedResult results in ERROR_IO_INCOMPLETE Pin
«_Superman_»8-Nov-10 9:37
professional«_Superman_»8-Nov-10 9:37 
GeneralRe: What to do when GetOverlappedResult results in ERROR_IO_INCOMPLETE Pin
Code-o-mat8-Nov-10 10:04
Code-o-mat8-Nov-10 10:04 
GeneralRe: What to do when GetOverlappedResult results in ERROR_IO_INCOMPLETE Pin
«_Superman_»8-Nov-10 10:12
professional«_Superman_»8-Nov-10 10:12 
GeneralRe: What to do when GetOverlappedResult results in ERROR_IO_INCOMPLETE Pin
Code-o-mat8-Nov-10 21:30
Code-o-mat8-Nov-10 21:30 
Questionchar * - returning address of local variable or temporary Pin
piul8-Nov-10 5:11
piul8-Nov-10 5:11 
AnswerRe: char * - returning address of local variable or temporary Pin
Alain Rist8-Nov-10 5:23
Alain Rist8-Nov-10 5:23 
GeneralRe: char * - returning address of local variable or temporary Pin
piul8-Nov-10 5:29
piul8-Nov-10 5:29 
GeneralRe: char * - returning address of local variable or temporary Pin
Alain Rist8-Nov-10 5:59
Alain Rist8-Nov-10 5:59 
AnswerRe: char * - returning address of local variable or temporary Pin
jschell8-Nov-10 5:39
jschell8-Nov-10 5:39 
AnswerRe: char * - returning address of local variable or temporary Pin
David Crow8-Nov-10 5:40
David Crow8-Nov-10 5:40 
AnswerRe: char * - returning address of local variable or temporary Pin
Sauro Viti8-Nov-10 5:50
professionalSauro Viti8-Nov-10 5:50 
AnswerRe: char * - returning address of local variable or temporary Pin
«_Superman_»8-Nov-10 7:03
professional«_Superman_»8-Nov-10 7:03 
AnswerRe: char * - returning address of local variable or temporary Pin
tom144312-Nov-10 2:26
tom144312-Nov-10 2:26 
Questionedit control not responding in a dialog created within an activex control Pin
lakshman rao8-Nov-10 2:59
lakshman rao8-Nov-10 2:59 
QuestionRe: edit control not responding in a dialog created within an activex control Pin
David Crow8-Nov-10 3:36
David Crow8-Nov-10 3:36 
AnswerRe: edit control not responding in a dialog created within an activex control Pin
lakshman rao8-Nov-10 3:48
lakshman rao8-Nov-10 3:48 
QuestionRe: edit control not responding in a dialog created within an activex control Pin
David Crow8-Nov-10 3:51
David Crow8-Nov-10 3:51 

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.