Skip to content

Commit

Permalink
Fix dynamic callback on HL (resolves issues in cURL)
Browse files Browse the repository at this point in the history
  • Loading branch information
jgranick committed Jan 4, 2024
1 parent 8e54e6d commit 9b9faae
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 7 additions & 4 deletions project/src/net/curl/CURLBindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,8 @@ namespace lime {
pos->v.i = position;

curl_gc_mutex.Unlock ();
length = *((int*)writeCallback->Call (bytes, pos));
vdynamic* _length = (vdynamic*)writeCallback->Call (bytes, pos);
length = (_length != NULL ? _length->v.i : 0);
curl_gc_mutex.Lock ();

if (length == CURL_WRITEFUNC_PAUSE) {
Expand Down Expand Up @@ -749,7 +750,8 @@ namespace lime {
ulnow->v.d = progress->ulnow;

curl_gc_mutex.Unlock ();
code = *((int*)progressCallback->Call (dltotal, dlnow, ultotal, ulnow));
vdynamic* _code = (vdynamic*)progressCallback->Call (dltotal, dlnow, ultotal, ulnow);
code = (_code != NULL ? _code->v.i : 0);
curl_gc_mutex.Lock ();

if (code != 0) { // CURLE_OK
Expand All @@ -776,7 +778,8 @@ namespace lime {
ulnow->v.i = xferInfo->ulnow;

curl_gc_mutex.Unlock ();
code = *((int*)xferInfoCallback->Call (dltotal, dlnow, ultotal, ulnow));
vdynamic* _code = (vdynamic*)xferInfoCallback->Call (dltotal, dlnow, ultotal, ulnow);
code = (_code != NULL ? _code->v.i : 0);
curl_gc_mutex.Lock ();

if (code != 0) {
Expand Down Expand Up @@ -1706,7 +1709,7 @@ namespace lime {

}

progressCallbacks[handle] = new ValuePointer (parameter);;
progressCallbacks[handle] = new ValuePointer (parameter);
progressValues[handle] = new CURL_Progress ();

code = curl_easy_setopt (easy_handle, type, progress_callback);
Expand Down
4 changes: 3 additions & 1 deletion src/lime/_internal/backend/native/NativeHTTPRequest.hx
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ class NativeHTTPRequest
}
}

private function curl_onProgress(curl:CURL, dltotal:Float, dlnow:Float, uptotal:Float, upnow:Float):Void
private function curl_onProgress(curl:CURL, dltotal:Float, dlnow:Float, uptotal:Float, upnow:Float):Int
{
if (upnow > writeBytesLoaded || dlnow > writeBytesLoaded || uptotal > writeBytesTotal || dltotal > writeBytesTotal)
{
Expand All @@ -389,6 +389,8 @@ class NativeHTTPRequest
// Wrong thread
// promise.progress (bytesLoaded, bytesTotal);
}

return 0;
}

private function curl_onWrite(curl:CURL, output:Bytes):Int
Expand Down

0 comments on commit 9b9faae

Please sign in to comment.