summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--blabouncer.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/blabouncer.c b/blabouncer.c
index 23d5217..15b1eb4 100644
--- a/blabouncer.c
+++ b/blabouncer.c
@@ -262,15 +262,12 @@ int sendtoserver(SSL *server_ssl, char *strsrc, int str_len, int clientfd, struc
int disconnectclient(int fd, struct client *clients, struct ircdstrings *ircdstrings, struct settings *settings) {
printf("disconnectclient(): disconnecting client fd '%d'\n", fd);
- // Alert other clients about the disconnection
+ // Alert other clients about the disconnection (don't send yet, we haven't removed from the clients array yet)
char alertmsg[MAXDATASIZE];
if (!snprintf(alertmsg, MAXDATASIZE, "NOTICE %s :blabouncer: client with fd %d has disconnected.", ircdstrings->ircnick, fd)) {
fprintf(stderr, "Error while preparing authentication failure NOTICE!\n");
exit(1);
}
- // "except" 0 since we trust this message
- sendtoallclients(clients, alertmsg, 0, settings);
-
// Remove the client from the clients array
for (int i = 0; i < MAXCLIENTS; i++) {
if (clients[i].fd == fd) {
@@ -289,6 +286,8 @@ int disconnectclient(int fd, struct client *clients, struct ircdstrings *ircdstr
SSL_free(clients[i].ssl);
// Close the socket
close(fd);
+ // Now clients array is cleared, inform all other clients (source "0" since we trust this message)
+ sendtoallclients(clients, alertmsg, 0, settings);
return 1;
}
}