From c322ed329530873f0dc78d6244f53cbcffdf508a Mon Sep 17 00:00:00 2001 From: Sunwook Bae Date: Wed, 29 May 2013 15:10:37 +0900 Subject: [PATCH] Add SetTimeout() in _IpcClient Change-Id: If923bee04ed86c0fd442569f422e1189ce0eba0e Signed-off-by: Sunwook Bae --- src/io/FIo_IpcClient.cpp | 22 +++++++++++++++++++++- src/io/inc/FIo_IpcClient.h | 18 ++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/io/FIo_IpcClient.cpp b/src/io/FIo_IpcClient.cpp index 6e1061f..780bb7f 100644 --- a/src/io/FIo_IpcClient.cpp +++ b/src/io/FIo_IpcClient.cpp @@ -57,6 +57,7 @@ namespace Tizen { namespace Io _IpcClient::_IpcClient(void) : __pReverseSource(null) , __fdCount(0) + , __timeout(-1) , __pFdLock(null) , __pListener(null) { @@ -564,7 +565,7 @@ _IpcClient::SendSync(IPC::Message* pMessage) while (true) { - ret = poll(&pfd, 1, -1); + ret = poll(&pfd, 1, __timeout); if (ret < 0) { if (errno == EINTR) @@ -577,6 +578,13 @@ _IpcClient::SendSync(IPC::Message* pMessage) ReleaseFd(fd); return E_SYSTEM; } + else if (ret == 0) + { + SysLogException(NID_IO, E_TIMEOUT, "[E_TIMEOUT] Timeout."); + + ReleaseFd(fd); + return E_TIMEOUT; + } if (pfd.revents & POLLRDHUP) { @@ -667,4 +675,16 @@ _IpcClient::SendRequest(const IPC::Message& message) return r; } +void +_IpcClient::SetTimeout(int timeout) +{ + __timeout = timeout; +} + +int +_IpcClient::GetTimeout(void) const +{ + return __timeout; +} + } } //Tizen::Io diff --git a/src/io/inc/FIo_IpcClient.h b/src/io/inc/FIo_IpcClient.h index 1cbd394..f262022 100644 --- a/src/io/inc/FIo_IpcClient.h +++ b/src/io/inc/FIo_IpcClient.h @@ -104,6 +104,7 @@ public: * @exception E_SUCCESS The method was successful. * @exception E_INVALID_STATE The instance is in an invalid state. * @exception E_OUT_OF_MEMORY Insufficient memory. + * @exception E_TIMEOUT The operation can not be completed within the specified time period. * @exception E_SYSTEM A system error occurred. * */ @@ -111,6 +112,22 @@ public: result SendRequest(IPC::Message* pMessage); + + /** + * Sets the timeout value which is used to send a synchronous message to the server. + * + * @param[in] timeout The time limit for synchronous messages, in milliseconds. + * @c infinite timeout if @c timeout value is a negative. + */ + void SetTimeout(int timeout); + + /** + * Gets the timeout value. + * + * @return The name of the IPC server. + */ + int GetTimeout() const; + private: _IpcClient(const _IpcClient& value); @@ -137,6 +154,7 @@ private: std::vector __fds; int __fdCount; + int __timeout; Tizen::Base::Runtime::Mutex* __pFdLock; Tizen::Base::String __name; _IIpcClientEventListener* __pListener; -- 2.7.4