all windows fixes
This commit is contained in:
parent
5284eadca6
commit
d9744365d2
@ -46,7 +46,9 @@ ReturnValue_t TcpTmTcServer::initialize() {
|
||||
if(spacePacketParser == nullptr) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
#if defined PLATFORM_UNIX
|
||||
tcpConfig.tcpFlags |= MSG_DONTWAIT;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -155,6 +157,10 @@ ReturnValue_t TcpTmTcServer::initializeAfterTaskCreation() {
|
||||
}
|
||||
|
||||
void TcpTmTcServer::handleServerOperation(socket_t& connSocket) {
|
||||
#if defined PLATFORM_WIN
|
||||
setSocketNonBlocking(connSocket);
|
||||
#endif
|
||||
|
||||
while (true) {
|
||||
int retval = recv(
|
||||
connSocket,
|
||||
@ -172,7 +178,13 @@ void TcpTmTcServer::handleServerOperation(socket_t& connSocket) {
|
||||
ringBuffer.writeData(receptionBuffer.data(), retval);
|
||||
}
|
||||
else if(retval < 0) {
|
||||
if(errno == EAGAIN) {
|
||||
int errorValue = GetLastError();
|
||||
#if defined PLATFORM_UNIX
|
||||
int wouldBlockValue = EAGAIN;
|
||||
#elif defined PLATFORM_WIN
|
||||
int wouldBlockValue = WSAEWOULDBLOCK;
|
||||
#endif
|
||||
if(errorValue == wouldBlockValue) {
|
||||
// No data available. Check whether any packets have been read, then send back
|
||||
// telemetry if available
|
||||
bool tcAvailable = false;
|
||||
@ -191,7 +203,7 @@ void TcpTmTcServer::handleServerOperation(socket_t& connSocket) {
|
||||
}
|
||||
}
|
||||
else {
|
||||
tcpip::handleError(tcpip::Protocol::TCP, tcpip::ErrorSources::RECV_CALL);
|
||||
tcpip::handleError(tcpip::Protocol::TCP, tcpip::ErrorSources::RECV_CALL, 300);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -375,3 +387,19 @@ void TcpTmTcServer::handleSocketError(ConstStorageAccessor &accessor) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TcpTmTcServer::setSocketNonBlocking(socket_t &connSocket) {
|
||||
u_long iMode = 1;
|
||||
int iResult = ioctlsocket(connSocket, FIONBIO, &iMode);
|
||||
if(iResult != NO_ERROR) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "TcpTmTcServer::handleServerOperation: Setting socket"
|
||||
" non-blocking failed with error " << iResult;
|
||||
#else
|
||||
sif::printWarning("TcpTmTcServer::handleServerOperation: Setting socket"
|
||||
" non-blocking failed with error %d\n", iResult);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -136,6 +136,9 @@ private:
|
||||
ReturnValue_t handleTmSending(socket_t connSocket, bool& tmSent);
|
||||
ReturnValue_t handleTcRingBufferData(size_t availableReadData);
|
||||
void handleSocketError(ConstStorageAccessor& accessor);
|
||||
#if defined PLATFORM_WIN
|
||||
void setSocketNonBlocking(socket_t& connSocket);
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif /* FSFW_OSAL_COMMON_TCP_TMTC_SERVER_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user