|
|
@@ -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);
|