Commit 0eac39a6 authored by Mac Newbold's avatar Mac Newbold

Fix small bug that was causing the cache not to use the full size

available to it.
parent d8252765
...@@ -96,7 +96,6 @@ typedef struct { ...@@ -96,7 +96,6 @@ typedef struct {
int in_addr; int in_addr;
int lastmsg; int lastmsg;
} ec_elt; } ec_elt;
int ec_elt_size = sizeof(ec_elt);
ec_elt evcache[EVENTCACHESIZE]; ec_elt evcache[EVENTCACHESIZE];
ec_elt ec_tmp; ec_elt ec_tmp;
...@@ -125,7 +124,7 @@ int rv; ...@@ -125,7 +124,7 @@ int rv;
/* Some support functions for the event cache */ /* Some support functions for the event cache */
ec_elt* ec_next(ec_elt* ptr) { ec_elt* ec_next(ec_elt* ptr) {
if (ptr < ec_front || ptr > ec_back) { return 0; } if (ptr < ec_front || ptr > ec_back) { return 0; }
ptr += ec_elt_size; ptr += 1;
if (ptr==ec_back) { ptr = ec_front; } if (ptr==ec_back) { ptr = ec_front; }
return ptr; return ptr;
} }
...@@ -133,7 +132,7 @@ ec_elt* ec_next(ec_elt* ptr) { ...@@ -133,7 +132,7 @@ ec_elt* ec_next(ec_elt* ptr) {
ec_elt* ec_prev(ec_elt* ptr) { ec_elt* ec_prev(ec_elt* ptr) {
if (ptr < ec_front || ptr > ec_back) { return 0; } if (ptr < ec_front || ptr > ec_back) { return 0; }
if (ptr==ec_front) { ptr = ec_back; } if (ptr==ec_front) { ptr = ec_back; }
ptr -= ec_elt_size; ptr -= 1;
return ptr; return ptr;
} }
...@@ -370,10 +369,13 @@ main(int argc, char *argv[]) ...@@ -370,10 +369,13 @@ main(int argc, char *argv[])
} }
#endif #endif
#ifdef EVENTSYS #ifdef EVENTSYS
ec_front=&evcache[0]; ec_front=&(evcache[0]);
ec_back=&evcache[EVENTCACHESIZE]; ec_back=&(evcache[EVENTCACHESIZE]);
ec_head=ec_front; ec_head=ec_front;
ec_tail=ec_front; ec_tail=ec_front;
printf("event_cache_front: %u\nevent_cache_back: %u\nhead: %u\nhead-next: %u\nhead-prev: %u\n",
ec_front, ec_back, ec_head, ec_next(ec_head),
ec_prev(ec_head));
#endif #endif
printf("Server started on port %d\n\n", ntohs(server.sin_port)); printf("Server started on port %d\n\n", ntohs(server.sin_port));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment