~ubuntu-branches/ubuntu/raring/firebird2.5/raring-proposed

« back to all changes in this revision

Viewing changes to src/common/config/config_file.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Damyan Ivanov
  • Date: 2011-09-24 14:12:19 UTC
  • mfrom: (15.1.8 sid)
  • Revision ID: james.westby@ubuntu.com-20110924141219-pkxk7486f3d8ut9f
Tags: 2.5.1.26349-0~rc1.ds4-5
* Medium urgency for fixing a serious bug in testing

* Import a patch from upstream SVN fixing problems in poll() usage when
  process receives signals like SIGALRM.
  Closes: #642555 -- segfault in the remote interface when using alarm() in
  the client program

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
// in applications. That's why for regular SERVER builds
37
37
// it's better to exit with appropriate diags rather continue
38
38
// with missing / wrong configuration.
39
 
#if (! defined(BOOT_BUILD)) && (! defined(EMBEDDED)) && (! defined(SUPERCLIENT))
40
 
#define EXCEPTION_ON_NO_CONF
41
 
#else
42
 
#undef EXCEPTION_ON_NO_CONF
43
 
#endif
44
39
 
45
40
// config_file works with OS case-sensitivity
46
41
typedef Firebird::PathName string;
208
203
 
209
204
        Firebird::AutoPtr<FILE, Firebird::FileClose> ifile(fopen(configFile.c_str(), "rt"));
210
205
 
211
 
#ifdef EXCEPTION_ON_NO_CONF
212
206
        int BadLinesCount = 0;
213
 
#endif
214
207
        if (!ifile)
215
208
        {
216
209
                // config file does not exist
217
 
#ifdef EXCEPTION_ON_NO_CONF
218
 
                if (fExceptionOnError)
219
 
                {
220
 
                        const Firebird::string msg =
221
 
                                "Missing configuration file: " + configFile.ToString() + ", exiting";
222
 
                        Firebird::Syslog::Record(Firebird::Syslog::Error, msg.c_str());
223
 
                        Firebird::fatal_exception::raise(msg.c_str());
224
 
                }
225
 
#endif //EXCEPTION_ON_NO_CONF
 
210
                lastMessage = "Missing configuration file: ";
 
211
                lastMessage += configFile;
226
212
                return;
227
213
        }
228
214
        string inputLine;
243
229
                {
244
230
                        const Firebird::string msg =
245
231
                                (configFile + ": illegal line \"" + inputLine + "\"").ToString();
246
 
                        Firebird::Syslog::Record(fExceptionOnError ?
247
 
                                                                                Firebird::Syslog::Error : Firebird::Syslog::Warning,
248
 
                                                                        msg.c_str());
249
 
#ifdef EXCEPTION_ON_NO_CONF
 
232
                        Firebird::Syslog::Record(Firebird::Syslog::Warning, msg.c_str());
250
233
                        BadLinesCount++;
251
 
#endif
252
234
                        continue;
253
235
                }
254
236
 
261
243
 
262
244
                parameters.add(Parameter(getPool(), key, value));
263
245
        }
264
 
#ifdef EXCEPTION_ON_NO_CONF
265
 
        if (BadLinesCount && fExceptionOnError)
 
246
        if (BadLinesCount)
266
247
        {
267
 
                Firebird::fatal_exception::raise("Bad lines in firebird.conf");
 
248
                lastMessage.printf("%d bad lines in %s", BadLinesCount, configFile.c_str());
268
249
        }
269
 
#endif
270
 
}
271
 
 
272
 
 
 
250
}
 
251
 
 
252
/******************************************************************************
 
253
 *
 
254
 *      Check for parse/load error
 
255
 */
 
256
 
 
257
const char* ConfigFile::getMessage()
 
258
{
 
259
        return lastMessage.nullStr();
 
260
}