sv/goose: remove {SVReceiver,GooseReceiver}_addHandleSet() function as it is unsafe to call before {SVReceiver,GooseReceiver}_startThreadless()

The ethernet socket is now returned by {SVReceiver,GooseReceiver}_startThreadless() which allows us to call EthernetHandleSet_addSocket() afterwards.
pull/39/head
Steffen Vogel 8 years ago
parent 9ad2b534f9
commit fa694f1b0d

@ -774,7 +774,7 @@ GooseReceiver_destroy(GooseReceiver self)
/*************************************** /***************************************
* Functions for non-threaded operation * Functions for non-threaded operation
***************************************/ ***************************************/
void EthernetSocket
GooseReceiver_startThreadless(GooseReceiver self) GooseReceiver_startThreadless(GooseReceiver self)
{ {
if (self->interfaceId == NULL) if (self->interfaceId == NULL)
@ -788,6 +788,8 @@ GooseReceiver_startThreadless(GooseReceiver self)
} }
else else
self->running = false; self->running = false;
return self->ethSocket;
} }
void void
@ -811,10 +813,3 @@ GooseReceiver_tick(GooseReceiver self)
else else
return false; return false;
} }
void
GooseReceiver_addHandleSet(GooseReceiver self, EthernetHandleSet handles)
{
return EthernetHandleSet_addSocket(handles, self->ethSocket);
}

@ -30,6 +30,7 @@ extern "C" {
#include <stdbool.h> #include <stdbool.h>
typedef struct sEthernetSocket* EthernetSocket;
/** /**
* \addtogroup goose_api_group * \addtogroup goose_api_group
@ -116,7 +117,7 @@ GooseReceiver_destroy(GooseReceiver self);
/*************************************** /***************************************
* Functions for non-threaded operation * Functions for non-threaded operation
***************************************/ ***************************************/
void EthernetSocket
GooseReceiver_startThreadless(GooseReceiver self); GooseReceiver_startThreadless(GooseReceiver self);
void void
@ -134,20 +135,6 @@ GooseReceiver_stopThreadless(GooseReceiver self);
bool bool
GooseReceiver_tick(GooseReceiver self); GooseReceiver_tick(GooseReceiver self);
/* Forward declaration */
typedef struct sEthernetHandleSet* EthernetHandleSet;
/**
* \brief Add the receiver to a handleset for multiplexed asynchronous IO.
*
* Note: This function must only be called after GooseReceiver_startThreadless().
*
* \param[in] self The SVReceiver instance.
* \param[inout] handles The EthernetHandleSet to which the EthernetSocket of this receiver should be added.
*/
void
GooseReceiver_addHandleSet(GooseReceiver self, EthernetHandleSet handles);
/**@}*/ /**@}*/
#ifdef __cplusplus #ifdef __cplusplus

@ -208,7 +208,7 @@ SVReceiver_destroy(SVReceiver self)
GLOBAL_FREEMEM(self); GLOBAL_FREEMEM(self);
} }
void EthernetSocket
SVReceiver_startThreadless(SVReceiver self) SVReceiver_startThreadless(SVReceiver self)
{ {
if (self->interfaceId == NULL) if (self->interfaceId == NULL)
@ -219,6 +219,8 @@ SVReceiver_startThreadless(SVReceiver self)
Ethernet_setProtocolFilter(self->ethSocket, ETH_P_SV); Ethernet_setProtocolFilter(self->ethSocket, ETH_P_SV);
self->running = true; self->running = true;
return self->ethSocket;
} }
void void
@ -229,12 +231,6 @@ SVReceiver_stopThreadless(SVReceiver self)
self->running = false; self->running = false;
} }
void
SVReceiver_addHandleSet(SVReceiver self, EthernetHandleSet handles)
{
return EthernetHandleSet_addSocket(handles, self->ethSocket);
}
static void static void
parseASDU(SVReceiver self, SVSubscriber subscriber, uint8_t* buffer, int length) parseASDU(SVReceiver self, SVSubscriber subscriber, uint8_t* buffer, int length)
{ {

@ -30,6 +30,8 @@
extern "C" { extern "C" {
#endif #endif
typedef struct sEthernetSocket* EthernetSocket;
/** /**
* \defgroup sv_subscriber_api_group IEC 61850 Sampled Values (SV) subscriber API * \defgroup sv_subscriber_api_group IEC 61850 Sampled Values (SV) subscriber API
* *
@ -204,7 +206,7 @@ SVReceiver_destroy(SVReceiver self);
* Functions for non-threaded operation * Functions for non-threaded operation
***************************************/ ***************************************/
void EthernetSocket
SVReceiver_startThreadless(SVReceiver self); SVReceiver_startThreadless(SVReceiver self);
void void
@ -222,20 +224,6 @@ SVReceiver_stopThreadless(SVReceiver self);
bool bool
SVReceiver_tick(SVReceiver self); SVReceiver_tick(SVReceiver self);
/* Forward declaration */
typedef struct sEthernetHandleSet* EthernetHandleSet;
/**
* \brief Add the receiver to a handleset for multiplexed asynchronous IO.
*
* Note: This function must only be called after SVReceiver_startThreadless().
*
* \param[in] self The SVReceiver instance.
* \param[inout] handles The EthernetHandleSet to which the EthernetSocket of this receiver should be added.
*/
void
SVReceiver_addHandleSet(SVReceiver self, EthernetHandleSet handles);
/* /*
* Subscriber * Subscriber
*/ */

Loading…
Cancel
Save