--- mqtt/inc/mqttd.h 2012/04/11 16:37:16 1.2.2.4 +++ mqtt/inc/mqttd.h 2012/06/26 08:05:58 1.2.2.13 @@ -2,8 +2,11 @@ #define __MQTTD_H +#define API_SERVER_SIDE +#include + + struct tagStore { - char st_qos; u_short st_msgid; mqtt_subscr_t st_subscr; @@ -12,9 +15,6 @@ struct tagStore { }; struct tagSession { - /* client session thread id */ - pthread_t sess_tid; - pthread_mutex_t sess_mtx; /* server dispatcher */ mqtt_srv_t *sess_srv; @@ -42,23 +42,21 @@ struct tagSession { char *msg; } sess_will; - /* Data Storage by QoS class */ - SLIST_HEAD(tStore, tagStore) sess_txque[3]; + /* session subscriptions & send pubs */ + SLIST_HEAD(tStore, tagStore) sess_subscr; + TAILQ_ENTRY(tagSession) sess_node; }; typedef TAILQ_HEAD(, tagSession) sessions_t; -#define SESS_ELEM_LOCK(x) pthread_mutex_lock(&(x)->sess_mtx) -#define SESS_ELEM_UNLOCK(x) pthread_mutex_unlock(&(x)->sess_mtx) extern sessions_t Sessions; extern sched_root_task_t *root; extern cfg_root_t cfg; -extern pthread_mutex_t mtx_sess, mtx_pub; -#define SESS_LOCK pthread_mutex_lock(&mtx_sess) -#define SESS_UNLOCK pthread_mutex_unlock(&mtx_sess) -#define PUB_LOCK pthread_mutex_lock(&mtx_pub) -#define PUB_UNLOCK pthread_mutex_unlock(&mtx_pub) + + +/* function prototypes */ +void *startSession(sched_task_t *task); #endif