diff options
author | Uros Majstorovic <majstor@majstor.org> | 2017-08-16 21:21:33 +0200 |
---|---|---|
committer | Uros Majstorovic <majstor@majstor.org> | 2017-08-16 21:21:33 +0200 |
commit | 8f44e2151cb3f91b220c4a3393a06068d0ee7302 (patch) | |
tree | 8320c304887ac9b0d922bc27b51330c084f34ee0 /code/core/rbuf_send.c | |
parent | 38e2385f5846860916f8880d818b3b024b8c7dd9 (diff) |
fixed rbuf; fixed error code for pthread_mitex_init
Diffstat (limited to 'code/core/rbuf_send.c')
-rw-r--r-- | code/core/rbuf_send.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/code/core/rbuf_send.c b/code/core/rbuf_send.c index 78c60c3..06bd2e2 100644 --- a/code/core/rbuf_send.c +++ b/code/core/rbuf_send.c @@ -7,7 +7,7 @@ static ssize_t _rbuf_send_flush(ECPConnection *conn, ECPTimerItem *ti) { unsigned char payload[ECP_SIZE_PLD(0)]; - ecp_pld_set_type(payload, ECP_MTYPE_RBFLUSH_REQ); + ecp_pld_set_type(payload, ECP_MTYPE_RBFLUSH); return ecp_pld_send(conn, payload, sizeof(payload)); } @@ -50,7 +50,7 @@ static void cc_flush(ECPConnection *conn) { } } -static ssize_t handle_ack(ECPConnection *conn, ecp_seq_t seq, unsigned char mtype, unsigned char *msg, ssize_t size) { +ssize_t ecp_rbuf_handle_ack(ECPConnection *conn, ecp_seq_t seq, unsigned char mtype, unsigned char *msg, ssize_t size) { ECPRBSend *buf; ssize_t rsize = sizeof(ecp_seq_t)+sizeof(ecp_ack_t); ecp_seq_t seq_ack = 0; @@ -158,13 +158,23 @@ int ecp_conn_rbuf_send_create(ECPConnection *conn, ECPRBSend *buf, ECPRBMessage rv = ecp_rbuf_init(&buf->rbuf, msg, msg_size); if (rv) return rv; - conn->rbuf.send = buf; +#ifdef ECP_WITH_PTHREAD + rv = pthread_mutex_init(&buf->mutex, NULL); + if (rv) return ECP_ERR; +#endif + conn->rbuf.send = buf; return ECP_OK; } void ecp_conn_rbuf_send_destroy(ECPConnection *conn) { + ECPRBSend *buf = conn->rbuf.send; + + if (buf == NULL) return; +#ifdef ECP_WITH_PTHREAD + pthread_mutex_destroy(&buf->mutex); +#endif } int ecp_conn_rbuf_send_set_wsize(ECPConnection *conn, ecp_win_t size) { |