<div dir="ltr">I have a dialplan setup that records a bridged call in FreeSWITCH, which sets the 'api_hangup_hook' variable to call a lua script when the call hangs up, and the called lua script moves the recorded .wav file from it's temporary location to a final destination.<div><br></div><div>This works, but recently I noticed that some of my .wav recordings have no header information, which results in many players choking when trying to play it.</div><div><br></div><div>I eventually figured out that the header information for the .wav file appears to be written *after* the call is hung up, and file move operation in the api_hangup_hook moves the file before the header information has been written. This occurs sporadically.</div><div><br></div><div>I've found that introducing a 1 second sleep in my lua script fixes this race condition, but that seems a bit of an ugly hack.</div><div><br></div><div>Curious if anybody else has run into this, and/or can offer me a cleaner solution than my sleep hack.</div><div><br></div><div>I'm attaching a brief summary of the dialplan and lua script for anyone that wants to see the code.</div></div>