Kaynağa Gözat

vccd: i'm feeling good

intirain 4 yıl önce
ebeveyn
işleme
ae2aee8f49
4 değiştirilmiş dosya ile 9 ekleme ve 7 silme
  1. 1 1
      Makefile
  2. 1 0
      include/vcc/vccd.h
  3. 2 2
      include/vcc/version.h
  4. 5 4
      vcc.c

+ 1 - 1
Makefile

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

+ 1 - 0
include/vcc/vccd.h

@@ -40,6 +40,7 @@ int vcc_send_msg(struct klist_node *, void *);
 int vcc_message_broadcast(char *msg, char *usr, int except_fd);
 
 int do_user_login(int fd, struct vcc_request *buf);
+struct klist_node *find_connection(int fd);
 
 
 #endif

+ 2 - 2
include/vcc/version.h

@@ -1,2 +1,2 @@
-#define VCCD_VERSION "vccd 1.2.2 Sun Mar 20 11:41:39 CST 2022 root"
-#define VCCD_SYMVER "vccd 1.2.2 Sun Mar 20 11:41:39 CST 2022 root"
+#define VCCD_VERSION "vccd 1.2.3 Sun Mar 20 12:03:13 CST 2022 root"
+#define VCCD_SYMVER "vccd 1.2.3 Sun Mar 20 12:03:13 CST 2022 root"

+ 5 - 4
vcc.c

@@ -80,9 +80,10 @@ int vcc_close_connection(int fd) {
 	const static char *leave_msg = "An user left, now there are only %d users here. \n";
 	char *new_msg;
 
-	for (n = connections.next; n != &connections 
-			&& n->value != fd; n = n->next) 
-		;
+	n = find_connection(fd);
+
+	if (unlikely(!n)) 
+		return 1;
 
 	if (unlikely(!(new_msg = malloc(128)))) {
 		vcc_log("*** malloc() failed\n");
@@ -93,7 +94,7 @@ int vcc_close_connection(int fd) {
 	sprintf(new_msg, leave_msg, --nusers);
 	klist_del(&connections, n);
 
-	for (t = n->sending->next; t != n->sending; t = n->next) 
+	for (t = n->sending->next; t != n->sending; t = t->next) 
 		/* it's dangerous here */
 		if (t->data) 
 			free(t->data);