aboutsummaryrefslogtreecommitdiffstats
path: root/FICS/network.c
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2023-12-13 20:00:33 +0100
committerMarkus Uhlin <markus@nifty-networks.net>2023-12-13 20:00:33 +0100
commit7253890eaed0b43f306ec5f85015954fdaedda53 (patch)
treebbcf60036ff7082a7d93d491582607fac8baeece /FICS/network.c
parent0fe88e9419a41d3158869f3c9e98d08e6a84dbee (diff)
Reformatted net_flushme()
Diffstat (limited to 'FICS/network.c')
-rw-r--r--FICS/network.c45
1 files changed, 28 insertions, 17 deletions
diff --git a/FICS/network.c b/FICS/network.c
index be8a8ae..65e34f6 100644
--- a/FICS/network.c
+++ b/FICS/network.c
@@ -113,25 +113,36 @@ PRIVATE int remConnection(int fd)
return 0;
}
-PRIVATE void net_flushme(int which)
+PRIVATE void
+net_flushme(int which)
{
- int sent;
+ int sent;
+
+ if ((sent = send(con[which].outFd, con[which].sndbuf,
+ con[which].sndbufpos, 0)) == -1) {
+ if (errno != EPIPE) { // EPIPE = they've disconnected
+ fprintf(stderr, "FICS: net_flushme(%d) couldn't send, "
+ "errno=%d.\n",
+ which, errno);
+ }
- sent = send(con[which].outFd, con[which].sndbuf, con[which].sndbufpos, 0);
- if (sent == -1) {
- if (errno != EPIPE) /* EPIPE = they've disconnected */
- fprintf(stderr, "FICS: net_flushme(%d) couldn't send, errno=%d.\n", which, errno);
- con[which].sndbufpos = 0;
- } else {
- con[which].sndbufpos -= sent;
- if (con[which].sndbufpos)
- memmove(con[which].sndbuf, con[which].sndbuf + sent, con[which].sndbufpos);
- }
- if (con[which].sndbufsize > MAX_STRING_LENGTH && con[which].sndbufpos < MAX_STRING_LENGTH) {
- /* time to shrink the buffer */
- con[which].sndbuf = rrealloc(con[which].sndbuf, MAX_STRING_LENGTH);
- con[which].sndbufsize = MAX_STRING_LENGTH;
- }
+ con[which].sndbufpos = 0;
+ } else {
+ con[which].sndbufpos -= sent;
+
+ if (con[which].sndbufpos) {
+ memmove(con[which].sndbuf, con[which].sndbuf + sent,
+ con[which].sndbufpos);
+ }
+ }
+
+ if (con[which].sndbufsize > MAX_STRING_LENGTH &&
+ con[which].sndbufpos < MAX_STRING_LENGTH) {
+ // time to shrink the buffer...
+ con[which].sndbuf = rrealloc(con[which].sndbuf,
+ MAX_STRING_LENGTH);
+ con[which].sndbufsize = MAX_STRING_LENGTH;
+ }
}
PRIVATE void