ConnectionFT601: add handle check to send functions
also return true in wait functions if handle is invalid or not used
as there is nothing to wait for
@@ -465,7 +465,7 @@ int ConnectionFT601::BeginDataReading(char *buffer, uint32_t length, int ep)
@brief Waits for asynchronous data reception
@param contextHandle handle of which context data to wait
@param timeout_ms number of miliseconds to wait
-@return 1-data received, 0-data not received
+@return true - wait finished, false - still waiting for transfer to complete
*/
bool ConnectionFT601::WaitForReading(int contextHandle, unsigned int timeout_ms)
{
@@ -489,7 +489,7 @@ bool ConnectionFT601::WaitForReading(int contextHandle, unsigned int timeout_ms)
return contexts[contextHandle].done.load() == true;
#endif
}
- return 0;
+ return true; //there is nothing to wait for (signal wait finished)
}
/**
@@ -610,11 +610,11 @@ int ConnectionFT601::BeginDataSending(const char *buffer, uint32_t length, int e
@brief Waits for asynchronous data sending
@param contextHandle handle of which context data to wait
@param timeout_ms number of miliseconds to wait
-@return 1-data received, 0-data not received
+@return true - wait finished, false - still waiting for transfer to complete
*/
bool ConnectionFT601::WaitForSending(int contextHandle, unsigned int timeout_ms)
{
- if(contextsToSend[contextHandle].used == true)
+ if(contextHandle >= 0 && contextsToSend[contextHandle].used == true)
{
#ifndef __unix__
DWORD dwRet = WaitForSingleObject(contextsToSend[contextHandle].inOvLap.hEvent, timeout_ms);
@@ -633,7 +633,7 @@ bool ConnectionFT601::WaitForSending(int contextHandle, unsigned int timeout_ms)
return contextsToSend[contextHandle].done == true;
#endif
}
- return 0;
+ return true; //there is nothing to wait for (signal wait finished)
}
/**
@@ -645,7 +645,7 @@ bool ConnectionFT601::WaitForSending(int contextHandle, unsigned int timeout_ms)
*/
int ConnectionFT601::FinishDataSending(const char *buffer, uint32_t length, int contextHandle)
{
- if(contextsToSend[contextHandle].used == true)
+ if(contextHandle >= 0 && contextsToSend[contextHandle].used == true)
{
#ifndef __unix__
ULONG ulActualBytesTransferred ;
