Skip to content

Commit

Permalink
Merge branch '4.4' of https://github.com/kamailio/kamailio into 4.4
Browse files Browse the repository at this point in the history
* '4.4' of https://github.com/kamailio/kamailio: (32 commits)
  Update hep.c
  core: mem - updated defines to pkg mod stats
  Makefile.defs: version set to 4.4.0-rc2
  Makefile.defs: re-enable pkg malloc
  topos: reused stored branch attributes in case of retransmission
  http_async_client: use pkg-config for libevent compile flags detection
  mem: shm - updated macros for mod stats api
  uuid: detect if pkg-config knows about uuid lib
  mem/tlsf_malloc: updates to use new api names for module stats
  mem/q_malloc: updates to use new api names for module stats
  mem/f_malloc: updates to use new api names for module stats
  core: mem/shm - use module stats fields for init of managers
  core: mem/pkg - use module stats fields for init of managers q
  core - mem: renamed api fields for module stats to repleft the purpose
  tm: coherent indentation
  p_usrloc: free allocated items in case of no more memory during domain add
  core: mem - export pkg api even when using system malloc
  presence: remove jumping to error from error in update_presentity()
  http_client: check first if pointer is not exceeding limit
  usrloc: if no location record loaded from db, then no attrs to look up
  ...
  • Loading branch information
oej committed Mar 30, 2016
2 parents 00a01a4 + 78a43ba commit 78bc680
Show file tree
Hide file tree
Showing 31 changed files with 1,976 additions and 1,920 deletions.
2 changes: 1 addition & 1 deletion Makefile.defs
Expand Up @@ -97,7 +97,7 @@ INSTALL_FLAVOUR=$(FLAVOUR)
VERSION = 4
PATCHLEVEL = 4
SUBLEVEL = 0
EXTRAVERSION = -rc1
EXTRAVERSION = -rc2

# memory manager switcher
# 0 - f_malloc (fast malloc)
Expand Down
1 change: 0 additions & 1 deletion lib/srdb1/schema/location.xml
Expand Up @@ -232,7 +232,6 @@
<name>connection_idx</name>
<colref linkend="server_id"/>
<colref linkend="connection_id"/>
<unique/>
</index>


Expand Down
8 changes: 4 additions & 4 deletions lib/trie/dtrie.c
Expand Up @@ -15,8 +15,8 @@
* 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, write to the Free Software
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

Expand Down Expand Up @@ -245,7 +245,7 @@ void **dtrie_longest_match(struct dtrie_node_t *root, const char *number,
digit = number[i];
if (digit>127) return ret;
}

if (node->child[digit] == NULL) return ret;
node = node->child[digit];
i++;
Expand All @@ -262,7 +262,7 @@ void **dtrie_longest_match(struct dtrie_node_t *root, const char *number,
void **dtrie_contains(struct dtrie_node_t *root, const char *number,
const unsigned int numberlen, const unsigned int branches)
{
int nmatch;
int nmatch = 0;
void **ret;
ret = dtrie_longest_match(root, number, numberlen, &nmatch, branches);

Expand Down
8 changes: 4 additions & 4 deletions mem/f_malloc.c
Expand Up @@ -1067,8 +1067,8 @@ int fm_malloc_init_pkg_manager(void)
ma.xavailable = fm_available;
ma.xsums = fm_sums;
ma.xdestroy = fm_malloc_destroy_pkg_manager;
ma.xstats = fm_mod_get_stats;
ma.xfstats = fm_mod_free_stats;
ma.xmodstats = fm_mod_get_stats;
ma.xfmodstats = fm_mod_free_stats;

return pkg_init_api(&ma);
}
Expand Down Expand Up @@ -1218,8 +1218,8 @@ int fm_malloc_init_shm_manager(void)
ma.xavailable = fm_shm_available;
ma.xsums = fm_shm_sums;
ma.xdestroy = fm_malloc_destroy_shm_manager;
ma.xstats = fm_mod_get_stats;
ma.xfstats = fm_mod_free_stats;
ma.xmodstats = fm_mod_get_stats;
ma.xfmodstats = fm_mod_free_stats;

if(shm_init_api(&ma)<0) {
LM_ERR("cannot initialize the core shm api\n");
Expand Down
8 changes: 4 additions & 4 deletions mem/memapi.h
Expand Up @@ -79,9 +79,9 @@ typedef struct sr_pkg_api {
/*memory destroy manager*/
sr_mem_destroy_f xdestroy;
/*memory stats per module*/
sr_mem_mod_get_stats_f xstats;
sr_mem_mod_get_stats_f xmodstats;
/*memory stats free per module*/
sr_mem_mod_free_stats_f xfstats;
sr_mem_mod_free_stats_f xfmodstats;
} sr_pkg_api_t;

/*shared memory api*/
Expand Down Expand Up @@ -115,9 +115,9 @@ typedef struct sr_shm_api {
/*memory destroy manager*/
sr_mem_destroy_f xdestroy;
/*memory stats per module*/
sr_mem_mod_get_stats_f xstats;
sr_mem_mod_get_stats_f xmodstats;
/*memory stats free per module*/
sr_mem_mod_free_stats_f xfstats;
sr_mem_mod_free_stats_f xfmodstats;
} sr_shm_api_t;

#endif
4 changes: 2 additions & 2 deletions mem/pkg.c
Expand Up @@ -46,8 +46,8 @@ int pkg_init_api(sr_pkg_api_t *ap)
_pkg_root.xavailable = ap->xavailable;
_pkg_root.xsums = ap->xsums;
_pkg_root.xdestroy = ap->xdestroy;
_pkg_root.xstats = ap->xstats;
_pkg_root.xfstats = ap->xfstats;
_pkg_root.xmodstats = ap->xmodstats;
_pkg_root.xfmodstats = ap->xfmodstats;
return 0;
}

Expand Down
20 changes: 11 additions & 9 deletions mem/pkg.h
Expand Up @@ -20,12 +20,17 @@
#ifndef _sr_pkg_h_
#define _sr_pkg_h_

#ifdef PKG_MALLOC

#include "memapi.h"

extern sr_pkg_api_t _pkg_root;

int pkg_init_api(sr_pkg_api_t *ap);
int pkg_init_manager(char *name);
void pkg_destroy_manager(void);
void pkg_print_manager(void);

#ifdef PKG_MALLOC

#ifdef DBG_SR_MEMORY
# define pkg_malloc(s) _pkg_root.xmalloc(_pkg_root.mem_block, (s), _SRC_LOC_, \
_SRC_FUNCTION_, _SRC_LINE_, _SRC_MODULE_)
Expand All @@ -43,13 +48,8 @@ extern sr_pkg_api_t _pkg_root;
# define pkg_info(mi) _pkg_root.xinfo(_pkg_root.mem_block, mi)
# define pkg_available() _pkg_root.xavailable(_pkg_root.mem_block)
# define pkg_sums() _pkg_root.xsums(_pkg_root.mem_block)
# define pkg_mod_get_stats(x) _pkg_root.xstats(_pkg_root.mem_block, x)
# define pkg_mod_free_stats(x) _pkg_root.xfstats(x)

int pkg_init_api(sr_pkg_api_t *ap);
int pkg_init_manager(char *name);
void pkg_destroy_manager(void);
void pkg_print_manager(void);
# define pkg_mod_get_stats(x) _pkg_root.xmodstats(_pkg_root.mem_block, x)
# define pkg_mod_free_stats(x) _pkg_root.xfmodstats(x)

#else /*PKG_MALLOC*/
/* use system allocator */
Expand All @@ -74,6 +74,8 @@ void pkg_print_manager(void);
# define pkg_info(mi) do{ memset((mi),0, sizeof(*(mi))); } while(0)
# define pkg_available() 0
# define pkg_sums() do{}while(0)
# define pkg_mod_get_stats(x) do{}while(0)
# define pkg_mod_free_stats(x) do{}while(0)
#endif /*PKG_MALLOC*/

#endif
8 changes: 4 additions & 4 deletions mem/q_malloc.c
Expand Up @@ -1032,8 +1032,8 @@ int qm_malloc_init_pkg_manager(void)
ma.xavailable = qm_available;
ma.xsums = qm_sums;
ma.xdestroy = qm_malloc_destroy_pkg_manager;
ma.xstats = qm_mod_get_stats;
ma.xfstats = qm_mod_free_stats;
ma.xmodstats = qm_mod_get_stats;
ma.xfmodstats = qm_mod_free_stats;

return pkg_init_api(&ma);
}
Expand Down Expand Up @@ -1183,8 +1183,8 @@ int qm_malloc_init_shm_manager(void)
ma.xavailable = qm_shm_available;
ma.xsums = qm_shm_sums;
ma.xdestroy = qm_malloc_destroy_shm_manager;
ma.xstats = qm_mod_get_stats;
ma.xfstats = qm_mod_free_stats;
ma.xmodstats = qm_mod_get_stats;
ma.xfmodstats = qm_mod_free_stats;

if(shm_init_api(&ma)<0) {
LM_ERR("cannot initialize the core shm api\n");
Expand Down
4 changes: 2 additions & 2 deletions mem/shm.c
Expand Up @@ -221,8 +221,8 @@ int shm_init_api(sr_shm_api_t *ap)
_shm_root.xavailable = ap->xavailable;
_shm_root.xsums = ap->xsums;
_shm_root.xdestroy = ap->xdestroy;
_shm_root.xstats = ap->xstats;
_shm_root.xfstats = ap->xfstats;
_shm_root.xmodstats = ap->xmodstats;
_shm_root.xfmodstats = ap->xfmodstats;
return 0;

}
Expand Down
4 changes: 2 additions & 2 deletions mem/shm.h
Expand Up @@ -73,8 +73,8 @@ extern sr_shm_api_t _shm_root;
# define shm_info(mi) _shm_root.xinfo(_shm_root.mem_block, mi)
# define shm_available() _shm_root.xavailable(_shm_root.mem_block)
# define shm_sums() _shm_root.xsums(_shm_root.mem_block)
# define shm_mod_get_stats(x) _shm_root.xstats(_shm_root.mem_block, x)
# define shm_mod_free_stats(x) _shm_root.xfstats(x)
# define shm_mod_get_stats(x) _shm_root.xmodstats(_shm_root.mem_block, x)
# define shm_mod_free_stats(x) _shm_root.xfmodstats(x)


void* shm_core_get_pool(void);
Expand Down
8 changes: 4 additions & 4 deletions mem/tlsf_malloc.c
Expand Up @@ -1358,8 +1358,8 @@ int tlsf_malloc_init_pkg_manager(void)
ma.xavailable = tlsf_available;
ma.xsums = tlsf_sums;
ma.xdestroy = tlsf_malloc_destroy_pkg_manager;
ma.xstats = tlsf_mod_get_stats;
ma.xfstats = tlsf_mod_free_stats;
ma.xmodstats = tlsf_mod_get_stats;
ma.xfmodstats = tlsf_mod_free_stats;

return pkg_init_api(&ma);
}
Expand Down Expand Up @@ -1508,8 +1508,8 @@ int tlsf_malloc_init_shm_manager(void)
ma.xavailable = tlsf_shm_available;
ma.xsums = tlsf_shm_sums;
ma.xdestroy = tlsf_malloc_destroy_shm_manager;
ma.xstats = tlsf_mod_get_stats;
ma.xfstats = tlsf_mod_free_stats;
ma.xmodstats = tlsf_mod_get_stats;
ma.xfmodstats = tlsf_mod_free_stats;

if(shm_init_api(&ma)<0) {
LM_ERR("cannot initialize the core shm api\n");
Expand Down
42 changes: 40 additions & 2 deletions modules/cnxcc/Makefile
@@ -1,14 +1,52 @@
#
# cnxcc module makefile
#
#
#
# WARNING: do not run this directly, it should be run by the master Makefile

include ../../Makefile.defs
auto_gen=
NAME=cnxcc.so

LIBS=-lhiredis -levent
ifeq ($(CROSS_COMPILE),)
HIREDIS_BUILDER = $(shell \
if pkg-config --exists hiredis; then \
echo 'pkg-config hiredis'; \
fi)
endif

ifeq ($(HIREDIS_BUILDER),)
HIREDISDEFS=-I$(LOCALBASE)/include
HIREDISLIBS=-L$(LOCALBASE)/lib -lhiredis
else
HIREDISDEFS = $(shell $(HIREDIS_BUILDER) --cflags)
HIREDISLIBS = $(shell $(HIREDIS_BUILDER) --libs)

ifeq ($(HIREDISLIBS),-L -lhiredis)
HIREDISDEFS = $(shell $(HIREDIS_BUILDER) --cflags) /opt/local/include
HIREDISLIBS = -L/opt/local/lib -lhiredis
endif

endif

ifeq ($(CROSS_COMPILE),)
LEVENT_BUILDER = $(shell \
if pkg-config --exists libevent; then \
echo 'pkg-config libevent'; \
fi)
endif

ifeq ($(LEVENT_BUILDER),)
LEVENTDEFS=
LEVENTLIBS=-L$(LOCALBASE)/lib -levent
else
LEVENTDEFS = $(shell $(LEVENT_BUILDER) --cflags)
LEVENTLIBS = $(shell $(LEVENT_BUILDER) --libs)
endif

DEFS+=$(HIREDISDEFS) $(LEVENTDEFS)
LIBS=$(HIREDISLIBS) $(LEVENTLIBS)

DEFS+=-DOPENSER_MOD_INTERFACE
SERLIBPATH=../../lib
SER_LIBS+=$(SERLIBPATH)/kmi/kmi
Expand Down
14 changes: 14 additions & 0 deletions modules/crypto/crypto_mod.c
Expand Up @@ -360,22 +360,29 @@ unsigned char *crypto_aes_encrypt(EVP_CIPHER_CTX *e, unsigned char *plaintext,
int c_len = *len + AES_BLOCK_SIZE - 1, f_len = 0;
unsigned char *ciphertext = (unsigned char *)malloc(c_len);

if(ciphertext == NULL) {
LM_ERR("no more system memory\n");
return NULL;
}
/* allows reusing of 'e' for multiple encryption cycles */
if(!EVP_EncryptInit_ex(e, NULL, NULL, NULL, NULL)){
LM_ERR("failure in EVP_EncryptInit_ex \n");
free(ciphertext);
return NULL;
}

/* update ciphertext, c_len is filled with the length of ciphertext
* generated, *len is the size of plaintext in bytes */
if(!EVP_EncryptUpdate(e, ciphertext, &c_len, plaintext, *len)){
LM_ERR("failure in EVP_EncryptUpdate \n");
free(ciphertext);
return NULL;
}

/* update ciphertext with the final remaining bytes */
if(!EVP_EncryptFinal_ex(e, ciphertext+c_len, &f_len)){
LM_ERR("failure in EVP_EncryptFinal_ex \n");
free(ciphertext);
return NULL;
}

Expand All @@ -393,18 +400,25 @@ unsigned char *crypto_aes_decrypt(EVP_CIPHER_CTX *e, unsigned char *ciphertext,
int p_len = *len, f_len = 0;
unsigned char *plaintext = (unsigned char *)malloc(p_len);

if(plaintext==NULL) {
LM_ERR("no more system memory\n");
return NULL;
}
if(!EVP_DecryptInit_ex(e, NULL, NULL, NULL, NULL)){
LM_ERR("failure in EVP_DecryptInit_ex \n");
free(plaintext);
return NULL;
}

if(!EVP_DecryptUpdate(e, plaintext, &p_len, ciphertext, *len)){
LM_ERR("failure in EVP_DecryptUpdate\n");
free(plaintext);
return NULL;
}

if(!EVP_DecryptFinal_ex(e, plaintext+p_len, &f_len)){
LM_ERR("failure in EVP_DecryptFinal_ex\n");
free(plaintext);
return NULL;
}

Expand Down

0 comments on commit 78bc680

Please sign in to comment.