struct client_cb *client_cb = state->data;
if (client_cb->result_cb) {
- /* If the callback return FAILURE, remove itself from the callback list */
- client_cb->result_cb(state->packet.head.data.ack.ret, state->from_pid, client_cb->data);
+ /* If the callback return FAILURE,
+ * remove itself from the callback list */
+ client_cb->result_cb(state->packet.head.data.ack.ret,
+ state->from_pid, client_cb->data);
}
state->state = BEGIN;
char *exec;
char *icon;
- if (state->packet.head.data.req.field_size.pkgname) {
+ if (state->packet.head.data.req.field_size.pkgname)
pkgname = state->payload;
- } else {
+ else
pkgname = NULL;
- }
- if (state->packet.head.data.req.field_size.name) {
+ if (state->packet.head.data.req.field_size.name)
name = state->payload + state->packet.head.data.req.field_size.pkgname;
- } else {
+ else
name = NULL;
- }
if (state->packet.head.data.req.field_size.exec) {
exec = state->payload + state->packet.head.data.req.field_size.pkgname;
state->payload + state->length,
state->packet.head.payload_size - state->length,
&check_pid);
- if (ret < 0) {
+ if (ret < 0)
return FALSE;
- }
if (state->from_pid != check_pid) {
- LOGD("PID is not matched (%d, expected %d)\n", check_pid, state->from_pid);
+ LOGD("PID is not matched (%d, expected %d)\n",
+ check_pid, state->from_pid);
return FALSE;
}
{
if (state->length < state->packet.head.payload_size) {
int ret;
- char *buffer;
+ char *buf;
int check_pid;
- buffer = alloca(state->packet.head.payload_size - state->length);
+ buf = alloca(state->packet.head.payload_size - state->length);
ret = secom_recv(conn_fd,
- buffer,
+ buf,
state->packet.head.payload_size - state->length,
&check_pid);
- if (ret < 0) {
+ if (ret < 0)
return FALSE;
- }
- if (check_pid != state->from_pid) {
- LOGD("PID is not matched (%d, expected %d)\n", check_pid, state->from_pid);
- }
+ if (check_pid != state->from_pid)
+ LOGD("PID is not matched (%d, expected %d)\n",
+ check_pid, state->from_pid);
state->length += ret;
}
- if (state->length < state->packet.head.payload_size) {
+ if (state->length < state->packet.head.payload_size)
return TRUE;
- }
/* Now, drop this connection */
return FALSE;
((char*)&state->packet) + state->length,
sizeof(state->packet) - state->length,
&check_pid);
- if (ret < 0) {
+ if (ret < 0)
return FALSE;
- }
- if (state->from_pid == 0) {
+ if (state->from_pid == 0)
state->from_pid = check_pid;
- }
if (state->from_pid != check_pid) {
- LOGD("PID is not matched (%d, expected %d)\n", check_pid, state->from_pid);
+ LOGD("PID is not matched (%d, expected %d)\n",
+ check_pid, state->from_pid);
return FALSE;
}
state->length += ret;
}
- if (state->length < sizeof(state->packet)) {
+ if (state->length < sizeof(state->packet))
return TRUE;
- }
if (state->packet.head.type == PACKET_ACK) {
state->length = 0;
- if (state->packet.head.payload_size) {
+ if (state->packet.head.payload_size)
state->state = ERROR;
- } else {
+ else
state->state = END;
- }
} else if (state->packet.head.type == PACKET_REQ) {
/* Let's take the next part. */
state->state = PAYLOAD;
if (read_size == 0) {
if (client_cb->result_cb) {
- /* If the callback return FAILURE, remove itself from the callback list */
- client_cb->result_cb(-ECONNABORTED, state->from_pid, client_cb->data);
+ /* If the callback return FAILURE,
+ * remove itself from the callback list */
+ client_cb->result_cb(-ECONNABORTED,
+ state->from_pid, client_cb->data);
}
ret = FALSE;
goto out;
break;
}
- if (state->state == END) {
+ if (state->state == END)
ret = check_reply_service(conn_fd, state);
- }
out:
if (ret == FALSE) {
ret = filling_payload(conn_fd, state);
break;
default:
- LOGE("[%s:%d] Invalid state(%x)\n", __func__, __LINE__, state->state);
+ LOGE("[%s:%d] Invalid state(%x)\n",
+ __func__, __LINE__, state->state);
ret = FALSE;
break;
}
if (ret == FALSE) {
secom_put_connection_handle(conn_fd);
- if (state->payload) {
+ if (state->payload)
free(state->payload);
- }
free(state);
}
connection_fd = secom_get_connection_handle(server_fd);
if (connection_fd < 0) {
- /* Error log will be printed from get_connection_handle function */
+ /* Error log will be printed from
+ * get_connection_handle function */
return FALSE;
}
- if (fcntl(connection_fd, F_SETFD, FD_CLOEXEC) < 0) {
+ if (fcntl(connection_fd, F_SETFD, FD_CLOEXEC) < 0)
LOGE("Error: %s\n", strerror(errno));
- }
- if (fcntl(connection_fd, F_SETFL, O_NONBLOCK) < 0) {
+
+ if (fcntl(connection_fd, F_SETFL, O_NONBLOCK) < 0)
LOGE("Error: %s\n", strerror(errno));
- }
gio = g_io_channel_unix_new(connection_fd);
if (!gio) {
}
state->state = BEGIN;
- id = g_io_add_watch(gio, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL, (GIOFunc)connection_cb, state);
+ id = g_io_add_watch(gio,
+ G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
+ (GIOFunc)connection_cb, state);
if (id < 0) {
GError *err = NULL;
LOGE("Failed to create g_io watch\n");
-static inline
-int init_client(struct client_cb *client_cb, const char *packet, int packet_size)
+static inline int init_client(struct client_cb *client_cb,
+ const char *packet, int packet_size)
{
GIOChannel *gio;
guint id;
return -EFAULT;
}
- if (fcntl(client_fd, F_SETFD, FD_CLOEXEC) < 0) {
+ if (fcntl(client_fd, F_SETFD, FD_CLOEXEC) < 0)
LOGE("Error: %s\n", strerror(errno));
- }
- if (fcntl(client_fd, F_SETFL, O_NONBLOCK) < 0) {
+
+ if (fcntl(client_fd, F_SETFL, O_NONBLOCK) < 0)
LOGE("Error: %s\n", strerror(errno));
- }
gio = g_io_channel_unix_new(client_fd);
if (!gio) {
state->data = client_cb;
- id = g_io_add_watch(gio, G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL, (GIOFunc)client_connection_cb, state);
+ id = g_io_add_watch(gio,
+ G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
+ (GIOFunc)client_connection_cb, state);
if (id < 0) {
GError *err = NULL;
LOGE("Failed to create g_io watch\n");
if (secom_send(client_fd, packet, packet_size) != packet_size) {
GError *err = NULL;
- LOGE("Failed to send all packet (g_io_channel is not cleared now\n");
+ LOGE("Failed to send all packet "
+ "(g_io_channel is not cleared now\n");
free(state);
g_io_channel_shutdown(gio, TRUE, &err);
close(client_fd);
}
if (pthread_mutex_lock(&s_info.server_mutex) != 0) {
- LOGE("[%s:%d] Failed to get lock (%s)\n", __func__, __LINE__, strerror(errno));
+ LOGE("[%s:%d] Failed to get lock (%s)\n",
+ __func__, __LINE__, strerror(errno));
return -EFAULT;
}
- if (sd_listen_fds(1) == 1
- && sd_is_socket_unix(SD_LISTEN_FDS_START, SOCK_STREAM, -1, s_info.socket_file, 0) > 0) {
+ if (sd_listen_fds(1) == 1 && sd_is_socket_unix(SD_LISTEN_FDS_START,
+ SOCK_STREAM, -1, s_info.socket_file, 0) > 0) {
s_info.server_fd = SD_LISTEN_FDS_START;
} else {
unlink(s_info.socket_file);
if (s_info.server_fd < 0) {
LOGE("Failed to open a socket (%s)\n", strerror(errno));
- if (pthread_mutex_unlock(&s_info.server_mutex) != 0) {
- LOGE("[%s:%d] Failed to do unlock mutex (%s)\n", __func__, __LINE__, strerror(errno));
- }
+ if (pthread_mutex_unlock(&s_info.server_mutex) != 0)
+ LOGE("[%s:%d] Failed to do unlock mutex (%s)\n",
+ __func__, __LINE__, strerror(errno));
return -EFAULT;
}
- if (fcntl(s_info.server_fd, F_SETFD, FD_CLOEXEC) < 0) {
+ if (fcntl(s_info.server_fd, F_SETFD, FD_CLOEXEC) < 0)
LOGE("Error: %s\n", strerror(errno));
- }
- if (fcntl(s_info.server_fd, F_SETFL, O_NONBLOCK) < 0) {
+
+ if (fcntl(s_info.server_fd, F_SETFL, O_NONBLOCK) < 0)
LOGE("Error: %s\n", strerror(errno));
- }
gio = g_io_channel_unix_new(s_info.server_fd);
if (!gio) {
close(s_info.server_fd);
s_info.server_fd = -1;
- if (pthread_mutex_unlock(&s_info.server_mutex) != 0) {
- LOGE("[%s:%d] Failed to do unlock mutex (%s)\n", __func__, __LINE__, strerror(errno));
- }
+ if (pthread_mutex_unlock(&s_info.server_mutex) != 0)
+ LOGE("[%s:%d] Failed to do unlock mutex (%s)\n",
+ __func__, __LINE__, strerror(errno));
return -EFAULT;
}
- id = g_io_add_watch(gio, G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL, (GIOFunc)accept_cb, NULL);
+ id = g_io_add_watch(gio,
+ G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL,
+ (GIOFunc)accept_cb, NULL);
if (id < 0) {
GError *err = NULL;
LOGE("Failed to create g_io watch\n");
g_io_channel_shutdown(gio, TRUE, &err);
close(s_info.server_fd);
s_info.server_fd = -1;
- if (pthread_mutex_unlock(&s_info.server_mutex) != 0) {
- LOGE("[%s:%d] Failed to do unlock mutex (%s)\n", __func__, __LINE__, strerror(errno));
- }
+ if (pthread_mutex_unlock(&s_info.server_mutex) != 0)
+ LOGE("[%s:%d] Failed to do unlock mutex (%s)\n",
+ __func__, __LINE__, strerror(errno));
+
return -EFAULT;
}
if (pthread_mutex_unlock(&s_info.server_mutex) != 0) {
GError *err = NULL;
g_io_channel_shutdown(gio, TRUE, &err);
- LOGE("[%s:%d] Failed to do unlock mutex (%s)\n", __func__, __LINE__, strerror(errno));
+ LOGE("[%s:%d] Failed to do unlock mutex (%s)\n",
+ __func__, __LINE__, strerror(errno));
/* NOTE:
* We couldn't make a lock for this statements.
* We already meet the unrecoverble error