Cache the metadata retrieval value where feasible for minimal performance impact.
{
rb_dlink_list channel; /* chain of channel pointer blocks */
rb_dlink_list invited; /* chain of invite pointer blocks */
- char *away; /* pointer to away message */
int refcnt; /* Number of times this block is referenced */
char suser[NICKLEN+1];
msg_client(int p_or_n, const char *command,
struct Client *source_p, struct Client *target_p, const char *text)
{
+ const char *awaymsg;
int do_floodcount = 0;
if(MyClient(source_p))
return;
}
- if(MyConnect(source_p) && (p_or_n != NOTICE) && target_p->user && target_p->user->away)
+ if(MyConnect(source_p) && (p_or_n != NOTICE) && target_p->user && (awaymsg = get_metadata(target_p, "away")) != NULL)
sendto_one_numeric(source_p, RPL_AWAY, form_str(RPL_AWAY),
- target_p->name, target_p->user->away);
+ target_p->name, awaymsg);
if(MyClient(target_p))
{
if(parc < 2 || EmptyString(parv[1]))
{
/* Marking as not away */
- if(source_p->user->away != NULL)
+ if(get_metadata(source_p, "away") != NULL)
{
/* we now send this only if they were away before --is */
sendto_server(client_p, NULL, CAP_TS6, NOCAPS,
return 0;
}
-
- if(source_p->user->away == NULL)
- {
- allocate_away(source_p);
- rb_strlcpy(source_p->user->away, parv[1], AWAYLEN);
- sendto_server(client_p, NULL, CAP_TS6, NOCAPS,
- ":%s AWAY :%s", use_id(source_p), source_p->user->away);
+ set_metadata(source_p, "away", parv[1]);
+ sendto_server(client_p, NULL, CAP_TS6, NOCAPS,
+ ":%s AWAY :%s", use_id(source_p), parv[1]);
- } else {
- rb_strlcpy(source_p->user->away, parv[1], AWAYLEN);
- }
-
if(MyConnect(source_p))
sendto_one_numeric(source_p, RPL_NOWAWAY, form_str(RPL_NOWAWAY));
static int
m_invite(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
+ const char *awaymsg;
struct Client *target_p;
struct Channel *chptr;
struct membership *msptr;
sendto_one(source_p, form_str(RPL_INVITING),
me.name, source_p->name,
target_p->name, parv[2]);
- if(target_p->user->away)
+ if((awaymsg = get_metadata(target_p, "away")) != NULL)
sendto_one_numeric(source_p, RPL_AWAY, form_str(RPL_AWAY),
- target_p->name, target_p->user->away);
+ target_p->name, awaymsg);
}
/* invite timestamp */
else if(parc > 3 && !EmptyString(parv[3]))
if(IsOperInvis(target_p) && !IsOper(source_p))
continue;
- if(target_p->user->away)
+ if(get_metadata(target_p, "away"))
continue;
count++;
int conf_count = 0; /* conf lines */
int users_invited_count = 0; /* users invited */
int user_channels = 0; /* users in channels */
- int aways_counted = 0;
size_t number_servers_cached; /* number of servers cached by scache */
size_t channel_memory = 0;
size_t channel_invex_memory = 0;
size_t channel_quiet_memory = 0;
- size_t away_memory = 0; /* memory used by aways */
size_t ww = 0; /* whowas array count */
size_t wwm = 0; /* whowas array memory used */
size_t conf_memory = 0; /* memory used by conf lines */
users_counted++;
users_invited_count += rb_dlink_list_length(&target_p->user->invited);
user_channels += rb_dlink_list_length(&target_p->user->channel);
- if(target_p->user->away)
- {
- aways_counted++;
- away_memory += (strlen(target_p->user->away) + 1);
- }
}
}
(unsigned long) users_invited_count * sizeof(rb_dlink_node));
sendto_one_numeric(source_p, RPL_STATSDEBUG,
- "z :User channels %u(%lu) Aways %u(%d)",
+ "z :User channels %u(%lu)",
user_channels,
- (unsigned long) user_channels * sizeof(rb_dlink_node),
- aways_counted, (int) away_memory);
+ (unsigned long) user_channels * sizeof(rb_dlink_node));
sendto_one_numeric(source_p, RPL_STATSDEBUG,
"z :Attached confs %u(%lu)",
rl = rb_sprintf(response, "%s%s=%c%s@%s ",
target_p->name,
IsOper(target_p) ? "*" : "",
- (target_p->user->away) ? '-' : '+',
+ (get_metadata(target_p, "away") != NULL) ? '-' : '+',
target_p->username,
target_p->sockhost);
}
rl = rb_sprintf(response, "%s%s=%c%s@%s ",
target_p->name,
IsOper(target_p) ? "*" : "",
- (target_p->user->away) ? '-' : '+',
+ (get_metadata(target_p, "away") != NULL) ? '-' : '+',
target_p->username, target_p->host);
}
const char *q;
rb_sprintf(status, "%c%s%s",
- target_p->user->away ? 'G' : 'H', IsOper(target_p) ? "*" : "", msptr ? find_channel_status(msptr, fmt->fields || IsCapable(source_p, CLICAP_MULTI_PREFIX)) : "");
+ (get_metadata(target_p, "away") != NULL) ? 'G' : 'H', IsOper(target_p) ? "*" : "", msptr ? find_channel_status(msptr, fmt->fields || IsCapable(source_p, CLICAP_MULTI_PREFIX)) : "");
if (fmt->fields == 0)
sendto_one(source_p, form_str(RPL_WHOREPLY), me.name,
static void
single_whois(struct Client *source_p, struct Client *target_p, int operspy)
{
+ const char *awaymsg;
char buf[BUFSIZE];
rb_dlink_node *ptr;
struct membership *msptr;
target_p->name, target_p->servptr->name,
target_p->servptr->info);
- if(target_p->user->away)
+ if((awaymsg = get_metadata(target_p, "away")) != NULL)
sendto_one_numeric(source_p, RPL_AWAY, form_str(RPL_AWAY),
- target_p->name, target_p->user->away);
+ target_p->name, awaymsg);
if(IsOper(target_p))
{
{
if(--user->refcnt <= 0)
{
- if(user->away)
- rb_free((char *) user->away);
/*
* sanity check
*/
RB_DLINK_FOREACH(ptr, global_client_list.head)
{
+ const char *awaymsg = NULL;
+
target_p = ptr->data;
if(!IsPerson(target_p))
use_id(target_p), target_p->user->suser);
}
- if(ConfigFileEntry.burst_away && !EmptyString(target_p->user->away))
+ if(ConfigFileEntry.burst_away && (awaymsg = get_metadata(target_p, "away")) != NULL)
sendto_one(client_p, ":%s AWAY :%s",
use_id(target_p),
- target_p->user->away);
+ awaymsg);
hclientinfo.target = target_p;
call_hook(h_burst_client, &hclientinfo);