Timing problem

Discussions related to HTTPAPI (An HTTP Client Package for RPG programming.) http://www.scottklement.com/httpapi/
Post Reply
Annemiek
Posts: 7
Joined: Tue Aug 29, 2023 9:52 am

Timing problem

Post by Annemiek »

Hi Everybody,
Thanks for having me here!

At the moment I'm working on a project to handle files at a remote location using API's. Of course I'm using HTTPAPI (version 1.38).

One of the functions I need to build is a COPY-function, to duplicate a file at the remote location. Unfortunately they only offer a GET- and a PUT-API.
So what I do is first download the file to our local machine, using http_stmf(). This works like a dream. The next step is to upload the same file again, using http_url_post_stmf(). Technically this works fine again, but when I execute both calls in a program directly after another, I run into a timing problem: by the time I'm executing the second API, the file I downloaded to the IFS is still open and it fails to get added to the second call. (To add it to the second call I use http_mfd_encoder_addstmf() btw).

What actions do you recommend to fix this?
Yes, I know I should upgrade HTTPAPI to a more recent version, but that is out of my control alas. Is there perhaps a IFS-API I could use to check the open state of the file I downloaded?

Thanks again,
Annemiek.
stefan@tageson.se
Posts: 12
Joined: Wed Jul 28, 2021 7:55 am
Location: Viken, Sweden
Contact:

Re: Timing problem

Post by stefan@tageson.se »

What about a simple delay - say 5 seconds - between the calls?
Annemiek
Posts: 7
Joined: Tue Aug 29, 2023 9:52 am

Re: Timing problem

Post by Annemiek »

stefan@tageson.se wrote: Tue Aug 29, 2023 11:01 am What about a simple delay - say 5 seconds - between the calls?
I guess I could do, in combination with checking the result of the http_mfd_encoder_addstmf API, but I was hoping for a more "modern" option ;)
peder udesen
Posts: 15
Joined: Thu Jul 29, 2021 8:00 am

Re: Timing problem

Post by peder udesen »

If I understand you correct then it is the file in the IFS on your local machine that is not closed.

Many years ago I had the same problem.
I made a small program that tried to open the IFS file exclusively with the flags
flags = O_RDONLY + O_SHARE_NONE;

The program was called with the parameters
1) IFS filename
2) number of seconds between retries
3) number of times to retry

If the open returned the error code 3029 = Resource busy
then it waited the number of seconds before trying again

If another error code was received leave the program.

If number of retries was exceded then it send an escape message to the calling program

If the open succeded then remember to close it again :D
Scott Klement
Site Admin
Posts: 658
Joined: Sun Jul 04, 2021 5:12 am

Re: Timing problem

Post by Scott Klement »

I can't see why the file would still be open. Please show us how to reproduce the problem.
Post Reply