Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   ofstream (standard C++ file output) not working (http://www.chiefdelphi.com/forums/showthread.php?t=79548)

slavik262 04-02-2010 10:54

Re: ofstream (standard C++ file output) not working
 
Right, so if it is called before fopen() in the same thread, why would there be a race condition?

I think we're having some kind of communication disconnect. Sorry.

jhersh 04-02-2010 13:08

Re: ofstream (standard C++ file output) not working
 
Quote:

Originally Posted by slavik262 (Post 913216)
Right, so if it is called before fopen() in the same thread, why would there be a race condition?

You would not. The situation described above (or how I read it anyway) was that you were not calling Priv_SetWriteFileAllowed, and that it sometimes worked. I was suggesting that there are other tasks that may be calling it that would allow the write to work sometimes and not others.

If what you are saying is that you are calling it in the same task before the fopen and it still only works some of the time, then I don't have a good theory for you. Let me know if this is the case and I'll try to look into it a bit more.

-Joe

byteit101 04-02-2010 15:20

Re: ofstream (standard C++ file output) not working
 
A race condition would make sense, originally, I had the write in the simple template constructor, later i put it in the auto. I will test out the race condition today. My plan:
write to file in entry point function before anything else
write to file in robot constructor
write to file in robot auto after 10 second wait

they will be tested 10 times without priv_set..., and 10 times with priv_set...
I will report back later

byteit101 04-02-2010 19:09

Re: ofstream (standard C++ file output) not working
 
Hmm, I am not seeing any blocked attempts to write; Every test was successful, without the priv_set... Sometimes it took up to 10 seconds to find it over FTP, but every test was successful

jhersh 04-02-2010 19:12

Re: ofstream (standard C++ file output) not working
 
Quote:

Originally Posted by byteit101 (Post 913534)
Sometimes it took up to 10 seconds to find it over FTP, but every test was successful

Make sure your FTP client is not caching the directory listing. What client are you using?

byteit101 05-02-2010 06:29

Re: ofstream (standard C++ file output) not working
 
Quote:

Originally Posted by jhersh (Post 913539)
Make sure your FTP client is not caching the directory listing. What client are you using?

FileZilla

jhersh 05-02-2010 15:40

Re: ofstream (standard C++ file output) not working
 
Quote:

Originally Posted by byteit101 (Post 913814)
FileZilla

Hmm... should be fine as long as you refresh and are connected. Have you tried putting prints to go along with your writes to get some idea of when the write happened vs. when you see the file on the FTP server?

byteit101 05-02-2010 15:49

Re: ofstream (standard C++ file output) not working
 
no, but I think it might be the code is slow (I only immediatly looked at the folder for a few test), you hit Run kernel task and it downloads, (I was measuring from that point), it calls the entry point function, and inits everything before creating the file

davidalln 05-02-2010 18:27

Re: ofstream (standard C++ file output) not working
 
We finally got our log working consistently (although not as sophisticated as 3132's Logger, it's a foundation in which stuff can be added on). It looks like the race condition problems listed above were the culprit. The key is not to completely overwhelm it with added lines in the main loop.

We have wrapped it in a class if anyone's interested: http://gist.github.com/296373


All times are GMT -5. The time now is 12:31.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi