#include <DcmTypes.h>
+#define DCM_TIMEOUT_SEC_60 60 /**< Response to media server time out */
+
namespace DcmIpcUtils {
int createSocket(int *socket_fd, DcmIpcPortType port);
int acceptSocket(int serv_sock, int *client_sock);
DcmIpcMsgType msg_type;
int pid;
uid_t uid;
+ int result;
size_t msg_size; /*this is size of message below and this does not include the terminationg null byte ('\0'). */
char msg[DCM_IPC_MSG_MAX_SIZE];
- int result;
} DcmIpcMsg;
typedef enum {
DcmScanItemType scan_item_type;
} DcmScanItem;
-typedef enum {
- DCM_FACE_ITEM_UPDATE_FACE = 0, /**< One face item is upated */
-} DcmFaceItemUpdateItem;
-
-typedef enum {
- DCM_FACE_ITEM_INSERT = 0, /**< Database update operation is INSERT */
- DCM_FACE_ITEM_DELETE = 1, /**< Database update operation is DELETE */
- DCM_FACE_ITEM_UPDATE = 2, /**< Database update operation is UPDATE */
- DCM_FACE_ITEM_REMOVE = 3, /**< Database update operation is REMOVE */
-} DcmFaceItemUpdateType;
-
typedef struct {
char *face_uuid;
char *media_uuid;
dcm_error("Invalid port! Stop sending message...");
return DCM_ERROR_INVALID_PARAMETER;
}
- dcm_debug("Send message type: %d", msg_type);
+ dcm_debug("Send message type: %d %s %d", msg_type, msg, result);
DcmIpcMsg send_msg;
int sock = -1;
if (socket_fd < 0) {
struct sockaddr_un serv_addr;
- struct timeval tv_timeout = { 10, 0 };
-
+ struct timeval tv_timeout = { DCM_TIMEOUT_SEC_60, 0 }; /* timeout: 60 seconds */
+
if ((sock = socket(PF_FILE, SOCK_STREAM, 0)) < 0) {
dcm_stderror("socket failed");
return DCM_ERROR_NETWORK;
/* Prepare send message */
memset((void *)&send_msg, 0, sizeof(DcmIpcMsg));
send_msg.msg_type = msg_type;
- send_msg.result = result;
+ send_msg.result = (int)result;
if (msg != NULL) {
send_msg.msg_size = strlen(msg);
strncpy(send_msg.msg, msg, send_msg.msg_size);
return DCM_ERROR_NETWORK;
}
- dcm_debug("Sent message type: %d", msg_type);
+ dcm_debug("Sent message type: %d %d", send_msg.msg_type, send_msg.result);
close(sock);
return DCM_SUCCESS;
int socket_fd = -1;
struct sockaddr_un serv_addr;
- //struct timeval tv_timeout = { 10, 0 }; /* timeout: 10 seconds */
DcmIpcMsg send_msg;
/* Prepare send message */
int socket_fd = -1;
struct sockaddr_un serv_addr;
- //struct timeval tv_timeout = { 10, 0 }; /* timeout: 10 seconds */
DcmIpcMsg send_msg;
/* Prepare send message */
}
/* Send ready response to dcm launcher */
- if (DcmIpcUtils::sendClientSocketMsg(-1, DCM_IPC_MSG_SERVICE_READY, 0, NULL, DCM_IPC_PORT_MS_RECV) != DCM_SUCCESS) {
+ if (DcmIpcUtils::sendSocketMsg(DCM_IPC_MSG_SERVICE_READY, 0, NULL, DCM_IPC_PORT_MS_RECV) != DCM_SUCCESS) {
dcm_error("Failed to send ready message");
}
}
if (DcmIpcUtils::receiveSocketMsg(client_sock, &recv_msg) < 0) {
dcm_error("getRecvMsg failed");
+ DcmIpcUtils::closeSocket(client_sock);
return TRUE;
}
/* Create scan thread before main loop is started */
if (dcmSvc->createScanThread() != DCM_SUCCESS) {
dcm_error("Failed to create scan thread! Exit main thread...");
+ DcmIpcUtils::closeSocket(client_sock);
return TRUE;
}
} else if (recv_msg.msg_type == DCM_IPC_MSG_SCAN_SINGLE) {
dcm_debug("Scan single");
ret = DcmScanMain::ScanSingle(recv_msg.msg, recv_msg.uid, &face_count);
- dcm_debug("Scan single result: %d", face_count);
- ret = DcmIpcUtils::sendClientSocketMsg(-1, DCM_IPC_MSG_SCAN_SINGLE, face_count, recv_msg.msg, DCM_IPC_PORT_MS_RECV);
- //ret = DcmIpcUtils::sendSocketMsg(DCM_IPC_MSG_SCAN_SINGLE, recv_msg.uid, recv_msg.msg, DCM_IPC_PORT_SCAN_RECV);
-/* if (ret == DCM_SUCCESS) {
- ret = DcmIpcUtils::sendClientSocketMsg(client_sock, DCM_IPC_MSG_SCAN_SINGLE, recv_msg.uid, recv_msg.msg, DCM_IPC_PORT_DCM_RECV);
- }*/
+ dcm_debug("Scan single result: %d (%d)", ret, face_count);
+ if (ret == DCM_SUCCESS) {
+ ret = DcmIpcUtils::sendClientSocketMsg(client_sock, DCM_IPC_MSG_SCAN_SINGLE, face_count, recv_msg.msg, DCM_IPC_PORT_MS_RECV);
+ if (ret != DCM_SUCCESS) {
+ dcm_error("Failed to sendClientSocketMsg! err: %d", ret);
+ }
+ } else {
+ ret = DcmIpcUtils::sendClientSocketMsg(client_sock, DCM_IPC_MSG_SCAN_SINGLE, ret, recv_msg.msg, DCM_IPC_PORT_MS_RECV);
+ if (ret != DCM_SUCCESS) {
+ dcm_error("Failed to sendClientSocketMsg! err: %d", ret);
+ }
+ }
} else {
dcm_debug("createDcmSvcReadSocket, invalid message(%d).", recv_msg.msg_type);
}