summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSunwook Bae <sunwook45.bae@samsung.com>2013-05-14 16:07:06 +0900
committerSunwook Bae <sunwook45.bae@samsung.com>2013-05-14 16:34:53 +0900
commit2fb8e85db4c51335ca896c67b82f2b6905c64148 (patch)
tree5f127f2cca0d4b8917a939cc9c85ea7595e6bb12
parent078cdd523a15c8a6f991d8bdaa813da318edfc71 (diff)
downloadmessage-port-tizen_2.1.tar.gz
message-port-tizen_2.1.tar.bz2
message-port-tizen_2.1.zip
Change-Id: Ife73c2f7f30e50a0d723b0533ef0da32c02151c0 Signed-off-by: Sunwook Bae <sunwook45.bae@samsung.com>
-rw-r--r--src/IpcClient.cpp34
1 files changed, 31 insertions, 3 deletions
diff --git a/src/IpcClient.cpp b/src/IpcClient.cpp
index 3b1ed40..8f4d34b 100644
--- a/src/IpcClient.cpp
+++ b/src/IpcClient.cpp
@@ -128,6 +128,7 @@ int
IpcClient::MakeConnection(bool forReverse)
{
int ret = 0;
+ int retry = 0;
size_t socketNameLength = 0;
string socketName;
@@ -171,12 +172,30 @@ IpcClient::MakeConnection(bool forReverse)
goto CATCH;
}
- ret = connect(client, (struct sockaddr*) &server, serverLen);
- if (ret != 0)
+ // Retry if the server is not ready
+ retry = 5;
+ while (retry > 0)
+ {
+ ret = connect(client, (struct sockaddr*) &server, serverLen);
+ if (ret < 0 && errno == ENOENT)
+ {
+ _LOGD("The server is not ready. %d", retry);
+
+ usleep(1000 * 1000);
+
+ --retry;
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ if (ret < 0)
{
if (errno != EINPROGRESS)
{
- _LOGE("Failed to connect to server(%s) : %s", socketName.c_str(), strerror(errno));
+ _LOGE("Failed to connect to server(%s) : %d, %s", socketName.c_str(), errno, strerror(errno));
goto CATCH;
}
@@ -497,6 +516,13 @@ IpcClient::SendSync(IPC::Message* pMessage)
while (remain > 0)
{
written = write(fd, (char*) pData, remain);
+ if (written < 0)
+ {
+ _LOGE("Failed to send a request: %d, %s", errno, strerror(errno));
+
+ ReleaseFd(fd);
+ return MESSAGEPORT_ERROR_IO_ERROR;
+ }
remain -= written;
pData += written;
}
@@ -532,6 +558,8 @@ IpcClient::SendSync(IPC::Message* pMessage)
if (pfd.revents & POLLRDHUP)
{
_LOGE("POLLRDHUP");
+
+ ReleaseFd(fd);
return MESSAGEPORT_ERROR_IO_ERROR;
}