93 #define RING_TO_MULTI_HEAD(p) RING_TO_APPL((p), SCACHE_MULTI_HEAD, ring)
106 #define RING_TO_MULTI_DEST(p) RING_TO_APPL((p), SCACHE_MULTI_DEST, ring)
108 static void scache_multi_expire_dest(
int,
void *);
121 #define RING_TO_MULTI_ENDP(p) RING_TO_APPL((p), SCACHE_MULTI_ENDP, ring)
123 static void scache_multi_expire_endp(
int,
void *);
138 const char *myname =
"scache_multi_drop_endp";
142 msg_info(
"%s: endp_prop=%s fd=%d", myname,
164 if (endp->
fd >= 0 && close(endp->
fd) != 0)
165 msg_warn(
"%s: close(%d): %m", myname, endp->
fd);
173 static void scache_multi_expire_endp(
int unused_event,
void *context)
182 static void scache_multi_free_endp(
void *ptr)
194 scache_multi_drop_endp(endp,
TOP_DOWN);
201 static void scache_multi_save_endp(
SCACHE *scache,
int ttl,
202 const char *endp_label,
203 const char *endp_prop,
int fd)
205 const char *myname =
"scache_multi_save_endp";
211 msg_panic(
"%s: bad ttl: %d", myname, ttl);
242 msg_info(
"%s: endp_label=%s -> endp_prop=%s fd=%d",
243 myname, endp_label, endp_prop, fd);
248 static int scache_multi_find_endp(
SCACHE *scache,
const char *endp_label,
251 const char *myname =
"scache_multi_find_endp";
264 msg_info(
"%s: no endpoint cache: endp_label=%s",
279 msg_info(
"%s: found: endp_label=%s -> endp_prop=%s fd=%d",
280 myname, endp_label, endp->
endp_prop, fd);
285 msg_info(
"%s: not found: endp_label=%s", myname, endp_label);
293 const char *myname =
"scache_multi_drop_dest";
297 msg_info(
"%s: dest_prop=%s endp_label=%s",
326 static void scache_multi_expire_dest(
int unused_event,
void *context)
335 static void scache_multi_free_dest(
void *ptr)
347 scache_multi_drop_dest(dest,
TOP_DOWN);
354 static void scache_multi_save_dest(
SCACHE *scache,
int ttl,
355 const char *dest_label,
356 const char *dest_prop,
357 const char *endp_label)
359 const char *myname =
"scache_multi_save_dest";
367 msg_panic(
"%s: bad ttl: %d", myname, ttl);
388 && strcmp(dest->
dest_prop, dest_prop) == 0) {
407 msg_info(
"%s: dest_label=%s -> dest_prop=%s endp_label=%s%s",
408 myname, dest_label, dest_prop, endp_label,
409 refresh ?
" (refreshed)" :
"");
414 static int scache_multi_find_dest(
SCACHE *scache,
const char *dest_label,
418 const char *myname =
"scache_multi_find_dest";
431 msg_info(
"%s: no destination cache: dest_label=%s",
441 fd = scache_multi_find_endp(scache, dest->
endp_label, endp_prop);
448 msg_info(
"%s: not found: dest_label=%s", myname, dest_label);
465 static void scache_multi_free(
SCACHE *scache)
void htable_free(HTABLE *table, void(*free_fn)(void *))
void ring_detach(RING *entry)
char * mystrdup(const char *str)
void(* size)(struct SCACHE *, SCACHE_SIZE *)
NORETURN msg_panic(const char *fmt,...)
void ring_init(RING *ring)
SCACHE_FIND_DEST_FN find_dest
VSTRING * vstring_strcpy(VSTRING *vp, const char *src)
HTABLE * htable_create(ssize_t size)
SCACHE * scache_multi_create(void)
#define RING_TO_MULTI_ENDP(p)
#define RING_FOREACH(entry, head)
void msg_warn(const char *fmt,...)
void * htable_find(HTABLE *table, const char *key)
SCACHE_SAVE_ENDP_FN save_endp
SCACHE_SAVE_DEST_FN save_dest
SCACHE_FIND_ENDP_FN find_endp
time_t event_request_timer(EVENT_NOTIFY_TIME_FN callback, void *context, int delay)
void(* free)(struct SCACHE *)
#define RING_TO_MULTI_DEST(p)
void htable_delete(HTABLE *table, const char *key, void(*free_fn)(void *))
int event_cancel_timer(EVENT_NOTIFY_TIME_FN callback, void *context)
void * mymalloc(ssize_t len)
HTABLE_INFO * htable_enter(HTABLE *table, const char *key, void *value)
void msg_info(const char *fmt,...)
void ring_prepend(RING *ring, RING *entry)