July 17th, 2014

What does it mean when GetQueuedCompletionStatus return ERROR_SEM_TIMEOUT?

A customer asked for assistance interpreting a failure of the Get­Queued­Completion­Status function.

We are observing that Get­Queued­Completion­Status is intermittently behaving as follows:

  • The handle is a SOCKET.
  • The function returns FALSE.
  • lpOverlapped != NULL.
  • Get­Last­Error reports ERROR_SEM_TIMEOUT: “The semaphore timeout period has expired.”

That’s all the information we have in our log files. We don’t know the value of number­Of­Bytes or completion­Key, sorry.

We realize that this is a rather vague question, but when this problem hits our machines, it causes our internal logic to go into a reset state since it doesn’t know what the error means or how to recover. Resetting is expensive, and we would prefer to handle this error in a less drastic manner, if only we knew what it meant.

The error code ERROR_SEM_TIMEOUT is a rather bad translation of the underlying status code STATUS_IO_TIMEOUT, which is much more meaningful. It means that the I/O operation timed out. Colleagues of mine from the networking team chimed in with additional information: A common source of this error with TCP sockets is that the maximum retransmission count and timeout have been reached on a bad (or broken) link.

If you know that the handle is a socket, then you can use WSA­Get­Overlapped­Result on the lpOverlapped that got returned. Winsock will convert the status code to something more Winsocky. In this case, it would have given you WSA­ETIMED­OUT, which makes it clearer what happened.

Topics
Code

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.