sherpa is hosted by Hepforge, IPPP Durham
close Warning: Can't synchronize with repository "(default)" (/hepforge/svn/sherpa does not appear to be a Subversion repository.). Look in the Trac log for more information.

Ticket #263: lock_1.patch

File lock_1.patch, 2.3 KB (added by Stefan Hoeche, 10 years ago)
  • ATOOLS/Org/My_File.C

     
    103103#endif
    104104  }
    105105  else {
    106     int res=sqlite3_open(file.c_str(),&db);
     106    int res=0;
     107    if (s_sqlopenflag.length()==0) res=sqlite3_open(file.c_str(),&db);
     108    else res=sqlite3_open_v2(file.c_str(),&db,SQLITE_OPEN_READWRITE|
     109                             SQLITE_OPEN_CREATE,s_sqlopenflag.c_str());
    107110    if (res!=SQLITE_OK) {
    108111      msg_IODebugging()<<METHOD<<"(): '"<<file<<"' returns '"
    109112                       <<sqlite3_errmsg(db)<<"'."<<std::endl;
     
    130133#ifdef USING__MPI
    131134  }
    132135#endif
    133   int res=sqlite3_open(file.c_str(),&db);
     136  int res=0;
     137  if (s_sqlopenflag.length()==0) res=sqlite3_open(file.c_str(),&db);
     138  else res=sqlite3_open_v2(file.c_str(),&db,SQLITE_OPEN_READWRITE,
     139                           s_sqlopenflag.c_str());
    134140  if (res!=SQLITE_OK) {
    135141    msg_IODebugging()<<METHOD<<"(): '"<<file<<"' returns '"
    136142                     <<sqlite3_errmsg(db)<<"'."<<std::endl;
     
    430436  return m_mode;
    431437}
    432438
     439template <class FileType>
     440std::string My_File<FileType>::s_sqlopenflag="";
     441
    433442namespace ATOOLS {
    434443
    435444  template class My_In_File;
  • ATOOLS/Org/My_File.H

     
    4444   
    4545    fom::code m_mode;
    4646
     47    static std::string s_sqlopenflag;
     48
    4749  public:
    4850
    4951    // constructor
     
    7981                       const std::string &cmd);
    8082    static bool CopyInDB(std::string oldfile, std::string newfile);
    8183
     84    inline static void SetSQLOpenFlag(const std::string &flag)
     85    { s_sqlopenflag=flag; }
     86
    8287  };// end of class My_File
    8388
    8489  template<class FileType>
  • ATOOLS/Org/Run_Parameter.C

     
    240240  dr.SetAllowUnits(false);
    241241  s_loader->AddPath(rpa->gen.Variable("SHERPA_RUN_PATH"));
    242242
     243  std::string sqlopenflag=dr.GetValue<std::string>("SQLITE_OPEN_FLAG","");
     244  My_In_File::SetSQLOpenFlag(sqlopenflag);
     245  My_Out_File::SetSQLOpenFlag(sqlopenflag);
    243246  // read only if defined (no error message if not defined)
    244247  long int seed;
    245248  std::vector<long int> seeds;