summaryrefslogtreecommitdiff
path: root/code/core/rbuf.c
diff options
context:
space:
mode:
Diffstat (limited to 'code/core/rbuf.c')
-rw-r--r--code/core/rbuf.c39
1 files changed, 18 insertions, 21 deletions
diff --git a/code/core/rbuf.c b/code/core/rbuf.c
index 93d6fc6..67c9f8d 100644
--- a/code/core/rbuf.c
+++ b/code/core/rbuf.c
@@ -68,35 +68,32 @@ ssize_t ecp_rbuf_pld_send(ECPConnection *conn, unsigned char *payload, size_t pa
return rv;
}
-int ecp_rbuf_conn_create(ECPConnection *conn, ECPRBSend *buf_s, ECPRBMessage *msg_s, unsigned int msg_s_size, ECPRBRecv *buf_r, ECPRBMessage *msg_r, unsigned int msg_r_size) {
+int ecp_rbuf_create(ECPConnection *conn, ECPRBSend *buf_s, ECPRBMessage *msg_s, unsigned int msg_s_size, ECPRBRecv *buf_r, ECPRBMessage *msg_r, unsigned int msg_r_size) {
int rv;
- rv = ecp_rbuf_send_create(conn, buf_s, msg_s, msg_s_size);
- if (rv) return rv;
+ if (buf_s) {
+ rv = ecp_rbuf_send_create(conn, buf_s, msg_s, msg_s_size);
+ if (rv) return rv;
+
+ rv = ecp_rbuf_send_start(conn);
+ if (rv) {
+ ecp_rbuf_send_destroy(conn);
+ return rv;
+ }
+ }
- rv = ecp_rbuf_recv_create(conn, buf_r, msg_r, msg_r_size);
- if (rv) {
- ecp_rbuf_send_destroy(conn);
- return rv;
+ if (buf_r) {
+ rv = ecp_rbuf_recv_create(conn, buf_r, msg_r, msg_r_size);
+ if (rv) {
+ if (buf_s) ecp_rbuf_send_destroy(conn);
+ return rv;
+ }
}
return ECP_OK;
}
-void ecp_rbuf_conn_destroy(ECPConnection *conn) {
+void ecp_rbuf_destroy(ECPConnection *conn) {
ecp_rbuf_send_destroy(conn);
ecp_rbuf_recv_destroy(conn);
}
-
-int ecp_rbuf_conn_start(ECPConnection *conn, ecp_seq_t seq) {
- int rv = ecp_rbuf_send_start(conn);
- if (rv) return rv;
-
- if (!conn->out) {
- rv = ecp_rbuf_recv_start(conn, seq);
- if (rv) return rv;
- }
-
- return ECP_OK;
-}
-