/* Copyright (c) 2009-2018 Dovecot authors, see the included COPYING file */
#include "common.h"
#include "hash.h"
#include "str.h"
#include "strescape.h"
#include "ostream.h"
#include "connect-limit.h"
struct ident_pid {
/* ident string points to ident_hash keys */
const char *ident;
unsigned int refcount;
};
struct connect_limit {
/* ident => unsigned int refcount */
/* struct ident_pid => struct ident_pid */
};
{
}
{
return -1;
return 1;
else
}
{
return limit;
}
{
}
const char *ident)
{
void *value;
return POINTER_CAST_TO(value, unsigned int);
}
const char *ident)
{
char *key;
void *value;
} else {
}
lookup_i.ident = ident;
if (i == NULL) {
i->ident = key;
i->refcount = 1;
} else {
i->refcount++;
}
}
static void
{
char *key;
void *value;
unsigned int new_refcount;
i_panic("connect limit hash tables are inconsistent");
if (new_refcount > 0) {
} else {
}
}
const char *ident)
{
lookup_i.ident = ident;
if (i == NULL) {
i_error("connect limit: disconnection for unknown "
return;
}
if (--i->refcount == 0) {
i_free(i);
}
connect_limit_ident_hash_unref(limit, ident);
}
{
/* this should happen rarely (or never), so this slow implementation
should be fine. */
connect_limit_ident_hash_unref(limit, i->ident);
i_free(i);
}
}
}
{
str_truncate(str, 0);
str_append_tabescaped(str, i->ident);
break;
}
}