Переглянути джерело

vccd: i decide to release vccd 1.2.0

intirain 4 роки тому
батько
коміт
dbddbd46ec
5 змінених файлів з 16 додано та 20 видалено
  1. 3 3
      Makefile
  2. 1 1
      include/vcc/vccd.h
  3. 2 2
      include/vcc/version.h
  4. 9 11
      main.c
  5. 1 3
      vcc.c

+ 3 - 3
Makefile

@@ -1,7 +1,7 @@
 VCCD_MAJOR 		= 1
-VCCD_MINOR 		= 1
-VCCD_PATCH 		= 2
-VCCD_STR 		= -beta 
+VCCD_MINOR 		= 2
+VCCD_PATCH 		= 0
+VCCD_STR 		= -release 
 
 VCCD_COMPILE_TIME 	= $(shell date)
 VCCD_COMPILE_BY 	= $(shell whoami)

+ 1 - 1
include/vcc/vccd.h

@@ -35,7 +35,7 @@ int vcc_new_connection(int fd, struct in_addr *addr);
 int vcc_close_connection(int fd);
 
 int vcc_write_packages(int fd);
-int vcc_new_msg(int fd, void *buf, int size);
+int vcc_new_msg(int fd, struct vcc_request *buf);
 int vcc_send_msg(struct klist_node *, void *);
 int vcc_message_broadcast(char *msg, char *usr, int except_fd);
 

+ 2 - 2
include/vcc/version.h

@@ -1,2 +1,2 @@
-#define VCCD_VERSION "vccd 1.1.2 Sat Mar 19 20:30:26 CST 2022 root"
-#define VCCD_SYMVER "vccd 1.1.2 Sat Mar 19 20:30:26 CST 2022 root"
+#define VCCD_VERSION "vccd 1.2.0 Sat Mar 19 20:47:15 CST 2022 root"
+#define VCCD_SYMVER "vccd 1.2.0 Sat Mar 19 20:47:15 CST 2022 root"

+ 9 - 11
main.c

@@ -162,6 +162,12 @@ int main(int argc, const char **argv) {
 
 	nfds_total = 1;
 
+	if (unlikely(!(buf = malloc(REQ_SIZE)))) {
+		vcc_log("*** malloc() failed\n");
+
+		return 1;
+	}
+
 	for (;;) {
 		nfds_ready = poll(fds, nfds_total, -1);
 
@@ -202,14 +208,6 @@ int main(int argc, const char **argv) {
 				continue;
 
 			if (fds[i].revents & POLLIN) {
-				if (!(buf = malloc(REQ_SIZE))) {
-					vcc_log("*** malloc() failed\n");
-
-					break;
-				}
-
-				size = read(fds[i].fd, buf, REQ_SIZE);
-
 				if (!size) {
 					vcc_close_connection(fds[i].fd);
 
@@ -219,9 +217,7 @@ int main(int argc, const char **argv) {
 					continue;
 				}
 
-				vcc_new_msg(fds[i].fd, buf, size);
-
-				free(buf);
+				vcc_new_msg(fds[i].fd, buf);
 
 				fds[i].events = POLLOUT;
 			}
@@ -236,6 +232,8 @@ int main(int argc, const char **argv) {
 		}
 	}
 
+	free(buf);
+
 	return 0;
 }
 

+ 1 - 3
vcc.c

@@ -252,15 +252,13 @@ int send_users(int fd) {
 }
 
 
-int vcc_new_msg(int fd, void *packet, int size) {
+int vcc_new_msg(int fd, struct vcc_request *req) {
 	struct klist_node *n = find_connection(fd);
-	struct vcc_request *req;
 	char *msg;
 
 	if (unlikely(!n)) 
 		return 1;
 
-	req = packet;
 	msg = req->msg;
 
 	if (unlikely(ntohl(req->magic) != VCC_MAGIC)) {