mirror of
https://github.com/ceph/ceph
synced 2024-12-18 01:16:55 +00:00
ceph_fuse: fix daemonization when pid file is non-empty
During daemonizing ceph-fuse, both the parent and child processes call global_init_postfork_start(). global_init_postfork_start() calls pidfile_write(). If pid file is non-empty, one pidfile_write() call fails because it can't lock the pid file. The fix is only child process calls global_init_postfork_start() Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
This commit is contained in:
parent
0f9c15e32d
commit
64a0e1401f
@ -115,28 +115,32 @@ int main(int argc, const char **argv, const char *envp[]) {
|
||||
cerr << std::endl;
|
||||
}
|
||||
|
||||
global_init_prefork(g_ceph_context);
|
||||
Preforker forker;
|
||||
if (g_conf->daemonize) {
|
||||
global_init_prefork(g_ceph_context);
|
||||
int r;
|
||||
string err;
|
||||
if (forker.prefork(err)) {
|
||||
cerr << "ceph-fuse[" << err << std::endl;
|
||||
return 1;
|
||||
r = forker.prefork(err);
|
||||
if (r < 0 || forker.is_parent()) {
|
||||
// Start log if current process is about to exit. Otherwise, we hit an assert
|
||||
// in the Ceph context destructor.
|
||||
g_ceph_context->_log->start();
|
||||
}
|
||||
if (r < 0) {
|
||||
cerr << "ceph-fuse " << err << std::endl;
|
||||
return r;
|
||||
}
|
||||
if (forker.is_parent()) {
|
||||
r = forker.parent_wait(err);
|
||||
if (r < 0) {
|
||||
cerr << "ceph-fuse " << err << std::endl;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
global_init_postfork_start(cct.get());
|
||||
}
|
||||
|
||||
|
||||
if (forker.is_parent()) {
|
||||
string err;
|
||||
int r = forker.parent_wait(err);
|
||||
if (r) {
|
||||
cerr << "ceph-fuse" << err << std::endl;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
if (forker.is_child()) {
|
||||
{
|
||||
common_init_finish(g_ceph_context);
|
||||
|
||||
//cout << "child, mounting" << std::endl;
|
||||
|
Loading…
Reference in New Issue
Block a user