-Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.\r
+Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd. All rights reserved.\r
\r
Apache License\r
Version 2.0, January 2004\r
-Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
/*
* PIMS IPC
*
- * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
/*
* PIMS IPC
*
- * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
/*
* PIMS IPC
*
- * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
/*
* PIMS IPC
*
- * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
/*
* PIMS IPC
*
- * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
/*
* PIMS IPC
*
- * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
/*
* PIMS IPC
*
- * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
/*
* PIMS IPC
*
- * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
pims_ipc_data_s *handle = NULL;
handle = calloc(1, sizeof(pims_ipc_data_s));
+ if (NULL == handle) {
+ ERROR("calloc() Fail");
+ return NULL;
+ }
handle->alloc_size = size;
handle->free_size = size;
handle->buf_size = 0;
handle->buf = calloc(1, size);
+ if (NULL == handle->buf) {
+ ERROR("calloc() Fail");
+ free(handle);
+ return NULL;
+ }
handle->pos = handle->buf;
handle->created = 1;
handle->buf_alloced = 1;
while (new_size < handle->buf_size + used_size)
new_size *= 2;
handle->buf = realloc(handle->buf, new_size);
+ if (NULL == handle->buf) {
+ ERROR("realloc() Fail");
+ return -1;
+ }
handle->alloc_size = new_size;
handle->free_size = handle->alloc_size - handle->buf_size;
handle->pos = handle->buf;
VERBOSE("size : %d", size);
handle = calloc(1, sizeof(pims_ipc_data_s));
+ if (NULL == handle) {
+ ERROR("calloc() Fail");
+ return NULL;
+ }
handle->alloc_size = size;
handle->free_size = 0;
handle->buf_size = handle->alloc_size;
/*
* PIMS IPC
*
- * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
cb_data->callback((pims_ipc_h)worker_id, dhandle_in, dhandle_out, cb_data->user_data);
}
-static void __make_raw_data(const char *call_id, int seq_no, pims_ipc_data_h data, pims_ipc_raw_data_s**out)
+static void __make_raw_data(const char *call_id, int seq_no, pims_ipc_data_h data, pims_ipc_raw_data_s **out)
{
+ if (NULL == out) {
+ ERROR("Invalid parameter:out is NULL");
+ return;
+ }
+
pims_ipc_raw_data_s *raw_data = NULL;
raw_data = (pims_ipc_raw_data_s*)calloc(1, sizeof(pims_ipc_raw_data_s));
+ if (NULL == raw_data) {
+ ERROR("calloc() Fail");
+ return;
+ }
pims_ipc_data_s *data_in = (pims_ipc_data_s*)data;
raw_data->call_id = strdup(call_id);
if (data_in && data_in->buf_size > 0) {
raw_data->is_data = TRUE;
raw_data->data = calloc(1, data_in->buf_size+1);
+ if (NULL == raw_data->data) {
+ ERROR("calloc() Fail");
+ free(raw_data->call_id);
+ free(raw_data);
+ return;
+ }
memcpy(raw_data->data, data_in->buf, data_in->buf_size);
raw_data->data_len = data_in->buf_size;
}
worker_id = (int)pthread_self();
worker_data = calloc(1, sizeof(pims_ipc_worker_data_s));
+ if (NULL == worker_data) {
+ ERROR("calloc() Fail");
+ close(worker_fd);
+ return NULL;
+ }
worker_data->fd = worker_fd;
worker_data->worker_id = worker_id;
worker_data->client_fd = -1;
write_command(ipc_svc->manager, 1);
DEBUG("worker register to manager : worker_id(%08x00), worker_fd(%d)\n", worker_id, worker_fd);
- struct pollfd *pollfds = (struct pollfd*) malloc (1 * sizeof (struct pollfd));
+ struct pollfd *pollfds = (struct pollfd*)calloc(1, sizeof(struct pollfd));
+ if (NULL == pollfds) {
+ ERROR("calloc() Fail");
+ g_hash_table_remove(ipc_svc->task_fds, GINT_TO_POINTER(worker_fd));
+ free(worker_data);
+ close(worker_fd);
+ return NULL;
+ }
pollfds[0].fd = worker_fd;
pollfds[0].events = POLLIN;
}
else {
data_in = pims_ipc_data_steal_unmarshal(raw_data->data, raw_data->data_len);
+ if (NULL == data_in) {
+ ERROR("pims_ipc_data_steal_unmarshal() Fail");
+ break;
+ }
raw_data->data = NULL;
raw_data->data_len = 0;
raw_data->is_data = false;
}
else {
data_queue = calloc(1, sizeof(pims_ipc_request_s));
+ if (NULL == data_queue) {
+ ERROR("calloc() Fail");
+ pthread_mutex_unlock(&ipc_svc->request_data_queue_mutex);
+ return;
+ }
data_queue->request_count = 0;
pthread_mutex_init(&data_queue->raw_data_mutex, 0);
}
temp = (pims_ipc_raw_data_s*)calloc(1, sizeof(pims_ipc_raw_data_s));
+ if (NULL == temp) {
+ ERROR("calloc() Fail");
+ return -1;
+ }
temp->client_id = NULL;
temp->client_id_len = 0;
temp->call_id = NULL;
read_len += ret;
temp->client_id = calloc(1, temp->client_id_len+1);
+ if (NULL == temp->client_id) {
+ ERROR("calloc() Fail");
+ ret = -1;
+ break;
+ }
ret = socket_recv(fd, (void *)&(temp->client_id), temp->client_id_len);
if (ret < 0) { ERROR("socket_recv error"); break; }
read_len += ret;
read_len += ret;
temp->call_id = calloc(1, temp->call_id_len+1);
+ if (NULL == temp->call_id) {
+ ERROR("calloc() Fail");
+ ret = -1;
+ break;
+ }
ret = socket_recv(fd, (void *)&(temp->call_id), temp->call_id_len);
if (ret < 0) { ERROR("socket_recv error"); break; }
read_len += ret;
read_len += ret;
temp->data = calloc(1, temp->data_len+1);
+ if (NULL == temp->data) {
+ ERROR("calloc() Fail");
+ ret = -1;
+ break;
+ }
ret = socket_recv(fd, (void *)&(temp->data), temp->data_len);
if (ret < 0) { ERROR("socket_recv error"); break; }
read_len += ret;
*data = temp;
*identity = false;
- }while(0);
+ } while(0);
if (ret < 0) {
__free_raw_data(temp);
// send command to router
if (identity) {
pims_ipc_client_map_s *client = (pims_ipc_client_map_s*)calloc(1, sizeof(pims_ipc_client_map_s));
+ if (NULL == client) {
+ ERROR("calloc() Fail");
+ close(event_fd);
+ return FALSE;
+ }
+
client->fd = event_fd;
char temp[100];
ret = __send_identify(event_fd, req->seq_no, temp, strlen(temp));
__free_raw_data(req);
- if (ret < 0)
+ if (ret < 0) {
+ ERROR("__send_identify() Fail(%d)", ret);
+ close(event_fd);
return FALSE;
+ }
pims_ipc_client_info_s *client_info = NULL;
if (0 != _create_client_info(event_fd, &client_info))
int fd_count = 2;
struct pollfd *pollfds;
- pollfds = (struct pollfd*) malloc (fd_count * sizeof (struct pollfd));
-
+ pollfds = (struct pollfd*)calloc(fd_count, sizeof(struct pollfd));
+ if (NULL == pollfds) {
+ ERROR("calloc() Fail");
+ return NULL;
+ }
pollfds[0].fd = ipc_svc->router;
pollfds[0].events = POLLIN;
pollfds[1].fd = ipc_svc->manager;
/*
* PIMS IPC
*
- * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
if (total_len == read_len) {
// send identity
data = pims_ipc_data_create(0);
+ if (NULL == data) {
+ ERROR("pims_ipc_data_create() Fail");
+ break;
+ }
ret = pims_ipc_data_put(data, client_id, client_id_len);
if (ret != 0)
WARNING("pims_ipc_data_put fail(%d)", ret);
read_len += ret;
data = pims_ipc_data_steal_unmarshal(buf, data_len);
+ if (NULL == data) {
+ ERROR("pims_ipc_data_steal_unmarshal() Fail");
+ break;
+ }
buf = NULL;
}
static int __pims_ipc_receive(pims_ipc_s *handle, pims_ipc_data_h *data_out)
{
int ret = -1;
- struct pollfd *pollfds = (struct pollfd*) malloc (1 * sizeof (struct pollfd));
+ struct pollfd *pollfds = (struct pollfd*)calloc(1, sizeof(struct pollfd));
+ if (NULL == pollfds) {
+ ERROR("calloc() Fail");
+ return -1;
+ }
pollfds[0].fd = handle->fd;
pollfds[0].events = POLLIN | POLLERR | POLLHUP;
read_len += ret;
dhandle = pims_ipc_data_steal_unmarshal(buf, data_len);
+ if (NULL == dhandle) {
+ ERROR("pims_ipc_data_steal_unmarshal() Fail");
+ break;
+ }
buf = NULL;
pims_ipc_subscribe_data_s *sub_data = (pims_ipc_subscribe_data_s *)calloc(1, sizeof(pims_ipc_subscribe_data_s));
+ if (NULL == sub_data) {
+ ERROR("calloc() Fail");
+ break;
+ }
sub_data->handle = dhandle;
sub_data->call_id = call_id;
call_id = NULL;
write_command(handle->subscribe_fd, 1);
}
ret = 0;
- }while(0);
+ } while(0);
free(call_id);
free(buf);
/*
* PIMS IPC
*
- * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
/*
* PIMS IPC
*
- * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.