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
|
|
@ -159,7 +159,7 @@
|
|||
#define MODES_INTERACTIVE_DELETE_TTL 300 // Delete from the list after 300 seconds
|
||||
#define MODES_INTERACTIVE_DISPLAY_TTL 60 // Delete from display after 60 seconds
|
||||
|
||||
#define MODES_NET_MAX_FD 1024
|
||||
#define MODES_NET_MAX_FD 1024
|
||||
#define MODES_NET_INPUT_RAW_PORT 30001
|
||||
#define MODES_NET_OUTPUT_RAW_PORT 30002
|
||||
#define MODES_NET_OUTPUT_SBS_PORT 30003
|
||||
|
|
@ -181,8 +181,8 @@
|
|||
struct client {
|
||||
int fd; // File descriptor
|
||||
int service; // TCP port the client is connected to
|
||||
char buf[MODES_CLIENT_BUF_SIZE+1]; // Read buffer
|
||||
int buflen; // Amount of data on buffer
|
||||
char buf[MODES_CLIENT_BUF_SIZE+1]; // Read buffer
|
||||
};
|
||||
|
||||
// Structure used to describe an aircraft in iteractive mode
|
||||
|
|
@ -405,6 +405,8 @@ void modesInitErrorInfo ();
|
|||
struct aircraft* interactiveReceiveData(struct modesMessage *mm);
|
||||
void interactiveShowData(void);
|
||||
void interactiveRemoveStaleAircrafts(void);
|
||||
int decodeBinMessage (struct client *c, char *p);
|
||||
|
||||
//
|
||||
// Functions exported from net_io.c
|
||||
//
|
||||
|
|
@ -412,6 +414,7 @@ void modesInitNet (void);
|
|||
void modesReadFromClients (void);
|
||||
void modesSendAllClients (int service, void *msg, int len);
|
||||
void modesQueueOutput (struct modesMessage *mm);
|
||||
void modesReadFromClient(struct client *c, char *sep, int(*handler)(struct client *, char *));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue