about summary refs log tree commit diff
path: root/ttb.c
diff options
context:
space:
mode:
authorNakidai <nakidai@disroot.org>2025-05-11 17:21:48 +0300
committerNakidai <nakidai@disroot.org>2025-05-11 18:06:13 +0300
commit337ee19afd48f271ec604ae0c442cbe8f3884d03 (patch)
treebd524482334a8e13141f5033577716740629039c /ttb.c
parent8f6cf913110f57e42143e0184bfcc8e2b1fe0ec2 (diff)
downloadttb-337ee19afd48f271ec604ae0c442cbe8f3884d03.tar.gz
ttb-337ee19afd48f271ec604ae0c442cbe8f3884d03.zip
Simplify sending
Since with tcp socket write call will either send whole buffer of return
an error (no probability of partial send) complex sending loop can be
removed and replaced with one write call instead

see: send(2), write(2), signal(7)
Diffstat (limited to 'ttb.c')
-rw-r--r--ttb.c15
1 files changed, 2 insertions, 13 deletions
diff --git a/ttb.c b/ttb.c
index 24c7a42..48e73c5 100644
--- a/ttb.c
+++ b/ttb.c
@@ -102,19 +102,8 @@ after:
 			}
 
 			for (size_t j = 1; j < lengthof(peers); ++j)
-			{
-				if (!peers[j] || i == j)
-					continue;
-				size_t writtenall = 0;
-				while (writtenall < reads)
-				{
-					ssize_t written = write(peers[j], buf + writtenall, reads - writtenall);
-					if (written == -1)
-						break;
-					else
-						writtenall += written;
-				}
-			}
+				if (peers[j] && i != j)
+					write(peers[j], buf, reads);
 		}
 	}
 }