3131#include "network.h"
3232#include "trie.h"
3333#include "uthash.h"
34- #include <stdatomic.h>
3534#include <time.h>
3635
3736/* Generic return codes without a defined purpose */
@@ -174,22 +173,21 @@ struct client {
174173 * ctx ; /* An event context refrence mostly used to fire write events */
175174 int rc ; /* Return code of the message just handled */
176175 int status ; /* Current status of the client (state machine) */
177- volatile atomic_int rpos ; /* The nr of bytes to skip after a complete
178- * packet has * been read. This because according
179- * to MQTT, length is encoded on multiple bytes
180- * according to it's size, using continuation bit
181- * as a technique to encode it. We don't want to
182- * decode the length two times when we already
183- * know it, so we need an offset to know where
184- * the actual packet will start
185- */
186- volatile atomic_size_t read ; /* The number of bytes already read */
187- volatile atomic_size_t
188- toread ; /* The number of bytes that have to be read */
189- unsigned char * rbuf ; /* The reading buffer */
190- volatile atomic_size_t wrote ; /* The number of bytes already written */
191- volatile atomic_size_t towrite ; /* The number of bytes we have to write */
192- unsigned char * wbuf ; /* The writing buffer */
176+ int rpos ; /* The nr of bytes to skip after a complete
177+ * packet has * been read. This because for
178+ * MQTT, length is encoded on multiple bytes
179+ * according to it's size, using a continuation bit
180+ * as a technique to encode it. We don't want to
181+ * decode the length two times when we already
182+ * know it, so we need an offset to know where
183+ * the actual packet will start
184+ */
185+ size_t read ; /* The number of bytes already read */
186+ size_t toread ; /* The number of bytes that have to be read */
187+ unsigned char * rbuf ; /* The reading buffer */
188+ size_t wrote ; /* The number of bytes already written */
189+ size_t towrite ; /* The number of bytes we have to write */
190+ unsigned char * wbuf ; /* The writing buffer */
193191 char client_id [MQTT_CLIENT_ID_LEN ]; /* The client ID according to MQTT specs
194192 */
195193 struct connection conn ; /* A connection structure, takes care of plain or
@@ -201,11 +199,9 @@ struct client {
201199 bool connected ; /* States if the client has already processed a connection
202200 packet */
203201 bool has_lwt ; /* States if the connection packet carried a LWT message */
204- bool clean_session ; /* States if the connection packet was set to clean
205- session */
206- pthread_mutex_t mutex ; /* Inner lock for the client, this avoid
207- race-conditions on shared parts */
208- UT_hash_handle hh ; /* UTHASH handle, needed to use UTHASH macros */
202+ bool clean_session ; /* States if the connection packet was set to clean
203+ session */
204+ UT_hash_handle hh ; /* UTHASH handle, needed to use UTHASH macros */
209205};
210206
211207/*
@@ -226,9 +222,9 @@ struct client_session {
226222 structs */
227223 List * outgoing_msgs ; /* Outgoing messages during disconnection time, stored
228224 as mqtt_packet pointers */
229- volatile atomic_ushort inflights ; /* Just a counter stating the presence of
230- inflight messages */
231- bool clean_session ; /* Clean session flag */
225+ unsigned short inflights ; /* Just a counter stating the presence of
226+ inflight messages */
227+ bool clean_session ; /* Clean session flag */
232228 char session_id [MQTT_CLIENT_ID_LEN ]; /* The client_id the session refers to
233229 */
234230 struct mqtt_packet
@@ -241,13 +237,6 @@ struct client_session {
241237 refcount ; /* Reference counting struct, to share the struct easily */
242238};
243239
244- /*
245- * Simple mutex for contexted critical areas, mainly used in the handlers
246- * module, in server the only useful use are when creating and deactivating
247- * clients
248- */
249- extern pthread_mutex_t mutex ;
250-
251240struct server ;
252241
253242/*
0 commit comments