From: sung-su.kim Date: Mon, 28 Oct 2013 04:43:50 +0000 (+0900) Subject: Revert "[DPL] FileLock" X-Git-Tag: 2.2.1_release~2^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2d04c832886a2ee5952052ca912060f4e877b45f;p=framework%2Fweb%2Fwrt-commons.git Revert "[DPL] FileLock" Launch is blocked by reinstallation or deinstallation For this reason, the app is not launched. Please check again it and make a commit. This reverts commit 32f6ed3d788fc6f811111607261e255741675cb1. Change-Id: I4ef3ddd1677a4155183ff855ed9981bf4ee7842c --- diff --git a/modules/core/config.cmake b/modules/core/config.cmake index 6e665d4..1a8625e 100644 --- a/modules/core/config.cmake +++ b/modules/core/config.cmake @@ -36,7 +36,6 @@ SET(DPL_CORE_SOURCES ${PROJECT_SOURCE_DIR}/modules/core/src/exception.cpp ${PROJECT_SOURCE_DIR}/modules/core/src/fast_delegate.cpp ${PROJECT_SOURCE_DIR}/modules/core/src/file_input.cpp - ${PROJECT_SOURCE_DIR}/modules/core/src/file_lock.cpp ${PROJECT_SOURCE_DIR}/modules/core/src/file_output.cpp ${PROJECT_SOURCE_DIR}/modules/core/src/lexical_cast.cpp ${PROJECT_SOURCE_DIR}/modules/core/src/mutable_task_list.cpp @@ -96,7 +95,6 @@ SET(DPL_CORE_HEADERS ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/exception.h ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/fast_delegate.h ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/file_input.h - ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/file_lock.h ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/file_output.h ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/foreach.h ${PROJECT_SOURCE_DIR}/modules/core/include/dpl/generic_event.h diff --git a/modules/core/include/dpl/file_lock.h b/modules/core/include/dpl/file_lock.h deleted file mode 100644 index 4771d89..0000000 --- a/modules/core/include/dpl/file_lock.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file file_lock.h - * @author Tomasz Iwanek (t.iwanek@samsung.com) - * @version 1.0 - * @brief This implementation fo file locking - */ -#ifndef DPL_FILE_LOCK_H -#define DPL_FILE_LOCK_H - -#include -#include - -#include -#include - -namespace DPL { -class FileLock : private Noncopyable -{ - protected: - int m_fd; - std::string m_filename; - size_t m_mode; - - public: - FileLock(const std::string & filename, bool blocking = true, size_t mode = 0666); - ~FileLock(); - - bool lock(bool blocking = true); - bool unlock(); - bool isHoldingLock() const; - int getFd() const; -}; - -class FileBasedMutex : public FileLock -{ -public: - FileBasedMutex(const std::string & id, bool blocking = true); -}; - -} // namespace DPL - -#endif // DPL_FILE_LOCK_H diff --git a/modules/core/src/file_lock.cpp b/modules/core/src/file_lock.cpp deleted file mode 100644 index 0106df4..0000000 --- a/modules/core/src/file_lock.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - * @file file_input.cpp - * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of named input pipe - */ - -#include - -#include - -namespace DPL { - -FileLock::FileLock(const std::string & filename, bool blocking, size_t mode) : m_filename(filename), m_mode(mode) -{ - lock(blocking); -} - -FileLock::~FileLock() -{ - if(isHoldingLock()) - { - unlock(); - } -} - -bool FileLock::lock(bool blocking) -{ - if(isHoldingLock()) return true; - - int ret = 0; - - m_fd = open(m_filename.c_str(), O_RDONLY | O_CREAT, m_mode); - - if (m_fd == -1) { - return false; - } - - if(blocking) - { - ret = flock(m_fd, LOCK_EX); - } - else - { - ret = flock(m_fd, LOCK_EX | LOCK_NB); - } - - if (ret == -1) { - close(m_fd); - m_fd = -1; - return false; - } - - return true; -} - -bool FileLock::unlock() -{ - if(!isHoldingLock()) return true; - - int ret = 0; - ret = flock(m_fd, LOCK_UN); - if(ret == -1) - { - return false; - } - close(m_fd); - m_fd = -1; - return true; -} - -bool FileLock::isHoldingLock() const -{ - return (m_fd > 0); -} - -int FileLock::getFd() const -{ - return m_fd; -} - -FileBasedMutex::FileBasedMutex(const std::string & id, bool blocking) : FileLock(std::string("/tmp/.dpl_lock.") + id, blocking) -{ -} - -} // namespace DPL -