summaryrefslogtreecommitdiff
path: root/src/lib/crypt.c
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2022-02-23 21:14:26 +0100
committerSander Vrijders <sander@ouroboros.rocks>2022-02-24 17:27:46 +0100
commit9719dbe335af4c6add39d739f78a68040b62d8a3 (patch)
tree071a8141e0dcb1544b441ccc985a691545588b45 /src/lib/crypt.c
parent65820fa84f2b16ee1c9291135a49a75437baeb4e (diff)
downloadouroboros-9719dbe335af4c6add39d739f78a68040b62d8a3.tar.gz
ouroboros-9719dbe335af4c6add39d739f78a68040b62d8a3.zip
lib: Add initial flow liveness monitoring
This adds flow liveness monitoring for flows, with a fixed timeout of 120s. I will make it configurable at flow allocation later on (timeout needs to be communicated to the peer). If one peer dies, or doesn't call any IPC calls (flow_write/flow_read/fevent) it will stop sending keepalives and the other peer's read/writes will error on an -EFLOWDOWN after the timeout expires. Packets without a payload (0 length packets) are interpreted as keepalive packets for the flow. They can be sent from any application, but they will not trigger a message read at the receiver side (0 as a return value on flow_read indicates a previous partial read has completed at exactly the buffer size). Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src/lib/crypt.c')
-rw-r--r--src/lib/crypt.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/lib/crypt.c b/src/lib/crypt.c
index 070f5113..043eae13 100644
--- a/src/lib/crypt.c
+++ b/src/lib/crypt.c
@@ -217,6 +217,9 @@ static int openssl_encrypt(struct flow * f,
in = shm_du_buff_head(sdb);
in_sz = shm_du_buff_tail(sdb) - in;
+ if (in_sz == 0)
+ return 0;
+
if (random_buffer(iv, IVSZ) < 0)
goto fail_iv;