Sfoglia il codice sorgente

vccd: beta test starts, perpare for 1.0 :-)

intirain 4 anni fa
parent
commit
a419c62828
4 ha cambiato i file con 20 aggiunte e 8 eliminazioni
  1. 7 2
      Makefile
  2. 2 1
      include/vcc/version.h
  3. 5 3
      users.c
  4. 6 2
      vcc.c

+ 7 - 2
Makefile

@@ -1,8 +1,11 @@
-VCCD_MAJOR 		= 0
-VCCD_MINOR 		= 4
+VCCD_MAJOR 		= 1
+VCCD_MINOR 		= 0
 VCCD_PATCH 		= 0
+VCCD_STR 		= -alpha
+
 VCCD_COMPILE_TIME 	= $(shell date)
 VCCD_COMPILE_BY 	= $(shell whoami)
+VCCD_SYMVER 		= vccd $(VCCD_MAJOR).$(VCCD_MINOR).$(VCCD_PATCH)$(VCCD_STR)
 
 lib-objs 		= libreadconf/libreadconf.a 
 lib-includes 		= libreadconf/include 
@@ -17,7 +20,9 @@ VCCD_VERSION 		= vccd $(VCCD_MAJOR).$(VCCD_MINOR).$(VCCD_PATCH) \
 
 all : 
 	@echo "$(VCCD_VERSION)"
+	@echo "$(VCCD_SYMVER)"
 	@echo "#define VCCD_VERSION \"$(VCCD_VERSION)\"" > include/vcc/version.h 
+	@echo "#define VCCD_SYMVER \"$(VCCD_VERSION)\"" >> include/vcc/version.h
 	@$(MAKE) libs
 	@$(MAKE) $(target) $(MAKEFLAGS)
 

+ 2 - 1
include/vcc/version.h

@@ -1 +1,2 @@
-#define VCCD_VERSION "vccd 0.4.0 Sat Mar 12 15:40:28 CST 2022 root"
+#define VCCD_VERSION "vccd 1.0.0 Sat Mar 12 20:53:20 CST 2022 root"
+#define VCCD_SYMVER "vccd 1.0.0 Sat Mar 12 20:53:20 CST 2022 root"

+ 5 - 3
users.c

@@ -195,7 +195,7 @@ static int get_users(char *p, int size) {
 int do_user_login(int fd, struct vcc_request *req) {
 	struct vcc_request *out;
 	char right_passwd[MSG_SIZE];
-	const static char join_msg[] = {"%s logged in. now there are %d users. \n"};
+	const static char *join_msg = "%s logged in. now there are %d users. \n";
 	char *t;
 
 	if (unlikely(!(out = malloc(sizeof(struct vcc_request))))) {
@@ -220,14 +220,16 @@ int do_user_login(int fd, struct vcc_request *req) {
 
 	out->uid = htonl(1);
 
-	if (unlikely(!(t = malloc(sizeof(join_msg))))) {
+	if (unlikely(!(t = malloc(128)))) {
 		vcc_log("*** malloc() failed\n");
 
 		return 1;
 	}
 
 	vcc_send_req(find_connection(fd), out);
-	sprintf(t, join_msg, req->usrname, ++nusers);
+
+	/* nusers incs when it connects */
+	sprintf(t, join_msg, req->usrname, nusers);
 
 	vcc_message_broadcast(t, "system", 0);
 

+ 6 - 2
vcc.c

@@ -67,13 +67,17 @@ int vcc_new_connection(int fd, struct in_addr *addr) {
 	klist_init(n->sending);	
 	klist_add(&connections, n);
 
+	/* if we kill vcc before it logs in, the nusers will dec but it 
+	 * didn't login the value will be something bad. */
+
+	nusers++;
+
 	return 0;
 }
 
-
 int vcc_close_connection(int fd) {
 	struct klist_node *n, *t;
-	const static char leave_msg[] = {"An user left, now there are only %d users here. \n"};
+	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