On TCP, requests sent from multiple threads could be theoretically
intermixed.
memset(peer, 0, sizeof(*peer));
fosa_cond_init(&peer->cond);
forb_ref_init(&peer->ref);
+ fosa_mutex_init(&peer->send_lock, 0);
}
return peer;
}
#include "refcnt.h"
#include <ul_gavl.h>
#include <ul_list.h>
-
+#include <fosa_mutexes_and_condvars.h>
/**
* State of a peer.
*
forb_ref_t ref; /**< Reference count */
enum forb_peer_state state;
fosa_cond_t cond; /**< Condition variable for waiting after the peer is discovered. Used together with forb_t::peer_mutex. */
+ fosa_mutex_t send_lock;
} forb_peer_t;
}
len = FORB_CDR_data_size(&req->cdr_request);
+ fosa_mutex_lock(&peer->send_lock);
size = forb_proto_send(peer, &req->cdr_request);
+ fosa_mutex_unlock(&peer->send_lock);
if (size <= 0 || size != len) {
env->major = FORB_EX_COMM_FAILURE;
/* Request is deleted when the stub calls forb_request_destroy() */