Subject: | id3v2 TMPXX temp file problem when multi=threaded |
First off, thanks for a great perl package!
I'm having a problem when using mp3::tag and threads. It might be a race
condition when simultaneously changing tags for multiple files in the
same directory.
Here's what I'm trying to do. My program transcodes a large number of
mp3 files using lame to a lower bitrate so I can fit a lot of them onto
my PSP. [playstation portable]. Since lame doesn't copy my mp3 headers,
I'm using mp3:tag to do it.
The single threaded operation takes ~4 hours. Since I have a quad core
processor, I rewrote it to use perl threads using perl 5.10. The speedup
is almost linear, and the 4 hour operation now takes a little over an
hour with 4 threads. I can't wait for the 16-core processors. :)
90% of the time everything goes as expected. It seems at random I get
one of these errors and the temp file is left in the directory:
'mv' is not recognized as an internal or external command,
operable program or batch file.
Couldn't rename temporary file s:/psp/music/28. Rock, soft/TMPxx0.tmp to
s:/psp/music/28. Rock, soft/021. Tender Is The Night.mp3
I'm using v0.9710, and found code inside ID3v2.pm that sets a basename
for the tempfile, then increases a counter to find an available, non
existent tempfile. It seems to me that 2 threads could find a temp
filename available and then try to create it at the same time. I tried
to fix it by making the tempfile based on the original filename:
my $tempfile = dirname($mp3obj->{filename}) . "/TMPxx";
my $tempfile = $mp3obj->{filename} . "_TMPxx";
Unfortunately, this didn't seem to fix it. Again, it works 90% of the
time, but the odd, random 10% cases still yield a similar error.
Thanks for your help & please let me know if you think of something I
can try or if you think I'm doing something wrong.