Commit 1847a256 authored by Sebastien Decugis's avatar Sebastien Decugis
Browse files

Force ordering of messages by using only stream 0 for link-local messages --...

Force ordering of messages by using only stream 0 for link-local messages -- avoids issue of DWR arriving before CEA.
parent e51eb2dd
......@@ -1274,9 +1274,9 @@ static int send_simple(struct cnxctx * conn, unsigned char * buf, size_t len)
}
/* Send a message -- this is synchronous -- and we assume it's never called by several threads at the same time, so we don't protect. */
int fd_cnx_send(struct cnxctx * conn, unsigned char * buf, size_t len)
int fd_cnx_send(struct cnxctx * conn, unsigned char * buf, size_t len, int ordered)
{
TRACE_ENTRY("%p %p %zd", conn, buf, len);
TRACE_ENTRY("%p %p %zd %i", conn, buf, len, ordered);
CHECK_PARAMS(conn && (conn->cc_socket > 0) && (! conn->cc_goterror) && buf && len);
......@@ -1291,7 +1291,7 @@ int fd_cnx_send(struct cnxctx * conn, unsigned char * buf, size_t len)
case IPPROTO_SCTP: {
int multistr = 0;
if ((conn->cc_sctp_para.str_out > 1) && ((! conn->cc_tls) || (conn->cc_sctp_para.pairs > 1))) {
if ((!ordered) && (conn->cc_sctp_para.str_out > 1) && ((! conn->cc_tls) || (conn->cc_sctp_para.pairs > 1))) {
/* Update the id of the stream we will send this message on */
conn->cc_sctp_para.next += 1;
conn->cc_sctp_para.next %= (conn->cc_tls ? conn->cc_sctp_para.pairs : conn->cc_sctp_para.str_out);
......
......@@ -323,7 +323,7 @@ int fd_cnx_getendpoints(struct cnxctx * conn, struct fd_list * local
char * fd_cnx_getremoteid(struct cnxctx * conn);
int fd_cnx_receive(struct cnxctx * conn, struct timespec * timeout, unsigned char **buf, size_t * len);
int fd_cnx_recv_setaltfifo(struct cnxctx * conn, struct fifo * alt_fifo); /* send FDEVP_CNX_MSG_RECV event to the fifo list */
int fd_cnx_send(struct cnxctx * conn, unsigned char * buf, size_t len);
int fd_cnx_send(struct cnxctx * conn, unsigned char * buf, size_t len, int ordered);
void fd_cnx_destroy(struct cnxctx * conn);
......
......@@ -39,7 +39,7 @@
static int do_send(struct msg ** msg, struct cnxctx * cnx, uint32_t * hbh, struct sr_list * srl)
{
struct msg_hdr * hdr;
int msg_is_a_req;
int msg_is_a_req, msg_is_appl;
uint8_t * buf;
size_t sz;
int ret;
......@@ -59,6 +59,8 @@ static int do_send(struct msg ** msg, struct cnxctx * cnx, uint32_t * hbh, struc
*hbh = hdr->msg_hbhid + 1;
}
msg_is_appl = fd_msg_is_routable(*msg);
/* Log the message */
if (TRACE_BOOL(FULL)) {
CHECK_FCT_DO( fd_msg_update_length(*msg), /* continue */ );
......@@ -76,7 +78,7 @@ static int do_send(struct msg ** msg, struct cnxctx * cnx, uint32_t * hbh, struc
}
/* Send the message */
CHECK_FCT_DO( ret = fd_cnx_send(cnx, buf, sz), { free(buf); return ret; } );
CHECK_FCT_DO( ret = fd_cnx_send(cnx, buf, sz, !msg_is_appl), { free(buf); return ret; } );
pthread_cleanup_pop(1);
/* Free remaining messages (i.e. answers) */
......
......@@ -672,14 +672,14 @@ int main(int argc, char *argv[])
CHECK( 0, fd_cnx_start_clear(client_side, 0) );
/* Send a message and receive it */
CHECK( 0, fd_cnx_send(server_side, cer_buf, cer_sz));
CHECK( 0, fd_cnx_send(server_side, cer_buf, cer_sz, 0));
CHECK( 0, fd_cnx_receive(client_side, NULL, &rcv_buf, &rcv_sz));
CHECK( cer_sz, rcv_sz );
CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
free(rcv_buf);
/* Do it in the other direction */
CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz));
CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz, 0));
CHECK( 0, fd_cnx_receive(server_side, NULL, &rcv_buf, &rcv_sz));
CHECK( cer_sz, rcv_sz );
CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
......@@ -712,7 +712,7 @@ int main(int argc, char *argv[])
CHECK( 0, fd_cnx_start_clear(server_side, 1) );
/* Send a message and receive it */
CHECK( 0, fd_cnx_send(server_side, cer_buf, cer_sz));
CHECK( 0, fd_cnx_send(server_side, cer_buf, cer_sz, 0));
CHECK( EINVAL, fd_cnx_receive(client_side, NULL, &rcv_buf, &rcv_sz));
CHECK( 0, fd_cnx_start_clear(client_side, 0) );
CHECK( 0, fd_cnx_receive(client_side, NULL, &rcv_buf, &rcv_sz));
......@@ -721,14 +721,14 @@ int main(int argc, char *argv[])
free(rcv_buf);
/* Do it in the other direction */
CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz));
CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz, 0));
CHECK( 0, fd_cnx_receive(server_side, NULL, &rcv_buf, &rcv_sz));
CHECK( cer_sz, rcv_sz );
CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
free(rcv_buf);
/* Do it one more time to use another stream */
CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz));
CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz, 0));
CHECK( 0, fd_cnx_receive(server_side, NULL, &rcv_buf, &rcv_sz));
CHECK( cer_sz, rcv_sz );
CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
......@@ -778,14 +778,14 @@ int main(int argc, char *argv[])
CHECK( 0, fd_cnx_start_clear(client_side, 0) );
/* Send a message and receive it */
CHECK( 0, fd_cnx_send(server_side, cer_buf, cer_sz));
CHECK( 0, fd_cnx_send(server_side, cer_buf, cer_sz, 0));
CHECK( 0, fd_cnx_receive(client_side, NULL, &rcv_buf, &rcv_sz));
CHECK( cer_sz, rcv_sz );
CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
free(rcv_buf);
/* And the supposed reply */
CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz));
CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz, 0));
CHECK( 0, fd_cnx_receive(server_side, NULL, &rcv_buf, &rcv_sz));
CHECK( cer_sz, rcv_sz );
CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
......@@ -799,13 +799,13 @@ int main(int argc, char *argv[])
/* Send a few TLS protected message, and replies */
for (i = 0; i < 2 * NB_STREAMS; i++) {
CHECK( 0, fd_cnx_send(server_side, cer_buf, cer_sz));
CHECK( 0, fd_cnx_send(server_side, cer_buf, cer_sz, 0));
CHECK( 0, fd_cnx_receive(client_side, NULL, &rcv_buf, &rcv_sz));
CHECK( cer_sz, rcv_sz );
CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
free(rcv_buf);
CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz));
CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz, 0));
CHECK( 0, fd_cnx_receive(server_side, NULL, &rcv_buf, &rcv_sz));
CHECK( cer_sz, rcv_sz );
CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
......@@ -863,14 +863,14 @@ int main(int argc, char *argv[])
CHECK( 0, fd_cnx_start_clear(client_side, 0) );
/* Send a message and receive it */
CHECK( 0, fd_cnx_send(server_side, cer_buf, cer_sz));
CHECK( 0, fd_cnx_send(server_side, cer_buf, cer_sz, 0));
CHECK( 0, fd_cnx_receive(client_side, NULL, &rcv_buf, &rcv_sz));
CHECK( cer_sz, rcv_sz );
CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
free(rcv_buf);
/* And the supposed reply */
CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz));
CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz, 0));
CHECK( 0, fd_cnx_receive(server_side, NULL, &rcv_buf, &rcv_sz));
CHECK( cer_sz, rcv_sz );
CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
......@@ -884,13 +884,13 @@ int main(int argc, char *argv[])
/* Send a few TLS protected message, and replies */
for (i = 0; i < 2 * NB_STREAMS; i++) {
CHECK( 0, fd_cnx_send(server_side, cer_buf, cer_sz));
CHECK( 0, fd_cnx_send(server_side, cer_buf, cer_sz, 0));
CHECK( 0, fd_cnx_receive(client_side, NULL, &rcv_buf, &rcv_sz));
CHECK( cer_sz, rcv_sz );
CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
free(rcv_buf);
CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz));
CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz, 0));
CHECK( 0, fd_cnx_receive(server_side, NULL, &rcv_buf, &rcv_sz));
CHECK( cer_sz, rcv_sz );
CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
......@@ -950,13 +950,13 @@ int main(int argc, char *argv[])
/* Send a few TLS protected message, and replies */
for (i = 0; i < 2 * NB_STREAMS; i++) {
CHECK( 0, fd_cnx_send(server_side, cer_buf, cer_sz));
CHECK( 0, fd_cnx_send(server_side, cer_buf, cer_sz, 0));
CHECK( 0, fd_cnx_receive(client_side, NULL, &rcv_buf, &rcv_sz));
CHECK( cer_sz, rcv_sz );
CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
free(rcv_buf);
CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz));
CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz, 0));
CHECK( 0, fd_cnx_receive(server_side, NULL, &rcv_buf, &rcv_sz));
CHECK( cer_sz, rcv_sz );
CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
......@@ -1015,13 +1015,13 @@ int main(int argc, char *argv[])
/* Send a few TLS protected message, and replies */
for (i = 0; i < 2 * NB_STREAMS; i++) {
CHECK( 0, fd_cnx_send(server_side, cer_buf, cer_sz));
CHECK( 0, fd_cnx_send(server_side, cer_buf, cer_sz, 0));
CHECK( 0, fd_cnx_receive(client_side, NULL, &rcv_buf, &rcv_sz));
CHECK( cer_sz, rcv_sz );
CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
free(rcv_buf);
CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz));
CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz, 0));
CHECK( 0, fd_cnx_receive(server_side, NULL, &rcv_buf, &rcv_sz));
CHECK( cer_sz, rcv_sz );
CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) );
......@@ -1364,7 +1364,7 @@ int main(int argc, char *argv[])
CHECK( 1, (str[0] != '\0') ? 1 : 0 );
/* fd_cnx_recv_setaltfifo */
CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz));
CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz, 0));
CHECK( 0, fd_fifo_new(&myfifo) );
CHECK( 0, fd_cnx_recv_setaltfifo(server_side, myfifo) );
CHECK( 0, clock_gettime(CLOCK_REALTIME, &now) );
......@@ -1482,7 +1482,7 @@ int main(int argc, char *argv[])
CHECK( 1, (str[0] != '\0') ? 1 : 0 );
/* fd_cnx_recv_setaltfifo */
CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz));
CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz, 0));
CHECK( 0, fd_fifo_new(&myfifo) );
CHECK( 0, fd_cnx_recv_setaltfifo(server_side, myfifo) );
CHECK( 0, clock_gettime(CLOCK_REALTIME, &now) );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment