Skip to content

Commit

Permalink
1.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikMinekus committed Aug 31, 2017
1 parent 5886a45 commit 8b421f2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
6 changes: 5 additions & 1 deletion curlapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ struct curl_slist *HTTPClient::BuildHeaders(struct HTTPRequest request)
void HTTPClient::Request(struct HTTPRequest request, IPluginFunction *function, cell_t value)
{
IChangeableForward *forward = forwards->CreateForwardEx(NULL, ET_Ignore, 2, NULL, Param_Cell, Param_Cell);
forward->AddFunction(function);
if (forward == NULL || !forward->AddFunction(function))
{
smutils->LogError(myself, "Could not create forward.");
return;
}

HTTPRequestThread *thread = new HTTPRequestThread(this, request, forward, value);
threader->MakeThread(thread);
Expand Down
5 changes: 4 additions & 1 deletion curlthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ void HTTPRequestThread::RunThread(IThreadHandle *pHandle)
CURL *curl = curl_easy_init();
if (curl == NULL)
{
smutils->LogError(myself, "Could not create cURL handle.");
forwards->ReleaseForward(this->forward);

smutils->LogError(myself, "Could not initialize cURL session.");
return;
}

Expand Down Expand Up @@ -108,6 +110,7 @@ void HTTPRequestThread::RunThread(IThreadHandle *pHandle)
curl_easy_cleanup(curl);
curl_slist_free_all(headers);
free(this->request.body);
forwards->ReleaseForward(this->forward);

smutils->LogError(myself, "HTTP request failed: %s", error);
return;
Expand Down
3 changes: 3 additions & 0 deletions extension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ void RipExt::RunFrame()
/* Return early if the plugin was unloaded while the thread was running */
if (forward->GetFunctionCount() == 0)
{
forwards->ReleaseForward(forward);
this->callbackMutex->Unlock();

return;
Expand All @@ -123,6 +124,7 @@ void RipExt::RunFrame()
Handle_t hndlResponse = handlesys->CreateHandleEx(htHTTPResponseObject, &response, &sec, NULL, NULL);
if (hndlResponse == BAD_HANDLE)
{
forwards->ReleaseForward(forward);
this->callbackMutex->Unlock();

smutils->LogError(myself, "Could not create HTTP response handle.");
Expand All @@ -136,6 +138,7 @@ void RipExt::RunFrame()
handlesys->FreeHandle(hndlResponse, &sec);
handlesys->FreeHandle(response.hndlData, &sec);

forwards->ReleaseForward(forward);
this->callbackMutex->Unlock();
}

Expand Down
2 changes: 1 addition & 1 deletion smsdk_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
/* Basic information exposed publicly */
#define SMEXT_CONF_NAME "REST in Pawn"
#define SMEXT_CONF_DESCRIPTION "Provides HTTP and JSON natives for plugins"
#define SMEXT_CONF_VERSION "1.0.2"
#define SMEXT_CONF_VERSION "1.0.3"
#define SMEXT_CONF_AUTHOR "Tsunami"
#define SMEXT_CONF_URL "http://www.tsunami-productions.nl"
#define SMEXT_CONF_LOGTAG "RIPEXT"
Expand Down

0 comments on commit 8b421f2

Please sign in to comment.