When I call CURLSMultiMBS.SharedInstance.AddCURL from within the TransferFinished handler of another CURL the CURL is added to the Multi’s queue but not performed, even if I set AutoPerform to True again.
I found two workarounds:
- Set Autoperform to False and then to True again. Not thoroughly tested, but works in at least one case.
- Use Timer.CallLater to call a separate method for dispatching additional CURLs, thus allowing the TransferFinished handler to complete.
If there’s no fundamental reason for the behavior it’d be great to have it fixed in a future update.
Do you reuse the same CURL object?
When you get the event, the CURL object is still in the queue.
And CURL doesn’t let you add the same CURL to the queue again.
With CallLater, you let the method return and remove it from the queue, so you can add it again later.
No, I do not reuse the same CURL object,
I instantiate a CURL to get a directory listing from the server.
In its TransferFinished event I iterate over the listing and instantiate a new CURL for each file in the listing to download it.
I can see that the CURLs have been added by calling SharedInstance.CURLS, but they do not perform until I toggle AutoPerform.
Can you change my “Multi Transfer” sample file to break?
or make a little sample project?
It seems to work as expected when I restructure the example project.
One difference is that the example is using http whereas my app uses SFTP to an S3 bucket.
Another difference is that each CURL being dispatched from my TransferFinished handler has an MTOutputFile, which is not the case in the example.