Restructuring of network output side.
Mostly refactoring the common code that was duplicated between the different output types so that there aren't many copies floating around. This introduces "struct net_writer" to store the state of a particular type of output service - buffers, time of last write, connection count etc. prepareWrite() / completeWrite() give access to the buffer and handle the actual writes and flushing when needed. Heartbeat and time-based flushing move into a generic periodic-work function. Update the SBS output code to use the new infrastructure. This makes a big different to CPU use when under load.
This commit is contained in:
parent
8d4f1a396c
commit
1769ac9006
4 changed files with 216 additions and 160 deletions
40
mode_s.c
40
mode_s.c
|
@ -1849,43 +1849,6 @@ void detectModeS(uint16_t *m, uint32_t mlen) {
|
|||
use_correction = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//Send any remaining partial raw buffers now
|
||||
if (Modes.rawOutUsed || Modes.beastOutUsed)
|
||||
{
|
||||
Modes.net_output_raw_rate_count++;
|
||||
if (Modes.net_output_raw_rate_count > Modes.net_output_raw_rate)
|
||||
{
|
||||
if (Modes.rawOutUsed) {
|
||||
modesSendAllClients(Modes.ros, Modes.rawOut, Modes.rawOutUsed);
|
||||
Modes.rawOutUsed = 0;
|
||||
}
|
||||
if (Modes.beastOutUsed) {
|
||||
modesSendAllClients(Modes.bos, Modes.beastOut, Modes.beastOutUsed);
|
||||
Modes.beastOutUsed = 0;
|
||||
}
|
||||
Modes.net_output_raw_rate_count = 0;
|
||||
}
|
||||
}
|
||||
else if ( (Modes.net)
|
||||
&& (Modes.net_heartbeat_rate)
|
||||
&& ((++Modes.net_heartbeat_count) > Modes.net_heartbeat_rate) ) {
|
||||
//
|
||||
// We haven't received any Mode A/C/S messages for some time. To try and keep any TCP
|
||||
// links alive, send a null frame. This will help stop any routers discarding our TCP
|
||||
// link which will cause an un-recoverable link error if/when a real frame arrives.
|
||||
//
|
||||
// Fudge up a null message
|
||||
memset(&mm, 0, sizeof(mm));
|
||||
mm.msgbits = MODES_SHORT_MSG_BITS;
|
||||
mm.timestampMsg = Modes.timestampBlk;
|
||||
|
||||
// Feed output clients
|
||||
modesQueueOutput(&mm);
|
||||
|
||||
// Reset the heartbeat counter
|
||||
Modes.net_heartbeat_count = 0;
|
||||
}
|
||||
}
|
||||
//
|
||||
//=========================================================================
|
||||
|
@ -1910,9 +1873,6 @@ void useModesMessage(struct modesMessage *mm) {
|
|||
|
||||
// Feed output clients
|
||||
if (Modes.net) {modesQueueOutput(mm);}
|
||||
|
||||
// Heartbeat not required whilst we're seeing real messages
|
||||
Modes.net_heartbeat_count = 0;
|
||||
}
|
||||
}
|
||||
//
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue