Fix reloading causing a segfault
This commit is contained in:
parent
a8fab5f749
commit
13082d892d
21
context.cpp
21
context.cpp
@ -3,9 +3,9 @@
|
||||
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);
|
||||
connectCallback = NULL;
|
||||
errorCallback = NULL;
|
||||
dataCallback = NULL;
|
||||
}
|
||||
|
||||
AsyncSocketContext::~AsyncSocketContext() {
|
||||
@ -62,13 +62,28 @@ 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