Skip to content

Commit

Permalink
fix(el): Only allow sockets to be opened if the ConnectionManager is …
Browse files Browse the repository at this point in the history
…running
  • Loading branch information
jpfr committed Jul 11, 2022
1 parent 3f36bb9 commit 4d63fd7
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions arch/eventloop_posix_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -904,17 +904,26 @@ TCP_openConnection(UA_ConnectionManager *cm,
size_t paramsSize, const UA_KeyValuePair *params,
void *application, void *context,
UA_ConnectionManager_connectionCallback connectionCallback) {
UA_EventLoopPOSIX *el = (UA_EventLoopPOSIX*)cm->eventSource.eventLoop;
if(cm->eventSource.state != UA_EVENTSOURCESTATE_STARTED) {
UA_LOG_ERROR(el->eventLoop.logger, UA_LOGCATEGORY_NETWORK,
"TCP\t| Cannot open a connection for a "
"ConnectionManager that is not started");
return UA_STATUSCODE_BADINTERNALERROR;
}

/* If the "port"-parameter is defined, then try to open an active
* connection. Otherwise try to open a socket that listens for incoming TCP
* connections. */
const UA_Variant *val = UA_KeyValueMap_get(params, paramsSize,
UA_QUALIFIEDNAME(0, "port"));
if(val)
const UA_Variant *val =
UA_KeyValueMap_get(params, paramsSize, UA_QUALIFIEDNAME(0, "port"));
if(val) {
return TCP_openActiveConnection(cm, paramsSize, params,
application, context, connectionCallback);
else
} else {
return TCP_openPassiveConnection(cm, paramsSize, params,
application, context, connectionCallback);
}
}

static UA_StatusCode
Expand Down

0 comments on commit 4d63fd7

Please sign in to comment.