Major Update:

- Merged SelectCore and PortCore into new SelectableCore
  Single well integrated Class
- Rename SelectCore.h to SelectableCore.h
- Create new TFileHandle structure for Ports/Sockets
- Moved buffer and Input Timeout from FunctionCore to TFileHandle
- Moved Read, Write and ProcessBuffer from FunctionCore to TFileHandle
Bug Fixes:
- malloc correct size for names
- Calculate MaxFD correctly when closing FDs
This commit is contained in:
Charl Wentzel
2016-05-23 14:35:15 +02:00
parent 0d1c46ac53
commit dcfbd85efa
11 changed files with 1116 additions and 953 deletions

View File

@@ -7,14 +7,10 @@
// redA Libraries
#include "TimingCore.h"
#include "SelectCore.h"
// Standard C/C++ Libraries
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "SelectableCore.h"
//---------------------------------------------------------------------------
@@ -67,6 +63,8 @@ void SelectAdd( int FD, bool Read, bool Write )
void SelectRemove( int FD, bool Read, bool Write )
{
int TestFD = 0;
// Remove from set for select read check
if (Read)
FD_CLR( FD, &ReadTestFDS);
@@ -76,13 +74,13 @@ void SelectRemove( int FD, bool Read, bool Write )
FD_CLR( FD, &WriteTestFDS);
// Check Maximum file handle
if (FD == MaxFD) {
for (int test = MaxFD-1; test >= 0; test--) {
if (FD_ISSET( test, &ReadTestFDS ) || FD_ISSET( test, &WriteTestFDS )) {
MaxFD = test+1;
if (FD == MaxFD-1) {
for (TestFD = MaxFD-1; TestFD >= 0; TestFD--) {
if (FD_ISSET( TestFD, &ReadTestFDS ) || FD_ISSET( TestFD, &WriteTestFDS )) {
break;
}
}
MaxFD = TestFD+1;
}
}
//---------------------------------------------------------------------------
@@ -120,4 +118,3 @@ bool SelectCheck( int FD, bool &Read, bool &Write )
return (Read || Write);
}
//---------------------------------------------------------------------------