summaryrefslogtreecommitdiff
path: root/src/irmd
diff options
context:
space:
mode:
Diffstat (limited to 'src/irmd')
-rw-r--r--src/irmd/main.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/irmd/main.c b/src/irmd/main.c
index 55764941..102d1872 100644
--- a/src/irmd/main.c
+++ b/src/irmd/main.c
@@ -1538,6 +1538,8 @@ void * mainloop()
irm_msg_t ret_msg = IRM_MSG__INIT;
struct irm_flow * e = NULL;
pid_t * apis = NULL;
+ struct timeval tv = {(SOCKET_TIMEOUT / 1000),
+ (SOCKET_TIMEOUT % 1000) * 1000};
pthread_rwlock_rdlock(&irmd->state_lock);
if (irmd->state != IRMD_RUNNING) {
@@ -1552,6 +1554,10 @@ void * mainloop()
if (cli_sockfd < 0)
continue;
+ if (setsockopt(cli_sockfd, SOL_SOCKET, SO_RCVTIMEO,
+ (void *) &tv, sizeof(tv)))
+ LOG_WARN("Failed to set timeout on socket.");
+
count = read(cli_sockfd, buf, IRM_MSG_BUF_SIZE);
if (count <= 0) {
LOG_ERR("Failed to read from socket.");
@@ -1705,7 +1711,7 @@ void * mainloop()
buffer.len = irm_msg__get_packed_size(&ret_msg);
if (buffer.len == 0) {
- LOG_ERR("Failed to send reply message.");
+ LOG_ERR("Failed to calculate length of reply message.");
if (apis != NULL)
free(apis);
close(cli_sockfd);
@@ -1726,7 +1732,7 @@ void * mainloop()
free(apis);
if (write(cli_sockfd, buffer.data, buffer.len) == -1)
- LOG_ERR("Failed to send reply message.");
+ LOG_WARN("Failed to send reply message.");
free(buffer.data);
close(cli_sockfd);
@@ -1797,11 +1803,8 @@ static struct irm * irm_create()
return NULL;
}
- if (setsockopt(irmd->sockfd,
- SOL_SOCKET,
- SO_RCVTIMEO,
- (char *) &timeout,
- sizeof(timeout)) < 0) {
+ if (setsockopt(irmd->sockfd, SOL_SOCKET, SO_RCVTIMEO,
+ (char *) &timeout, sizeof(timeout)) < 0) {
LOG_ERR("Failed setting socket option.");
irm_destroy();
return NULL;