[Groonga-commit] groonga/grnxx at 2a4b6a7 [master] Disable update of a read-only storage.

Back to archive index

susumu.yata null+****@clear*****
Wed May 1 13:09:58 JST 2013


susumu.yata	2013-05-01 13:09:58 +0900 (Wed, 01 May 2013)

  New Revision: 2a4b6a713f584a2b20b19dbc5535c4d8cd7d282e
  https://github.com/groonga/grnxx/commit/2a4b6a713f584a2b20b19dbc5535c4d8cd7d282e

  Message:
    Disable update of a read-only storage.

  Modified files:
    lib/grnxx/storage/storage_impl.cpp

  Modified: lib/grnxx/storage/storage_impl.cpp (+12 -0)
===================================================================
--- lib/grnxx/storage/storage_impl.cpp    2013-05-01 10:41:45 +0900 (c4eeaa1)
+++ lib/grnxx/storage/storage_impl.cpp    2013-05-01 13:09:58 +0900 (245c171)
@@ -165,6 +165,10 @@ bool StorageImpl::unlink(const char *path) {
 }
 
 StorageNode StorageImpl::create_node(uint32_t parent_node_id, uint64_t size) {
+  if (flags_ & STORAGE_READ_ONLY) {
+    GRNXX_ERROR() << "invalid operation: flags = " << flags_;
+    return StorageNode(nullptr);
+  }
   Lock data_lock(&header_->data_mutex);
   if (parent_node_id >= header_->num_nodes) {
     GRNXX_ERROR() << "invalid argument: parent_node_id = " << parent_node_id
@@ -227,6 +231,10 @@ StorageNode StorageImpl::open_node(uint32_t node_id) {
 }
 
 bool StorageImpl::unlink_node(uint32_t node_id) {
+  if (flags_ & STORAGE_READ_ONLY) {
+    GRNXX_ERROR() << "invalid operation: flags = " << flags_;
+    return false;
+  }
   Lock data_lock(&header_->data_mutex);
   if ((node_id == STORAGE_ROOT_NODE_ID) || (node_id >= header_->num_nodes)) {
     GRNXX_ERROR() << "invalid argument: node_id = " << node_id
@@ -280,6 +288,10 @@ bool StorageImpl::unlink_node(uint32_t node_id) {
 }
 
 bool StorageImpl::sweep(Duration lifetime) {
+  if (flags_ & STORAGE_READ_ONLY) {
+    GRNXX_ERROR() << "invalid operation: flags = " << flags_;
+    return false;
+  }
   Lock data_lock(&header_->data_mutex);
   if (header_->latest_unlinked_node_id == STORAGE_INVALID_NODE_ID) {
     // Nothing to do.
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index