diff options
-rw-r--r-- | include/secure_socket.h | 6 | ||||
-rw-r--r-- | src/com-core.c | 4 | ||||
-rw-r--r-- | src/com-core_thread.c | 4 | ||||
-rw-r--r-- | src/secure_socket.c | 14 |
4 files changed, 20 insertions, 8 deletions
diff --git a/include/secure_socket.h b/include/secure_socket.h index 8c9d76b..64f1aca 100644 --- a/include/secure_socket.h +++ b/include/secure_socket.h @@ -86,7 +86,8 @@ extern int secure_socket_get_connection_handle(int server_handle); * \retval * \sa */ -extern int secure_socket_send(int conn, const char *buffer, int size, int fd); +extern int secure_socket_send(int conn, const char *buffer, int size); +extern int secure_socket_send_with_fd(int handle, const char *buffer, int size, int fd); /*! * \brief Recv data from the connected peer. and its PID value @@ -101,7 +102,8 @@ extern int secure_socket_send(int conn, const char *buffer, int size, int fd); * \retval * \sa */ -extern int secure_socket_recv(int conn, char *buffer, int size, int *sender_pid, int *fd); +extern int secure_socket_recv(int conn, char *buffer, int size, int *sender_pid); +extern int secure_socket_recv_with_fd(int conn, char *buffer, int size, int *sender_pid, int *fd); /*! * \brief Destroy a connection diff --git a/src/com-core.c b/src/com-core.c index bf627e6..208b564 100644 --- a/src/com-core.c +++ b/src/com-core.c @@ -535,7 +535,7 @@ EAPI int com_core_recv_with_fd(int handle, char *buffer, int size, int *sender_p return -EINVAL; } - ret = secure_socket_recv(handle, buffer + readsize, size, sender_pid, recv_fd); + ret = secure_socket_recv_with_fd(handle, buffer + readsize, size, sender_pid, recv_fd); if (ret < 0) { if (ret == -EAGAIN) { DbgPrint("Retry to get data (%d:%d)\n", readsize, size); @@ -606,7 +606,7 @@ EAPI int com_core_send_with_fd(int handle, const char *buffer, int size, double return -EINVAL; } - ret = secure_socket_send(handle, buffer + writesize, size, fd); + ret = secure_socket_send_with_fd(handle, buffer + writesize, size, fd); if (ret < 0) { if (ret == -EAGAIN) { DbgPrint("Retry to send data (%d:%d)\n", writesize, size); diff --git a/src/com-core_thread.c b/src/com-core_thread.c index 4e186b5..38c5a12 100644 --- a/src/com-core_thread.c +++ b/src/com-core_thread.c @@ -404,7 +404,7 @@ static void *client_cb(void *data) break; } - ret = secure_socket_recv(tcb->handle, chunk->data, chunk->size, &chunk->pid, &chunk->fd); + ret = secure_socket_recv_with_fd(tcb->handle, chunk->data, chunk->size, &chunk->pid, &chunk->fd); if (ret <= 0) { destroy_chunk(chunk); if (ret == -EAGAIN) { @@ -904,7 +904,7 @@ EAPI int com_core_thread_send_with_fd(int handle, const char *buffer, int size, return -EINVAL; } - ret = secure_socket_send(tcb->handle, buffer + writesize, size, fd); + ret = secure_socket_send_with_fd(tcb->handle, buffer + writesize, size, fd); if (ret < 0) { if (ret == -EAGAIN) { DbgPrint("Retry to send data (%d:%d)\n", writesize, size); diff --git a/src/secure_socket.c b/src/secure_socket.c index a1f69eb..a299b50 100644 --- a/src/secure_socket.c +++ b/src/secure_socket.c @@ -418,7 +418,7 @@ EAPI int secure_socket_get_connection_handle(int server_handle) return handle; } -EAPI int secure_socket_send(int handle, const char *buffer, int size, int fd) +EAPI int secure_socket_send_with_fd(int handle, const char *buffer, int size, int fd) { struct msghdr msg; struct iovec iov; @@ -470,7 +470,12 @@ EAPI int secure_socket_send(int handle, const char *buffer, int size, int fd) return iov.iov_len; } -EAPI int secure_socket_recv(int handle, char *buffer, int size, int *sender_pid, int *fd) +EAPI int secure_socket_send(int handle, const char *buffer, int size) +{ + return secure_socket_send_with_fd(handle, buffer, size, -1); +} + +EAPI int secure_socket_recv_with_fd(int handle, char *buffer, int size, int *sender_pid, int *fd) { struct msghdr msg; struct cmsghdr *cmsg; @@ -533,6 +538,11 @@ EAPI int secure_socket_recv(int handle, char *buffer, int size, int *sender_pid, return iov.iov_len; } +EAPI int secure_socket_recv(int handle, char *buffer, int size, int *sender_pid) +{ + return secure_socket_recv_with_fd(handle, buffer, size, sender_pid, NULL); +} + EAPI int secure_socket_destroy_handle(int handle) { if (close(handle) < 0) { |