aboutsummaryrefslogtreecommitdiffstats
path: root/glougloud
diff options
context:
space:
mode:
authorLaurent Ghigonis <laurent@p1sec.com>2012-07-22 04:10:00 +0200
committerLaurent Ghigonis <laurent@p1sec.com>2012-07-22 04:10:00 +0200
commita6b51c44b8d52fa159c4dc073c9dafbc4baa18f2 (patch)
treee773d07173643eeb48706d788158564cf11c0884 /glougloud
parentfatal() messages are now prefixed by "fatal:" (diff)
downloadglouglou-a6b51c44b8d52fa159c4dc073c9dafbc4baa18f2.tar.xz
glouglou-a6b51c44b8d52fa159c4dc073c9dafbc4baa18f2.zip
when going through a LIST and removing elements in the loop, you need to
use LIST_FOREACH_SAFE !
Diffstat (limited to 'glougloud')
-rw-r--r--glougloud/server.c4
-rw-r--r--glougloud/user.c11
2 files changed, 8 insertions, 7 deletions
diff --git a/glougloud/server.c b/glougloud/server.c
index 3446f6e..4fb0be6 100644
--- a/glougloud/server.c
+++ b/glougloud/server.c
@@ -216,12 +216,12 @@ receive(int fd, short why, void *data)
static void
ev_usrtimer(int fd, short why, void *data)
{
- struct user *usr;
+ struct user *usr, *usrtmp;
struct imsg_srvconn req;
srv->time = time(NULL);
- LIST_FOREACH(usr, &usr_list, entry) {
+ LIST_FOREACH_SAFE(usr, &usr_list, entry, usrtmp) {
if (srv->time > usr->lastseen + USER_TIMEOUT) {
addrcpy(&req.addr, &usr->addr);
req.deco = 1;
diff --git a/glougloud/user.c b/glougloud/user.c
index 998f666..3ed52f4 100644
--- a/glougloud/user.c
+++ b/glougloud/user.c
@@ -2,7 +2,6 @@
#include <sys/socket.h>
#include <sys/param.h>
#include <sys/time.h>
-#include <sys/queue.h>
#if !defined(__OpenBSD__)
#define __FAVOR_BSD
@@ -512,6 +511,8 @@ conn_del(struct conn *c)
p.delconn_id = c->id;
sendto_all(&p, PACKET_DELCONN_SIZE);
+ if (cap->conn_freeids_ptr == 0)
+ fatal("cap->conn_freeids_ptr == 0");
cap->conn_freeids_ptr--;
cap->conn_freeids[cap->conn_freeids_ptr] = c->id;
@@ -656,15 +657,15 @@ ev_pcap(int fd, short why, void *data)
static void
ev_timer(int fd, short why, void *data)
{
- struct conn *c;
- struct node *n;
+ struct conn *c, *ctmp;
+ struct node *n, *ntmp;
int i, to;
log_debug("ev_timer");
cap->time = time(NULL);
i = 0;
- LIST_FOREACH(c, &cap->conn_list, entry) {
+ LIST_FOREACH_SAFE(c, &cap->conn_list, entry, ctmp) {
switch (c->proto) {
case IPPROTO_UDP:
to = CONN_TIMEOUT_UDP;
@@ -683,7 +684,7 @@ ev_timer(int fd, short why, void *data)
}
if (cap->node_count > NODE_MAX_WITHOUT_TIMEOUT) {
- LIST_FOREACH(n, &cap->node_list, entry) {
+ LIST_FOREACH_SAFE(n, &cap->node_list, entry, ntmp) {
if (n->used == 0 &&
cap->time > n->lastseen + NODE_TIMEOUT)
node_del(n);