Bug Fix in modesReadFromClient()
The modesReadFromClient() funtion is called from modesReadFromClients(), which in turn is called from backgroundTasks(). backgroundTasks() is called from within the main processing loop. However, modesReadFromClient() can and does block. It attempts to read characters from the input stream, and loops whilst there was no error. This stalls the main RTL processing loop until an error occurs. In order to support simultaneous local reception (via our RTL dongle) and remote forwarding (data received from the interweb) we cannot allow this internet read to stall. To fix this, in modesReadFromClient() attempt to read a buffer of data (currently 0x400 bytes). If we get a full buffer of bytes, then process them, and attempt to read another full buffer. Keep doing thios untill we read only a partial buffer (less than 0x400 bytes). Process the partial buffer bytes and return. This allows us to occasionally process data that is arriving from the internet (which is buffered anyway in the TCP stack), without blocking local RTL dongle decoding.
This commit is contained in:
parent
52ac50b018
commit
7ea2e8fdef
3 changed files with 59 additions and 16 deletions
|
|
@ -41,6 +41,40 @@ static uint64_t mstime(void) {
|
|||
mst += tv.tv_usec/1000;
|
||||
return mst;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
// Standard error macro for reporting API errors
|
||||
#define PERR(bSuccess, api){if(!(bSuccess)) printf("%s:Error %d from %s on line %d\n", __FILE__, GetLastError(), api, __LINE__);}
|
||||
|
||||
void cls( HANDLE hConsole ) {
|
||||
COORD coordScreen = { 0, 0 }; // here's where we'll home the cursor
|
||||
BOOL bSuccess;
|
||||
DWORD cCharsWritten;
|
||||
CONSOLE_SCREEN_BUFFER_INFO csbi; // to get buffer info
|
||||
DWORD dwConSize; // number of character cells in the current buffer
|
||||
|
||||
// get the number of character cells in the current buffer
|
||||
bSuccess = GetConsoleScreenBufferInfo( hConsole, &csbi );
|
||||
PERR( bSuccess, "GetConsoleScreenBufferInfo" );
|
||||
dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
|
||||
|
||||
// fill the entire screen with blanks
|
||||
bSuccess = FillConsoleOutputCharacter( hConsole, (TCHAR) ' ', dwConSize, coordScreen, &cCharsWritten );
|
||||
PERR( bSuccess, "FillConsoleOutputCharacter" );
|
||||
|
||||
// get the current text attribute
|
||||
bSuccess = GetConsoleScreenBufferInfo( hConsole, &csbi );
|
||||
PERR( bSuccess, "ConsoleScreenBufferInfo" );
|
||||
|
||||
// now set the buffer's attributes accordingly
|
||||
bSuccess = FillConsoleOutputAttribute( hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten );
|
||||
PERR( bSuccess, "FillConsoleOutputAttribute" );
|
||||
|
||||
// put the cursor at (0, 0)
|
||||
bSuccess = SetConsoleCursorPosition( hConsole, coordScreen );
|
||||
PERR( bSuccess, "SetConsoleCursorPosition" );
|
||||
}
|
||||
#endif
|
||||
//
|
||||
//========================= Interactive mode ===============================
|
||||
//
|
||||
|
|
@ -342,7 +376,7 @@ void interactiveShowData(void) {
|
|||
#ifndef _WIN32
|
||||
printf("\x1b[H\x1b[2J"); // Clear the screen
|
||||
#else
|
||||
system("cls");
|
||||
cls(GetStdHandle(STD_OUTPUT_HANDLE));
|
||||
#endif
|
||||
|
||||
if (Modes.interactive_rtl1090 == 0) {
|
||||
|
|
@ -439,7 +473,7 @@ void interactiveShowData(void) {
|
|||
//=========================================================================
|
||||
//
|
||||
// When in interactive mode If we don't receive new nessages within
|
||||
// MODES_INTERACTIVE__DELETE_TTL seconds we remove the aircraft from the list.
|
||||
// MODES_INTERACTIVE_DELETE_TTL seconds we remove the aircraft from the list.
|
||||
//
|
||||
void interactiveRemoveStaleAircrafts(void) {
|
||||
struct aircraft *a = Modes.aircrafts;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue