{
int pid;
bool reverse;
- char pkgId[256];
- char appExecutableName[256];
+ char appId[256];
};
result
if (__fdCount == 0)
{
- // Set an pkgId
- String pkgId = _AppInfo::GetPackageId();
- int length = (pkgId.GetLength() + 1) * sizeof(wchar_t);
+ // Set an appId
+ String appId = _AppInfo::GetApplicationId();
+ int length = (appId.GetLength() + 1) * sizeof(wchar_t);
if (length > 255)
{
length = 255;
}
- SysTryReturnResult(NID_IO, pkgId.GetLength() > 0, E_SYSTEM, "AppId dose not exist.");
+ SysTryReturnResult(NID_IO, appId.GetLength() > 0, E_SYSTEM, "AppId dose not exist.");
- memcpy(helloMessage.pkgId, pkgId.GetPointer(), length);
-
- // Set an executableName
- String appExecutableName = _AppInfo::GetAppExecutableName();
- length = (appExecutableName.GetLength() + 1) * sizeof(wchar_t);
- if (length > 255)
- {
- length = 255;
- }
-
- if (appExecutableName.GetLength() != 0)
- {
- memcpy(helloMessage.appExecutableName, appExecutableName.GetPointer(), length);
- }
+ memcpy(helloMessage.appId, appId.GetPointer(), length);
}
client = socket(AF_UNIX, SOCK_STREAM, 0);
strncpy(server.sun_path, socketName.c_str(), socketNameLength);
serverLen = sizeof(server);
- ret = connect(client, (struct sockaddr*) &server, serverLen);
- if (ret != 0)
+ // Retry if the server is not ready
+ int retry = 5;
+ while (retry > 0)
+ {
+ ret = connect(client, (struct sockaddr*) &server, serverLen);
+ if (ret < 0 && errno == ENOENT)
+ {
+ SysLog(NID_IO, "The server is not ready. %d", retry);
+
+ usleep(1000 * 1000);
+
+ --retry;
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ if (ret < 0)
{
SysTryCatch(NID_IO, errno == EINPROGRESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed to connect to server(%s) : %s",
socketName.c_str(), strerror(errno));
std::string message;
- struct pollfd pfd;
-
IPC::Message* pReply = null;
MessageReplyDeserializer* pReplyDeserializer = null;
IPC::SyncMessage* pSyncMessage = dynamic_cast <IPC::SyncMessage*>(pMessage);
while (remain > 0)
{
written = write(fd, (char*) pData, remain);
+ if (written < 0)
+ {
+ SysLogException(NID_IO, E_SYSTEM, "[E_SYSTEM] Failed to send a request: %d, %s", errno, strerror(errno));
+
+ ReleaseFd(fd);
+ return E_SYSTEM;
+ }
+
remain -= written;
pData += written;
}
// Wait reply
+ struct pollfd pfd;
+
pfd.fd = fd;
pfd.events = POLLIN | POLLRDHUP;
pfd.revents = 0;
if (pfd.revents & POLLRDHUP)
{
SysLogException(NID_IO, E_SYSTEM, "[E_SYSTEM] POLLRDHUP");
+
+ ReleaseFd(fd);
return E_SYSTEM;
}