}
-CephContext::CephContext(uint32_t module_type_)
+CephContext::CephContext(uint32_t module_type_, int init_flags_)
: nref(1),
_conf(new md_config_t()),
_log(NULL),
_module_type(module_type_),
+ _init_flags(init_flags_),
_crypto_inited(false),
_service_thread(NULL),
_log_obs(NULL),
return _module_type;
}
+int CephContext::get_init_flags() const
+{
+ return _init_flags;
+}
+
PerfCountersCollection *CephContext::get_perfcounters_collection()
{
return _perf_counters_collection;
*/
class CephContext {
public:
- CephContext(uint32_t module_type_);
+ CephContext(uint32_t module_type_, int init_flags_ = 0);
// ref count!
private:
/* Get the module type (client, mon, osd, mds, etc.) */
uint32_t get_module_type() const;
+ int get_init_flags() const;
+
/* Get the PerfCountersCollection of this CephContext */
PerfCountersCollection *get_perfcounters_collection();
uint32_t _module_type;
+ int _init_flags;
+
bool _crypto_inited;
/* libcommon service thread.
g_code_env = code_env;
// Create a configuration object
- CephContext *cct = new CephContext(iparams.module_type);
+ CephContext *cct = new CephContext(iparams.module_type, flags);
md_config_t *conf = cct->_conf;
// add config observers here
/* Please be sure that this can safely be called multiple times by the
* same application. */
-void common_init_finish(CephContext *cct, int flags)
+void common_init_finish(CephContext *cct)
{
cct->init_crypto();
- if (!(flags & CINIT_FLAG_NO_DAEMON_ACTIONS))
+ if (!(cct->get_init_flags() & CINIT_FLAG_NO_DAEMON_ACTIONS))
cct->start_service_thread();
}
* libraries. The most obvious reason for this is that the threads started by
* the Ceph libraries would be destroyed by a fork().
*/
-void common_init_finish(CephContext *cct, int flags = 0);
+void common_init_finish(CephContext *cct);
#endif
pidfile_remove();
}
-int global_init_prefork(CephContext *cct, int flags)
+int global_init_prefork(CephContext *cct)
{
if (g_code_env != CODE_ENVIRONMENT_DAEMON)
return -1;
return 0;
}
-void global_init_daemonize(CephContext *cct, int flags)
+void global_init_daemonize(CephContext *cct)
{
- if (global_init_prefork(cct, flags) < 0)
+ if (global_init_prefork(cct) < 0)
return;
int ret = daemon(1, 1);
}
global_init_postfork_start(cct);
- global_init_postfork_finish(cct, flags);
+ global_init_postfork_finish(cct);
}
void global_init_postfork_start(CephContext *cct)
pidfile_write(g_conf);
}
-void global_init_postfork_finish(CephContext *cct, int flags)
+void global_init_postfork_finish(CephContext *cct)
{
/* We only close stderr once the caller decides the daemonization
* process is finished. This way we can allow error messages to be
* propagated in a manner that the user is able to see.
*/
- if (!(flags & CINIT_FLAG_NO_CLOSE_STDERR)) {
+ if (!(cct->get_init_flags() & CINIT_FLAG_NO_CLOSE_STDERR)) {
int ret = global_init_shutdown_stderr(cct);
if (ret) {
derr << "global_init_daemonize: global_init_shutdown_stderr failed with "
* to actually forking (via daemon(3)). return 0 if we are going to proceed
* with the fork, or -1 otherwise.
*/
-int global_init_prefork(CephContext *cct, int flags);
+int global_init_prefork(CephContext *cct);
/*
* perform all the steps that global_init_daemonize performs just after
/*
* close stderr, thus completing the postfork.
*/
-void global_init_postfork_finish(CephContext *cct, int flags);
+void global_init_postfork_finish(CephContext *cct);
/*
* Note that this is equivalent to calling _prefork(), daemon(), and
* _postfork.
*/
-void global_init_daemonize(CephContext *cct, int flags);
+void global_init_daemonize(CephContext *cct);
/*
* global_init_chdir changes the process directory.