diff options
author | dimitri staessens <dimitri.staessens@intec.ugent.be> | 2016-08-24 17:52:48 +0200 |
---|---|---|
committer | dimitri staessens <dimitri.staessens@intec.ugent.be> | 2016-08-24 18:07:59 +0200 |
commit | 9c0c55198c2406fea6be189e1ec6b3ac3cc565fc (patch) | |
tree | 481e74dbd99131c77e6700c49b84a2554e296d16 /src/ipcpd/ipcp.h | |
parent | b1eba5880803f8981d80ff452a2121407360e3d4 (diff) | |
download | ouroboros-9c0c55198c2406fea6be189e1ec6b3ac3cc565fc.tar.gz ouroboros-9c0c55198c2406fea6be189e1ec6b3ac3cc565fc.zip |
ipcpd: Revised locking
The state lock was reverted to an rwlock to avoid interference of
management functions with the fast path. IPCPs now close without
calling unsafe functions in the signal handler.
Diffstat (limited to 'src/ipcpd/ipcp.h')
-rw-r--r-- | src/ipcpd/ipcp.h | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/src/ipcpd/ipcp.h b/src/ipcpd/ipcp.h index 8b7d4ec9..edaea0fd 100644 --- a/src/ipcpd/ipcp.h +++ b/src/ipcpd/ipcp.h @@ -27,12 +27,14 @@ #include <ouroboros/shared.h> #include <pthread.h> +#include <time.h> #include "ipcp-ops.h" #include "ipcp-data.h" enum ipcp_state { - IPCP_INIT = 0, + IPCP_NULL = 0, + IPCP_INIT, IPCP_PENDING_ENROLL, IPCP_ENROLLED, IPCP_DISCONNECTED, @@ -45,15 +47,27 @@ struct ipcp { int irmd_fd; enum ipcp_state state; - pthread_mutex_t state_lock; + pthread_rwlock_t state_lock; + pthread_mutex_t state_mtx; pthread_cond_t state_cond; }; -struct ipcp * ipcp_instance_create(); -void ipcp_state_change(struct ipcp * ipcp, - enum ipcp_state state); -void * ipcp_main_loop(void * o); -void * ipcp_sdu_loop(void * o); -int ipcp_parse_arg(int argc, char * argv[]); +struct ipcp * ipcp_instance_create(); + +void ipcp_set_state(struct ipcp * ipcp, + enum ipcp_state state); + +enum ipcp_state ipcp_get_state(struct ipcp * ipcp); + +int ipcp_wait_state(struct ipcp * ipcp, + enum ipcp_state state, + const struct timespec * timeout); + +void * ipcp_main_loop(void * o); + +void * ipcp_sdu_loop(void * o); + +int ipcp_parse_arg(int argc, + char * argv[]); #endif |