Prechádzať zdrojové kódy

vccd: fix a small bug

intirain 4 rokov pred
rodič
commit
8618f7f02d
5 zmenil súbory, kde vykonal 8 pridanie a 8 odobranie
  1. 1 1
      Makefile
  2. 2 2
      include/vcc/version.h
  3. 1 3
      session.c
  4. 2 2
      users.c
  5. 2 0
      vcc.c

+ 1 - 1
Makefile

@@ -1,6 +1,6 @@
 VCCD_MAJOR 		= 1
 VCCD_MINOR 		= 6
-VCCD_PATCH 		= 1
+VCCD_PATCH 		= 2
 VCCD_STR 		= -rc 
 
 VCCD_COMPILE_TIME 	= $(shell date)

+ 2 - 2
include/vcc/version.h

@@ -1,2 +1,2 @@
-#define VCCD_VERSION "vccd 1.6.1 Sun Mar 27 15:14:29 CST 2022 root"
-#define VCCD_SEMVER "vccd 1.6.1-rc "
+#define VCCD_VERSION "vccd 1.6.2 Sat Apr  2 20:58:00 CST 2022 root"
+#define VCCD_SEMVER "vccd 1.6.2-rc "

+ 1 - 3
session.c

@@ -145,9 +145,7 @@ int join_session(int sid, int fd) {
 
 	klist_add(session->session, n);
 
-	sprintf(t, join_msg, n->connection->usrname, session->usrname, session->session->nusers);
-	session->session->nusers++;
-
+	sprintf(t, join_msg, n->connection->usrname, session->usrname, ++session->session->nusers);
 	session_broadcast(sid, t, "system", 0);
 
 	vcc_log("%d joined session %d. \n", fd, sid);

+ 2 - 2
users.c

@@ -217,8 +217,8 @@ int do_user_logout(int fd) {
 	write(fdt, usr, sizeof(struct user));
 	vcc_log("Bye, %s. \n", usr->username);
 
-	sprintf(t, leave_msg, usr->username, --nusers);
-	vcc_message_broadcast(t, "system", 0);
+	sprintf(t, leave_msg, usr->username, nusers);
+	vcc_message_broadcast(t, "system", fd);
 
 	klist_del(&logged_users, n);
 

+ 2 - 0
vcc.c

@@ -81,6 +81,8 @@ int vcc_close_connection(int fd) {
 	if (unlikely(!(n = find_connection(fd)))) 
 		return 1;
 
+	nusers--;
+
 	do_user_logout(fd);
 	klist_del(&connections, n);