Page 1 of 1

Timing problem

Posted: Tue Aug 29, 2023 10:11 am
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.

Re: Timing problem

Posted: Tue Aug 29, 2023 11:01 am
by stefan@tageson.se
What about a simple delay - say 5 seconds - between the calls?

Re: Timing problem

Posted: Tue Aug 29, 2023 11:44 am
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 ;)

Re: Timing problem

Posted: Thu Aug 31, 2023 10:13 am
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

Re: Timing problem

Posted: Wed Sep 06, 2023 4:57 pm
by Scott Klement
I can't see why the file would still be open. Please show us how to reproduce the problem.