projects
/
phys
/
latlib.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
594f56b
)
Opening cachefiles exclusively with O_EXCL.
author
Alexander Schmidt
<alex@treefish.org>
Thu, 13 Feb 2014 20:11:00 +0000
(21:11 +0100)
committer
Alexander Schmidt
<alex@treefish.org>
Thu, 13 Feb 2014 20:11:00 +0000
(21:11 +0100)
configcache.cpp
patch
|
blob
|
history
diff --git
a/configcache.cpp
b/configcache.cpp
index 34789ee71b4dbdf0ef1af5b9aa4451567c346908..5987789104e623233abefc0337888b390dc96b6c 100644
(file)
--- a/
configcache.cpp
+++ b/
configcache.cpp
@@
-4,6
+4,9
@@
#include <iostream>
#include <time.h>
#include <dirent.h>
#include <iostream>
#include <time.h>
#include <dirent.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <fcntl.h>
#include <boost/iostreams/filtering_streambuf.hpp>
#include <boost/iostreams/stream.hpp>
#include <boost/iostreams/filtering_streambuf.hpp>
#include <boost/iostreams/stream.hpp>
@@
-274,10
+277,26
@@
void configcache::readConfig(bool *readnewconfig, int *nequileft, vector<unsigne
void configcache::openOutFile(int actnequi)
{
time_t secstamp = time(NULL);
void configcache::openOutFile(int actnequi)
{
time_t secstamp = time(NULL);
+ int iseq=0;
+
+ while (true) {
+ outFileName.str("");
+ outFileName << DATADIR << "/" << secstamp << "." << iseq << "_" << getFileId(actnequi) << "_.edat.tmp";
+
+ int tmpfd = open(outFileName.str().c_str(), O_CREAT | O_EXCL, 0644);
- outFileName.str("");
- outFileName << DATADIR << "/" << secstamp << "_" << getFileId(actnequi) << "_.edat.tmp";
+ if ( tmpfd != -1 ) {
+ close(tmpfd);
+ break;
+ }
+ else if ( errno != EEXIST ) {
+ if(log) *log << "CCACHE: Could not create cachefile!" << endl << flush;
+ exit(1);
+ }
+ iseq++;
+ }
+
outFile.open( outFileName.str().c_str(), std::ios::binary );
ioBuffers->out = new boost::iostreams::filtering_ostreambuf;
outFile.open( outFileName.str().c_str(), std::ios::binary );
ioBuffers->out = new boost::iostreams::filtering_ostreambuf;