Skip to content

Commit

Permalink
EBP-383: Go API throws panic error on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
oodigie committed Dec 10, 2024
1 parent b633bee commit 02d7640
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 9 deletions.
17 changes: 8 additions & 9 deletions internal/ccsmp/ccsmp_core.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,10 @@ func SolClientInitialize(props []string) *SolClientErrorInfoWrapper {
func SolClientContextCreate() (context *SolClientContext, err *SolClientErrorInfoWrapper) {
var contextP SolClientContextPt
solClientErrorInfo := handleCcsmpError(func() SolClientReturnCode {
var contextFuncInfo C.solClient_context_createFuncInfo_t
return C.solClient_context_create(C.SOLCLIENT_CONTEXT_PROPS_DEFAULT_WITH_CREATE_THREAD, &contextP, &contextFuncInfo, 24)
// creates context with default properties
return C.SessionContextCreate(C.SOLCLIENT_CONTEXT_PROPS_DEFAULT_WITH_CREATE_THREAD, &contextP)
})

if solClientErrorInfo != nil {
return nil, solClientErrorInfo
}
Expand All @@ -322,15 +323,13 @@ func (context *SolClientContext) SolClientSessionCreate(properties []string) (se
sessionPropsP, sessionPropertiesFreeFunction := ToCArray(properties, true)
defer sessionPropertiesFreeFunction()

var sessionFuncInfo C.solClient_session_createFuncInfo_t
sessionFuncInfo.rxMsgInfo.callback_p = (C.solClient_session_rxMsgCallbackFunc_t)(unsafe.Pointer(C.defaultMessageReceiveCallback))
sessionFuncInfo.rxMsgInfo.user_p = nil
sessionFuncInfo.eventInfo.callback_p = (C.solClient_session_eventCallbackFunc_t)(unsafe.Pointer(C.eventCallback))
sessionFuncInfo.eventInfo.user_p = nil

solClientErrorInfo := handleCcsmpError(func() SolClientReturnCode {
return C.solClient_session_create(sessionPropsP, context.pointer, &sessionP, &sessionFuncInfo, (C.size_t)(unsafe.Sizeof(sessionFuncInfo)))
// this will create a session and put the session pointer in sessionP
return C.SessionCreate(sessionPropsP,
context.pointer,
&sessionP)
})

if solClientErrorInfo != nil {
return nil, solClientErrorInfo
}
Expand Down
36 changes: 36 additions & 0 deletions internal/ccsmp/ccsmp_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,17 @@
solClient_rxMsgCallback_returnCode_t
messageReceiveCallback(solClient_opaqueSession_pt opaqueSession_p, solClient_opaqueMsg_pt msg_p, void *user_p);

solClient_rxMsgCallback_returnCode_t
defaultMessageReceiveCallback(solClient_opaqueSession_pt opaqueSession_p, solClient_opaqueMsg_pt msg_p, void *user_p);

solClient_rxMsgCallback_returnCode_t
requestResponseReplyMessageReceiveCallback(solClient_opaqueSession_pt opaqueSession_p, solClient_opaqueMsg_pt msg_p, void *user_p);

solClient_rxMsgCallback_returnCode_t
flowMessageReceiveCallback(solClient_opaqueFlow_pt opaqueFlow_p, solClient_opaqueMsg_pt msg_p, void *user_p);

void eventCallback(solClient_opaqueSession_pt opaqueSession_p, solClient_session_eventCallbackInfo_pt eventInfo_p, void *user_p);

void flowEventCallback(solClient_opaqueFlow_pt opaqueFlow_p, solClient_flow_eventCallbackInfo_pt eventInfo_p, void *user_p);

solClient_returnCode_t
Expand All @@ -53,6 +58,37 @@ solClientgo_msg_isRequestReponseMsg(solClient_opaqueMsg_pt msg_p, char **correla
return SOLCLIENT_OK;
}

solClient_returnCode_t
SessionCreate( solClient_propertyArray_pt sessionPropsP,
solClient_opaqueContext_pt contextP,
solClient_opaqueSession_pt *opaqueSession_p)
{
/* allocate the session create struct */
solClient_session_createFuncInfo_t sessionCreateFuncInfo;
sessionCreateFuncInfo.rxMsgInfo.callback_p = (solClient_session_rxMsgCallbackFunc_t)defaultMessageReceiveCallback;
sessionCreateFuncInfo.rxMsgInfo.user_p = NULL;
sessionCreateFuncInfo.eventInfo.callback_p = (solClient_session_eventCallbackFunc_t)eventCallback;
sessionCreateFuncInfo.eventInfo.user_p = NULL;

sessionCreateFuncInfo.rxMsgInfo.callback_p = flowMessageReceiveCallback;
sessionCreateFuncInfo.eventInfo.callback_p = (solClient_flow_eventCallbackFunc_t)flowEventCallback;

return solClient_session_create(sessionPropsP, contextP, opaqueSession_p, &sessionCreateFuncInfo, sizeof(sessionCreateFuncInfo));
}

solClient_returnCode_t
SessionContextCreate( solClient_propertyArray_pt contextPropsP,
solClient_opaqueContext_pt *contextP)
{
/* allocate the session context create struct to NULL */
solClient_context_createFuncInfo_t contextCreateFuncInfo;
contextCreateFuncInfo.regFdInfo.regFdFunc_p = NULL;
contextCreateFuncInfo.regFdInfo.unregFdFunc_p = NULL;
contextCreateFuncInfo.regFdInfo.user_p = NULL;

return solClient_context_create(contextPropsP, &contextP, &contextCreateFuncInfo, sizeof(contextCreateFuncInfo));
}

solClient_returnCode_t
SessionFlowCreate( solClient_opaqueSession_pt opaqueSession_p,
solClient_propertyArray_pt flowPropsP,
Expand Down
9 changes: 9 additions & 0 deletions internal/ccsmp/ccsmp_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ typedef struct solClient_errorInfo_wrapper
* operating systems are supported, this may need to change to a more complex
* definition.
*/
solClient_returnCode_t SessionCreate(
solClient_propertyArray_pt sessionPropsP,
solClient_opaqueContext_pt contextP,
solClient_opaqueSession_pt *opaqueSession_p);

solClient_returnCode_t SessionContextCreate(
solClient_propertyArray_pt contextPropsP,
solClient_opaqueContext_pt *contextP);

solClient_returnCode_t SessionFlowCreate(
solClient_opaqueSession_pt opaqueSession_p,
solClient_propertyArray_pt flowPropsP,
Expand Down

0 comments on commit 02d7640

Please sign in to comment.