diff options
Diffstat (limited to 'code/core')
-rw-r--r-- | code/core/msgq.c | 8 | ||||
-rw-r--r-- | code/core/msgq.h | 4 | ||||
-rw-r--r-- | code/core/rbuf_recv.c | 11 | ||||
-rw-r--r-- | code/core/rbuf_send.c | 2 |
4 files changed, 14 insertions, 11 deletions
diff --git a/code/core/msgq.c b/code/core/msgq.c index 743478f..45df608 100644 --- a/code/core/msgq.c +++ b/code/core/msgq.c @@ -21,9 +21,7 @@ static struct timespec *abstime_ts(struct timespec *ts, ecp_cts_t msec) { return ts; } -int ecp_conn_msgq_create(ECPConnection *conn) { - ECPRBRecv *buf = conn->rbuf.recv; - ECPConnMsgQ *msgq = buf ? &buf->msgq : NULL; +int ecp_conn_msgq_create(ECPConnMsgQ *msgq) { int i; int rv; @@ -50,9 +48,7 @@ int ecp_conn_msgq_create(ECPConnection *conn) { return ECP_OK; } -void ecp_conn_msgq_destroy(ECPConnection *conn) { - ECPRBRecv *buf = conn->rbuf.recv; - ECPConnMsgQ *msgq = buf ? &buf->msgq : NULL; +void ecp_conn_msgq_destroy(ECPConnMsgQ *msgq) { int i; if (msgq == NULL) return; diff --git a/code/core/msgq.h b/code/core/msgq.h index dd0b9a8..a98ae18 100644 --- a/code/core/msgq.h +++ b/code/core/msgq.h @@ -16,8 +16,8 @@ typedef struct ECPConnMsgQ { pthread_mutex_t mutex; } ECPConnMsgQ; -int ecp_conn_msgq_create(struct ECPConnection *conn); -void ecp_conn_msgq_destroy(struct ECPConnection *conn); +int ecp_conn_msgq_create(ECPConnMsgQ *msgq); +void ecp_conn_msgq_destroy(ECPConnMsgQ *msgq); int ecp_conn_msgq_start(struct ECPConnection *conn, ecp_seq_t seq); int ecp_conn_msgq_push(struct ECPConnection *conn, ecp_seq_t seq, unsigned char mtype); diff --git a/code/core/rbuf_recv.c b/code/core/rbuf_recv.c index 5b8568e..fc2b6ab 100644 --- a/code/core/rbuf_recv.c +++ b/code/core/rbuf_recv.c @@ -219,7 +219,7 @@ int ecp_rbuf_recv_create(ECPConnection *conn, ECPRBRecv *buf, ECPRBMessage *msg, buf->ack_rate = ACK_RATE; #ifdef ECP_WITH_MSGQ - rv = ecp_conn_msgq_create(conn); + rv = ecp_conn_msgq_create(&buf->msgq); if (rv) return rv; #endif @@ -228,9 +228,14 @@ int ecp_rbuf_recv_create(ECPConnection *conn, ECPRBRecv *buf, ECPRBMessage *msg, } void ecp_rbuf_recv_destroy(ECPConnection *conn) { + ECPRBRecv *buf = conn->rbuf.recv; + + if (buf == NULL) return; #ifdef ECP_WITH_MSGQ - ecp_conn_msgq_destroy(conn); -#endif + ecp_conn_msgq_destroy(&buf->msgq); +#endif + + conn->rbuf.recv = NULL; } int ecp_rbuf_recv_set_hole(ECPConnection *conn, unsigned short hole_max) { diff --git a/code/core/rbuf_send.c b/code/core/rbuf_send.c index 685280d..323596f 100644 --- a/code/core/rbuf_send.c +++ b/code/core/rbuf_send.c @@ -204,6 +204,8 @@ void ecp_rbuf_send_destroy(ECPConnection *conn) { #ifdef ECP_WITH_PTHREAD pthread_mutex_destroy(&buf->mutex); #endif + + conn->rbuf.send = NULL; } int ecp_rbuf_send_set_wsize(ECPConnection *conn, ecp_win_t size) { |