|
|
@@ -64,7 +64,7 @@ int vcc_new_connection(int fd, struct in_addr *addr) {
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
- klist_init(n->sending);
|
|
|
+ klist_init(n->sending);
|
|
|
klist_add(&connections, n);
|
|
|
|
|
|
/* if we kill vcc before it logs in, the nusers will dec but it
|
|
|
@@ -117,21 +117,22 @@ struct klist_node *find_connection(int fd) {
|
|
|
|
|
|
|
|
|
int write_packages(struct klist_node *node) {
|
|
|
- void *p;
|
|
|
+ struct klist_node *n;
|
|
|
|
|
|
if (unlikely(!node->sending))
|
|
|
return 0;
|
|
|
|
|
|
if (unlikely(klist_empty(node->sending)))
|
|
|
return 0;
|
|
|
-
|
|
|
- p = node->sending->next->data;
|
|
|
|
|
|
- write(node->value, p, REQ_SIZE);
|
|
|
- afree(p, REQ_SIZE);
|
|
|
-
|
|
|
- klist_del(node->sending, node->sending->next);
|
|
|
+ for (n = node->sending->next; n != node->sending; n = n->next) {
|
|
|
+ write(node->value, n->data, REQ_SIZE);
|
|
|
+ klist_del(node->sending, n);
|
|
|
|
|
|
+ afree(n->data, REQ_SIZE);
|
|
|
+ afree(n, sizeof(struct klist_node));
|
|
|
+ }
|
|
|
+
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
@@ -139,6 +140,15 @@ int vcc_write_packages(int fd) {
|
|
|
return write_packages(find_connection(fd));
|
|
|
}
|
|
|
|
|
|
+int vcc_write_all(void) {
|
|
|
+ struct klist_node *n;
|
|
|
+
|
|
|
+ for (n = connections.next; n != &connections; n = n->next)
|
|
|
+ vcc_write_packages(n->value);
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
int vcc_send_req(struct klist_node *node, void *p) {
|
|
|
struct klist_node *n;
|
|
|
@@ -149,6 +159,8 @@ int vcc_send_req(struct klist_node *node, void *p) {
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
+ klist_init(n);
|
|
|
+
|
|
|
n->data = p;
|
|
|
klist_add(node->sending, n);
|
|
|
|
|
|
@@ -193,6 +205,7 @@ int vcc_message_broadcast(char *msg, char *usrname, int except_fd, int flags) {
|
|
|
i++;
|
|
|
}
|
|
|
|
|
|
+ vcc_write_all();
|
|
|
vcc_log("Message sent to %d users. \n", i);
|
|
|
|
|
|
return 0;
|
|
|
@@ -331,6 +344,8 @@ int vcc_new_msg(int fd, struct vcc_request *req) {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
+ vcc_write_packages(fd);
|
|
|
+
|
|
|
return 0;
|
|
|
}
|
|
|
|