summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/irmd/irm_flow.c19
-rw-r--r--src/irmd/main.c27
-rw-r--r--src/irmd/proc_table.c12
3 files changed, 25 insertions, 33 deletions
diff --git a/src/irmd/irm_flow.c b/src/irmd/irm_flow.c
index 8bdda86b..44d3fb7e 100644
--- a/src/irmd/irm_flow.c
+++ b/src/irmd/irm_flow.c
@@ -176,23 +176,16 @@ void irm_flow_set_state(struct irm_flow * f,
int irm_flow_wait_state(struct irm_flow * f,
enum flow_state state,
- struct timespec * timeo)
+ struct timespec * dl)
{
int ret = 0;
int s;
- struct timespec dl;
-
assert(f);
assert(state != FLOW_NULL);
assert(state != FLOW_DESTROY);
assert(state != FLOW_DEALLOC_PENDING);
- if (timeo != NULL) {
- clock_gettime(PTHREAD_COND_CLOCK, &dl);
- ts_add(&dl, timeo, &dl);
- }
-
pthread_mutex_lock(&f->state_lock);
assert(f->state != FLOW_NULL);
@@ -203,13 +196,13 @@ int irm_flow_wait_state(struct irm_flow * f,
f->state == FLOW_DESTROY ||
f->state == FLOW_DEALLOC_PENDING) &&
ret != -ETIMEDOUT) {
- if (timeo == NULL)
- ret = -pthread_cond_wait(&f->state_cond,
- &f->state_lock);
- else
+ if (dl != NULL)
ret = -pthread_cond_timedwait(&f->state_cond,
&f->state_lock,
- &dl);
+ dl);
+ else
+ ret = -pthread_cond_wait(&f->state_cond,
+ &f->state_lock);
}
if (f->state == FLOW_DESTROY ||
diff --git a/src/irmd/main.c b/src/irmd/main.c
index 5ef9a82e..e8a73aa0 100644
--- a/src/irmd/main.c
+++ b/src/irmd/main.c
@@ -1275,7 +1275,7 @@ static int proc_announce(pid_t pid,
}
static int flow_accept(pid_t pid,
- struct timespec * timeo,
+ struct timespec * dl,
struct irm_flow * f_out,
const void * data,
size_t len)
@@ -1312,7 +1312,7 @@ static int flow_accept(pid_t pid,
pthread_rwlock_unlock(&irmd.reg_lock);
- ret = proc_entry_sleep(pe, timeo);
+ ret = proc_entry_sleep(pe, dl);
if (ret == -ETIMEDOUT)
return -ETIMEDOUT;
@@ -1418,7 +1418,7 @@ static int flow_accept(pid_t pid,
static int flow_join(pid_t pid,
const char * dst,
qosspec_t qs,
- struct timespec * timeo,
+ struct timespec * dl,
struct irm_flow * f_out)
{
struct irm_flow * f;
@@ -1476,7 +1476,7 @@ static int flow_join(pid_t pid,
free(hash);
- state = irm_flow_wait_state(f, FLOW_ALLOCATED, timeo);
+ state = irm_flow_wait_state(f, FLOW_ALLOCATED, dl);
if (state != FLOW_ALLOCATED) {
if (state == -ETIMEDOUT) {
log_dbg("Flow allocation timed out");
@@ -1510,7 +1510,7 @@ static int flow_join(pid_t pid,
static int flow_alloc(pid_t pid,
const char * dst,
qosspec_t qs,
- struct timespec * timeo,
+ struct timespec * dl,
struct irm_flow * f_out,
const void * data,
size_t len)
@@ -1570,7 +1570,7 @@ static int flow_alloc(pid_t pid,
free(hash);
- state = irm_flow_wait_state(f, FLOW_ALLOCATED, timeo);
+ state = irm_flow_wait_state(f, FLOW_ALLOCATED, dl);
if (state != FLOW_ALLOCATED) {
if (state == -ETIMEDOUT) {
log_dbg("Flow allocation timed out");
@@ -2075,7 +2075,7 @@ static void * mainloop(void * o)
irm_msg_t * ret_msg;
struct irm_flow e;
struct ipcp_config conf;
- struct timespec * timeo = NULL;
+ struct timespec * dl = NULL;
struct timespec ts = {0, 0};
struct cmd * cmd;
int result;
@@ -2119,11 +2119,16 @@ static void * mainloop(void * o)
tpm_dec(irmd.tpm);
if (msg->has_timeo_sec) {
+ struct timespec now;
+ clock_gettime(PTHREAD_COND_CLOCK, &now);
assert(msg->has_timeo_nsec);
ts.tv_sec = msg->timeo_sec;
ts.tv_nsec = msg->timeo_nsec;
- timeo = &ts;
+
+ ts_add(&ts, &now, &ts);
+
+ dl = &ts;
}
pthread_cleanup_push(__cleanup_close_ptr, &sfd);
@@ -2195,7 +2200,7 @@ static void * mainloop(void * o)
case IRM_MSG_CODE__IRM_FLOW_ACCEPT:
assert(msg->pk.len > 0 ? msg->pk.data != NULL
: msg->pk.data == NULL);
- result = flow_accept(msg->pid, timeo, &e,
+ result = flow_accept(msg->pid, dl, &e,
msg->pk.data, msg->pk.len);
if (result == 0) {
ret_msg->has_flow_id = true;
@@ -2215,7 +2220,7 @@ static void * mainloop(void * o)
: msg->pk.data == NULL);
result = flow_alloc(msg->pid, msg->dst,
qos_spec_msg_to_s(msg->qosspec),
- timeo, &e, msg->pk.data,
+ dl, &e, msg->pk.data,
msg->pk.len);
if (result == 0) {
ret_msg->has_flow_id = true;
@@ -2233,7 +2238,7 @@ static void * mainloop(void * o)
assert(msg->pk.len == 0 && msg->pk.data == NULL);
result = flow_join(msg->pid, msg->dst,
qos_spec_msg_to_s(msg->qosspec),
- timeo, &e);
+ dl, &e);
if (result == 0) {
ret_msg->has_flow_id = true;
ret_msg->flow_id = e.flow_id;
diff --git a/src/irmd/proc_table.c b/src/irmd/proc_table.c
index 8a25831a..ee87813d 100644
--- a/src/irmd/proc_table.c
+++ b/src/irmd/proc_table.c
@@ -184,19 +184,13 @@ void proc_entry_del_name(struct proc_entry * e,
}
int proc_entry_sleep(struct proc_entry * e,
- struct timespec * timeo)
+ struct timespec * dl)
{
- struct timespec dl;
int ret = 0;
assert(e);
- if (timeo != NULL) {
- clock_gettime(PTHREAD_COND_CLOCK, &dl);
- ts_add(&dl, timeo, &dl);
- }
-
pthread_mutex_lock(&e->lock);
if (e->state != PROC_WAKE && e->state != PROC_DESTROY)
@@ -205,8 +199,8 @@ int proc_entry_sleep(struct proc_entry * e,
pthread_cleanup_push(cancel_proc_entry, e);
while (e->state == PROC_SLEEP && ret != -ETIMEDOUT)
- if (timeo)
- ret = -pthread_cond_timedwait(&e->cond, &e->lock, &dl);
+ if (dl != NULL)
+ ret = -pthread_cond_timedwait(&e->cond, &e->lock, dl);
else
ret = -pthread_cond_wait(&e->cond, &e->lock);