Functions

mcd_var.c File Reference

$Id$ More...

#include "mcd_var.h"
#include "memcached.h"
#include "../../ut.h"
#include "../../mem/mem.h"
#include "../pv/pv_svar.h"
#include "../../md5utils.h"
Include dependency graph for mcd_var.c:

Go to the source code of this file.

Functions


Detailed Description

Copyright (C) 2009 Henning Westerholt

This file is part of Kamailio, a free SIP server.

Kamailio is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version

Kamailio is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, see <http://www.gnu.org/licenses/>.

memcached module

Definition in file mcd_var.c.


Function Documentation

int pv_dec_mcd_value ( struct sip_msg msg,
pv_param_t *  param,
int  op,
pv_value_t *  val 
) [inline]
Parameters:
msg SIP message
param parameter
op not used
val value
Returns:
0 on success, -1 on failure

Definition at line 290 of file mcd_var.c.

References pv_mcd_atomic_helper().

Here is the call graph for this function:

int pv_get_mcd_value ( struct sip_msg msg,
pv_param_t *  param,
pv_value_t *  res 
)
Parameters:
msg SIP message
param parameter
res result
Returns:
null on success, negative on failure

Definition at line 115 of file mcd_var.c.

References _str::len, pkg_str_dup(), pv_get_mcd_value_helper(), pv_get_null(), pv_mcd_key_check(), and _str::s.

Here is the call graph for this function:

static int pv_get_mcd_value_helper ( struct sip_msg msg,
str key,
struct memcache_req **  mcd_req,
struct memcache_res **  mcd_res 
) [static]
Parameters:
msg SIP message
key value key
mcd_req request
mcd_res result
Returns:
null on success, negative on failure

Definition at line 79 of file mcd_var.c.

References _str::len, memcached_h, and _str::s.

Referenced by pv_get_mcd_value(), pv_mcd_atomic_helper(), and pv_set_mcd_expire().

Here is the caller graph for this function:

int pv_inc_mcd_value ( struct sip_msg msg,
pv_param_t *  param,
int  op,
pv_value_t *  val 
) [inline]
Parameters:
msg SIP message
param parameter
op not used
val value
Returns:
0 on success, -1 on failure

Definition at line 277 of file mcd_var.c.

References pv_mcd_atomic_helper().

Here is the call graph for this function:

static int pv_mcd_atomic_helper ( struct sip_msg msg,
pv_param_t *  param,
int  op,
pv_value_t *  val,
unsigned int(*)(struct memcache *mc, char *key, const size_t key_len, const unsigned int val)  atomic_ops 
) [static]
Note:
The checks on value existence and type are not done atomically, so there is a small chance that the later atomic operation fails. This is hard to detect because this function don't return a proper result code. Checking for the incremented value is also not possible, because in the mean time the value could be incremented from some other client.
Parameters:
msg SIP message
param parameter
op not used
val value
atomic_ops function pointer to the atomic operation from the memcache library
Returns:
0 on success, -1 on failure

Definition at line 229 of file mcd_var.c.

References _str::len, memcached_h, pv_get_mcd_value_helper(), pv_mcd_key_check(), and _str::s.

Referenced by pv_dec_mcd_value(), and pv_inc_mcd_value().

Here is the call graph for this function:

Here is the caller graph for this function:

static int pv_mcd_key_check ( struct sip_msg msg,
pv_param_t *  param,
str out 
) [inline, static]
Parameters:
msg SIP message
param pseudo-variable input parameter
out output string
Returns:
0 on success, negative on failure

Definition at line 43 of file mcd_var.c.

References hash(), _str::len, MD5StringArray(), and _str::s.

Referenced by pv_get_mcd_value(), pv_mcd_atomic_helper(), pv_set_mcd_expire(), and pv_set_mcd_value().

Here is the call graph for this function:

Here is the caller graph for this function:

int pv_parse_mcd_name ( pv_spec_p  sp,
str in 
)
Parameters:
sp pseudo-variable specification
in parameter string
Returns:
0 on success, -1 on failure

Definition at line 345 of file mcd_var.c.

References _str::len, and _str::s.

int pv_set_mcd_expire ( struct sip_msg msg,
pv_param_t *  param,
int  op,
pv_value_t *  val 
)
Note:
The memcache library don't provide functions to change the expiration time for a certain key after creation, so we need to do a get and set here.
Parameters:
msg SIP message
param parameter
op not used
val value
Returns:
0 on success, -1 on failure

Definition at line 305 of file mcd_var.c.

References _str::len, memcached_h, pv_get_mcd_value_helper(), pv_mcd_key_check(), and _str::s.

Here is the call graph for this function:

int pv_set_mcd_value ( struct sip_msg msg,
pv_param_t *  param,
int  op,
pv_value_t *  val 
)
Todo:
Replacement of already existing values is not done atomically at the moment.

Here the provided replace function should be used.

Parameters:
msg SIP message
param parameter
op not used
val value
Returns:
0 on success, -1 on failure

Definition at line 175 of file mcd_var.c.

References int2str(), _str::len, memcached_expire, memcached_h, memcached_mode, pv_mcd_key_check(), and _str::s.

Here is the call graph for this function: