Fix reloading plugins causing a segfault with forwards
This commit is contained in:
parent
1b93b4736c
commit
a8fab5f749
19
context.cpp
19
context.cpp
@ -2,6 +2,10 @@
|
||||
|
||||
AsyncSocketContext::AsyncSocketContext(IPluginContext* pContext) {
|
||||
this->pContext = pContext;
|
||||
|
||||
connectCallback = forwards->CreateForwardEx(NULL, ET_Single, 1, NULL, Param_Cell);
|
||||
errorCallback = forwards->CreateForwardEx(NULL, ET_Single, 3, NULL, Param_Cell, Param_Cell, Param_String);
|
||||
dataCallback = forwards->CreateForwardEx(NULL, ET_Single, 3, NULL, Param_Cell, Param_String, Param_Cell);
|
||||
}
|
||||
|
||||
AsyncSocketContext::~AsyncSocketContext() {
|
||||
@ -58,28 +62,13 @@ void AsyncSocketContext::OnData(char* data, ssize_t size) {
|
||||
}
|
||||
|
||||
bool AsyncSocketContext::SetConnectCallback(funcid_t function) {
|
||||
if (connectCallback) {
|
||||
forwards->ReleaseForward(connectCallback);
|
||||
}
|
||||
|
||||
connectCallback = forwards->CreateForwardEx(NULL, ET_Single, 1, NULL, Param_Cell);
|
||||
return connectCallback->AddFunction(pContext, function);
|
||||
}
|
||||
|
||||
bool AsyncSocketContext::SetErrorCallback(funcid_t function) {
|
||||
if (connectCallback) {
|
||||
forwards->ReleaseForward(errorCallback);
|
||||
}
|
||||
|
||||
errorCallback = forwards->CreateForwardEx(NULL, ET_Single, 3, NULL, Param_Cell, Param_Cell, Param_String);
|
||||
return errorCallback->AddFunction(pContext, function);
|
||||
}
|
||||
|
||||
bool AsyncSocketContext::SetDataCallback(funcid_t function) {
|
||||
if (dataCallback) {
|
||||
forwards->ReleaseForward(dataCallback);
|
||||
}
|
||||
|
||||
dataCallback = forwards->CreateForwardEx(NULL, ET_Single, 3, NULL, Param_Cell, Param_String, Param_Cell);
|
||||
return dataCallback->AddFunction(pContext, function);
|
||||
}
|
@ -72,7 +72,7 @@ AsyncSocketContext* AsyncSocket::GetSocketInstanceByHandle(Handle_t handle) {
|
||||
void AsyncSocket::OnHandleDestroy(HandleType_t type, void *object) {
|
||||
if(object != NULL) {
|
||||
AsyncSocketContext *ctx = (AsyncSocketContext *) object;
|
||||
|
||||
UV_EOF;
|
||||
delete ctx;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user