- Adjust memory new/free owner.
Change-Id: I41bdce2d32166eb6fa69c01da5526bcd3f407727
msg.caller = (void *)this;
msg.callback = (void *)this; /* if callback is class instance, it means synchronized call */
- ClientIPC::getInstance().sendMessage(&msg);
-
syncLock();
- rv = waitTimedCondition(0);
- syncUnlock();
-
- if (rv < 0)
+ if (ClientIPC::getInstance().sendMessage(&msg) == true)
{
- SCARD_DEBUG_ERR("closeSync failed [%d]", rv);
+ rv = waitTimedCondition(0);
+ if (rv < 0)
+ {
+ SCARD_DEBUG_ERR("closeSync failed [%d]", rv);
+ }
}
+ else
+ {
+ SCARD_DEBUG_ERR("sendMessage failed");
+ }
+ syncUnlock();
channelNum = -1;
}
int ClientChannel::close(closeCallback callback, void *userParam)
{
+ int result = 0;
+
if (isClosed() == false)
{
if (getSession()->getReader()->isSecureElementPresent() == true)
msg.callback = (void *)callback;
msg.userParam = userParam;
- ClientIPC::getInstance().sendMessage(&msg);
+ if (ClientIPC::getInstance().sendMessage(&msg) == true)
+ {
+ result = 0;
+ }
+ else
+ {
+ result = -1;
+ }
}
else
{
SCARD_DEBUG_ERR("unavailable channel");
+ result = -1;
}
}
- return 0;
+ return result;
}
int ClientChannel::transmitSync(ByteArray command, ByteArray &result)
msg.caller = (void *)this;
msg.callback = (void *)this; /* if callback is class instance, it means synchronized call */
- ClientIPC::getInstance().sendMessage(&msg);
-
syncLock();
- rv = waitTimedCondition(0);
- syncUnlock();
-
- if (rv >= 0)
+ if (ClientIPC::getInstance().sendMessage(&msg) == true)
{
- result = response;
+ rv = waitTimedCondition(0);
+ if (rv >= 0)
+ {
+ result = response;
+
+ rv = 0;
+ }
+ else
+ {
+ SCARD_DEBUG_ERR("clientIPC is null");
- rv = 0;
+ rv = -1;
+ }
}
else
{
- SCARD_DEBUG_ERR("clientIPC is null");
-
- rv = -1;
+ SCARD_DEBUG_ERR("sendMessage failed");
}
+ syncUnlock();
#endif
}
else
{
SCARD_DEBUG_ERR("unavailable channel");
-
- rv = -1;
}
return rv;
int ClientChannel::transmit(ByteArray command, transmitCallback callback, void *userParam)
{
+ int result = -1;
+
if (getSession()->getReader()->isSecureElementPresent() == true)
{
Message msg;
msg.callback = (void *)callback;
msg.userParam = userParam;
- ClientIPC::getInstance().sendMessage(&msg);
+ if (ClientIPC::getInstance().sendMessage(&msg) == true)
+ {
+ result = 0;
+ }
+ else
+ {
+ result = -1;
+ }
}
else
{
SCARD_DEBUG_ERR("unavailable channel");
}
- return 0;
+ return result;
}
bool ClientChannel::dispatcherCallback(void *message)
break;
}
- delete msg;
-
return result;
}
} /* namespace smartcard_service_api */
case Message::MSG_REQUEST_READERS :
case Message::MSG_REQUEST_SHUTDOWN :
{
- DispatcherMsg *tempMsg = new DispatcherMsg(msg);
-
- if (msg->callback != msg->caller)
+ if (msg->isSynchronousCall() == false)
{
+ DispatcherMsg *tempMsg = new DispatcherMsg(msg);
+
/* Asynchronous call */
g_idle_add((GSourceFunc)&SEService::dispatcherCallback, (gpointer)tempMsg);
}
else
{
/* Synchronous call */
- SEService::dispatcherCallback(tempMsg);
+ SEService::dispatcherCallback(msg);
}
}
break;
- /* Reader requests */
+ /* Reader requests */
case Message::MSG_REQUEST_OPEN_SESSION :
{
- DispatcherMsg *tempMsg = new DispatcherMsg(msg);
-
- if (msg->callback != msg->caller)
+ if (msg->isSynchronousCall() == false)
{
+ DispatcherMsg *tempMsg = new DispatcherMsg(msg);
+
/* Asynchronous call */
g_idle_add((GSourceFunc)&Reader::dispatcherCallback, (gpointer)tempMsg);
}
else
{
/* Synchronous call */
- Reader::dispatcherCallback(tempMsg);
+ Reader::dispatcherCallback(msg);
}
}
break;
case Message::MSG_REQUEST_CLOSE_SESSION :
case Message::MSG_REQUEST_GET_CHANNEL_COUNT :
{
- DispatcherMsg *tempMsg = new DispatcherMsg(msg);
-
- if (msg->callback != msg->caller)
+ if (msg->isSynchronousCall() == false)
{
+ DispatcherMsg *tempMsg = new DispatcherMsg(msg);
+
/* Asynchronous call */
g_idle_add((GSourceFunc)&Session::dispatcherCallback, (gpointer)tempMsg);
}
else
{
/* Synchronous call */
- Session::dispatcherCallback(tempMsg);
+ Session::dispatcherCallback(msg);
}
}
break;
case Message::MSG_REQUEST_TRANSMIT :
case Message::MSG_REQUEST_CLOSE_CHANNEL :
{
- DispatcherMsg *tempMsg = new DispatcherMsg(msg);
-
- if (msg->callback != msg->caller)
+ if (msg->isSynchronousCall() == false)
{
+ DispatcherMsg *tempMsg = new DispatcherMsg(msg);
+
/* Asynchronous call */
g_idle_add((GSourceFunc)&ClientChannel::dispatcherCallback, (gpointer)tempMsg);
}
else
{
/* Synchronous call */
- ClientChannel::dispatcherCallback(tempMsg);
+ ClientChannel::dispatcherCallback(msg);
}
}
break;
msg = retrieveMessage();
if (msg != NULL)
{
- DispatcherMsg *dispMsg = new DispatcherMsg(msg);
+ DispatcherMsg dispMsg(msg);
/* set peer socket */
- dispMsg->setPeerSocket(ipcSocket);
+ dispMsg.setPeerSocket(ipcSocket);
/* push to dispatcher */
if (dispatcher != NULL)
{
#ifdef CLIENT_IPC_THREAD
- dispatcher->processMessage(dispMsg);
- delete dispMsg;
+ dispatcher->processMessage(&dispMsg);
#else
- dispatcher->pushMessage(dispMsg);
+ dispatcher->pushMessage(&dispMsg);
#endif
}
msg.caller = (void *)this;
msg.callback = (void *)this; /* if callback is class instance, it means synchronized call */
- ClientIPC::getInstance().sendMessage(&msg);
-
syncLock();
- rv = waitTimedCondition(0);
- syncUnlock();
-
- if (rv != 0)
+ if (ClientIPC::getInstance().sendMessage(&msg) == true)
+ {
+ rv = waitTimedCondition(0);
+ if (rv != 0)
+ {
+ SCARD_DEBUG_ERR("time over");
+ }
+ }
+ else
{
- SCARD_DEBUG_ERR("time over");
+ SCARD_DEBUG_ERR("sendMessage failed");
}
+ syncUnlock();
#endif
}
else
msg.callback = (void *)callback;
msg.userParam = userData;
- ClientIPC::getInstance().sendMessage(&msg);
-
- result = 0;
+ if (ClientIPC::getInstance().sendMessage(&msg) == true)
+ {
+ result = 0;
+ }
+ else
+ {
+ SCARD_DEBUG_ERR("sendMessage failed");
+ }
}
else
{
break;
}
- delete msg;
-
SCARD_END();
return result;
msg.caller = (void *)this;
msg.callback = (void *)this; /* if callback is class instance, it means synchronized call */
+ syncLock();
if (ClientIPC::getInstance().sendMessage(&msg) == true)
{
- syncLock();
rv = waitTimedCondition(0);
- syncUnlock();
if (rv == 0)
{
{
SCARD_DEBUG_ERR("sendMessage failed");
}
+ syncUnlock();
}
#endif
}
break;
}
- delete msg;
-
SCARD_END();
return result;
msg.caller = (void *)this;
msg.callback = (void *)this; /* if callback is class instance, it means synchronized call */
- ClientIPC::getInstance().sendMessage(&msg);
-
syncLock();
- rv = waitTimedCondition(0);
- syncUnlock();
-
- if (rv != 0)
+ if (ClientIPC::getInstance().sendMessage(&msg) == true)
+ {
+ rv = waitTimedCondition(0);
+ if (rv != 0)
+ {
+ SCARD_DEBUG_ERR("time over");
+ }
+ }
+ else
{
- SCARD_DEBUG_ERR("time over");
+ SCARD_DEBUG_ERR("sendMessage failed");
}
+ syncUnlock();
#endif
}
else
msg.callback = (void *)callback;
msg.userParam = userData;
- ClientIPC::getInstance().sendMessage(&msg);
-
- result = 0;
+ if (ClientIPC::getInstance().sendMessage(&msg) == true)
+ {
+ result = 0;
+ }
}
else
{
msg.caller = (void *)this;
msg.callback = (void *)this; /* if callback is class instance, it means synchronized call */
- ClientIPC::getInstance().sendMessage(&msg);
-
syncLock();
- rv = waitTimedCondition(0);
- syncUnlock();
+ if (ClientIPC::getInstance().sendMessage(&msg) == true)
+ {
+ rv = waitTimedCondition(0);
- if (rv != 0)
+ if (rv != 0)
+ {
+ SCARD_DEBUG_ERR("time over");
+ }
+ }
+ else
{
- SCARD_DEBUG_ERR("time over");
+ SCARD_DEBUG_ERR("sendMessage failed");
}
+ syncUnlock();
}
#endif
}
int Session::close(closeSessionCallback callback, void *userData)
{
+ int result = -1;
Message msg;
if (isClosed() == false)
msg.callback = (void *)callback;
msg.userParam = userData;
- ClientIPC::getInstance().sendMessage(&msg);
+ if (ClientIPC::getInstance().sendMessage(&msg) == true)
+ {
+ result = 0;
+ }
}
- return 0;
+ return result;
}
unsigned int Session::getChannelCountSync()
msg.caller = (void *)this;
msg.callback = (void *)this; /* if callback is class instance, it means synchronized call */
- ClientIPC::getInstance().sendMessage(&msg);
+ channelCount = -1;
syncLock();
- rv = waitTimedCondition(0);
- syncUnlock();
-
- if (rv != 0)
+ if (ClientIPC::getInstance().sendMessage(&msg) == true)
{
- SCARD_DEBUG_ERR("time over");
-
- channelCount = -1;
+ rv = waitTimedCondition(0);
+ if (rv != 0)
+ {
+ SCARD_DEBUG_ERR("time over");
+ }
+ }
+ else
+ {
+ SCARD_DEBUG_ERR("sendMessage failed");
}
+ syncUnlock();
#endif
}
else
msg.callback = (void *)callback;
msg.userParam = userData;
- ClientIPC::getInstance().sendMessage(&msg);
-
- result = 0;
+ if (ClientIPC::getInstance().sendMessage(&msg) == true)
+ {
+ result = 0;
+ }
}
else
{
msg.caller = (void *)this;
msg.callback = (void *)this; /* if callback is class instance, it means synchronized call */
- ClientIPC::getInstance().sendMessage(&msg);
-
syncLock();
- rv = waitTimedCondition(0);
- syncUnlock();
-
- if (rv != 0)
+ if (ClientIPC::getInstance().sendMessage(&msg) == true)
+ {
+ rv = waitTimedCondition(0);
+ if (rv != 0)
+ {
+ SCARD_DEBUG_ERR("time over");
+ }
+ }
+ else
{
- SCARD_DEBUG_ERR("time over");
+ SCARD_DEBUG_ERR("sendMessage failed");
}
+ syncUnlock();
#endif
}
else
msg.callback = (void *)callback;
msg.userParam = userData;
- ClientIPC::getInstance().sendMessage(&msg);
-
- result = 0;
+ if (ClientIPC::getInstance().sendMessage(&msg) == true)
+ {
+ result = 0;
+ }
}
else
{
break;
}
- delete msg;
-
return result;
}
} /* namespace smartcard_service_api */
void DispatcherHelper::pushMessage(DispatcherMsg *msg)
{
+ DispatcherMsg *pushMsg = new DispatcherMsg(msg);
+
syncLock();
- messageQ.push(msg);
+ messageQ.push(pushMsg);
signalCondition();
syncUnlock();
{
if (pollEvents[i].data.fd == fdPoll)
{
- SCARD_DEBUG("pollEvents[%d].data.fd == fdPoll", i);
- SCARD_DEBUG("pollEvents[%d].events [%X]", pollEvents[i].events);
+ SCARD_DEBUG("pollEvents[%d].events [%X]", i, pollEvents[i].events);
- if (pollEvents[i].events & EPOLLIN)
+ if ((pollEvents[i].events & EPOLLHUP) || (pollEvents[i].events & EPOLLERR))
{
- result = 1;
+ SCARD_DEBUG_ERR("connection is closed");
+ result = 0;
break;
}
- else if ((pollEvents[i].events & EPOLLHUP) || (pollEvents[i].events & EPOLLERR))
+ else if (pollEvents[i].events & EPOLLIN)
{
- SCARD_DEBUG_ERR("connection is closed");
- result = 0;
+ result = 1;
break;
}
}
userParam = msg->userParam;
}
+ DispatcherMsg(DispatcherMsg *msg):Message()
+ {
+ peerSocket = msg->peerSocket;
+ message = msg->message;
+ param1 = msg->param1;
+ param2 = msg->param2;
+ error = msg->error;
+ data = msg->data;
+ caller = msg->caller;
+ callback = msg->callback;
+ userParam = msg->userParam;
+ }
+
DispatcherMsg(Message *msg, int socket):Message()
{
peerSocket = socket;
Name: smartcard-service
Summary: Smartcard Service FW
Version: 0.1.0
-Release: 26
+Release: 27
Group: libs
License: Samsung Proprietary License
Source0: %{name}-%{version}.tar.gz
goto ERROR;
}
- SCARD_DEBUG("client socket is bound with g_io_channel");
+ SCARD_DEBUG("client socket is bond with g_io_channel");
if (ServerResource::getInstance().createClient(client_channel, client_sock_fd, client_src_id, 0, -1) == false)
{
/* read message */
if ((msg = retrieveMessage(peerSocket)) != NULL)
{
- DispatcherMsg *dispMsg = new DispatcherMsg(msg, peerSocket);
+ DispatcherMsg dispMsg(msg, peerSocket);
/* push to dispatcher */
- ServerDispatcher::getInstance()->pushMessage(dispMsg);
+ ServerDispatcher::getInstance()->pushMessage(&dispMsg);
result = TRUE;