Windows 2003 -- RasHangUp blocks for several seconds before returning, and handle count keeps climbing?
Posted on 2007-08-07
I am using RAS to create and disconnect VPN connections. I can establish the connection without any problems and transfer data across it. However, I am experiencing two issues:
1. RasDial blocks for about 5 seconds before returning.
2. According to Task Manager, the program's handle count is steadily increasing, even though I am careful to give RAS enough time to release the handle.
Here is my hangup code, :
int hangup(HRASCONN* vpnConn)
DWORD RASDialStatus = -1;
memset ((void*) &vpnConnStatus, 0, sizeof(RASCONNSTATUS));
vpnConnStatus.dwSize = sizeof(RASCONNSTATUS);
RASDialStatus = RasHangUp(*vpnConn);
while (RASDialStatus != ERROR_INVALID_HANDLE)
RASDialStatus = RasGetConnectStatus (*vpnConn, &vpnConnStatus);
/* Error handling stuff goes here */
I thought at first that the while() loop was causing the delay. However, when I step through the code, RasHangup() blocks for about 5 seconds before it returns 0. The while loop runs just once before the RasGetConnectStatus returns ERROR_INVALID_HANDLE.
Does anyone know what might be causing RasHangup to take so long to return? Could it be something in the way that I am initializing the connection properties when I call RasDial?