Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

Commit

Permalink
fix file mode settings in linux
Browse files Browse the repository at this point in the history
  • Loading branch information
0xfdi committed May 14, 2015
1 parent 1491463 commit c734650
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/apps/replication/lib/mutation_log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ std::map<int, log_file_ptr>& mutation_log::get_logfiles_for_test()
char path[512];
sprintf (path, "%s/log.%u.%lld", dir, index, static_cast<long long int>(startOffset));

handle_t hFile = dsn::service::file::open(path, O_RDWR | O_CREAT, 0);
handle_t hFile = dsn::service::file::open(path, O_RDWR | O_CREAT, 0666);
if (hFile == 0)
{
dwarn("create log %s failed", path);
Expand Down
22 changes: 10 additions & 12 deletions src/apps/replication/meta_server/meta_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ meta_service::meta_service(server_state* state)
{
_balancer = nullptr;
_failure_detector = nullptr;
_log = nullptr;
_log = static_cast<handle_t>(0);
_offset = 0;
_data_dir = ".";
_started = false;

_opts.initialize(system::config());
}
Expand Down Expand Up @@ -81,7 +82,7 @@ void meta_service::start(const char* data_dir, bool clean_state)
}
}

_log = file::open((_data_dir + "/oplog").c_str(), O_RDWR | O_CREAT, 0);
_log = file::open((_data_dir + "/oplog").c_str(), O_RDWR | O_CREAT, 0666);

_balancer = new load_balancer(_state);
_failure_detector = new meta_server_failure_detector(_state);
Expand All @@ -93,15 +94,6 @@ void meta_service::start(const char* data_dir, bool clean_state)
if (_state->get_meta_server_primary(primary) && primary == primary_address())
{
_failure_detector->set_primary(true);

node_states nodes;
_state->get_node_state(nodes);

for (auto& n : nodes)
{
dassert(n.second, "");
_failure_detector->register_worker(n.first);
}
}
else
_failure_detector->set_primary(false);
Expand All @@ -114,10 +106,14 @@ void meta_service::start(const char* data_dir, bool clean_state)
_opts.fd_grace_seconds,
false
);

_started = true;
}

bool meta_service::stop()
{
if (!_started) return false;
_started = false;
_failure_detector->stop();
delete _failure_detector;
_failure_detector = nullptr;
Expand Down Expand Up @@ -198,6 +194,7 @@ void meta_service::query_configuration_by_index(configuration_query_by_index_req
void meta_service::replay_log(const char* log)
{
FILE* fp = ::fopen(log, "rb");
dassert (fp != nullptr, "open operation log %s failed, err = %d", log, errno);

char buffer[4096]; // enough for holding configuration_update_request
while (true)
Expand Down Expand Up @@ -268,7 +265,8 @@ void meta_service::update_configuration(configuration_update_request& request, _
{
_state->update_configuration(request, response);

tasking::enqueue(LPC_LBM_RUN, this, std::bind(&meta_service::on_config_changed, this, request.config.gpid));
if (_started)
tasking::enqueue(LPC_LBM_RUN, this, std::bind(&meta_service::on_config_changed, this, request.config.gpid));
}

// local timers
Expand Down
1 change: 1 addition & 0 deletions src/apps/replication/meta_server/meta_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class meta_service : public serverlet<meta_service>
task_ptr _balancer_timer;
replication_options _opts;
std::string _data_dir;
bool _started;

zlock _log_lock;
handle_t _log;
Expand Down

0 comments on commit c734650

Please sign in to comment.