Module: sip-router
Branch: master
Commit: 27cdfd2c39e28b846c81640c84f00f1e282ab91c
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=27cdfd2…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Fri Mar 27 20:44:36 2009 +0100
build system: support for multiple modules dirs
Multiple modules directories are now supported.
The list of the modules directories is in Makefile.dirs in
$(modules_dirs).
Name restrictions: the names must not match any makefile variable name
and they shouldn't contain any '-' char.
The modules and modules doc/READMEs will be installed in separate dirs
(e.g. for modules_dirs="modules modules_s modules_k" , the modules
will be installed in .../lib/ser/modules , ...lib/ser/modules_s
and ...lib/ser/modules_k).
The module man pages will all be installed in the same man dir
(but so far only some ser modules have man pages so we should be
safe).
New make targets:
every-module - make all the modules in all the module dirs
install-every-module - like above, but install
install-every-module-doc
install-every-module-man
Targets dependent on $(modules_dirs) content:
$(m), $(m)-doc, $(m)-readme, $(m)-man, install-$(m),
install-$(m)-doc, install-$(m)-man.
E.g.: for modules_dirs=modules modules_k modules_s
make modules - make all modules in the directory "modules".
make modules_k - make all the modules in the directory modules_k.
make every-module - make all the modules in the directories
modules, modules_k and modules_s.
make install-modules_s - install all the modules in the directory
modules_s.
---
Makefile | 315 +++++++++++++++++++++++++++++++++---------------------
Makefile.defs | 3 +-
Makefile.dirs | 23 ++++
Makefile.modules | 16 ++--
Makefile.rules | 12 +-
Makefile.sources | 2 +-
Makefile.targets | 22 +++--
7 files changed, 251 insertions(+), 142 deletions(-)
Diff: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commitdiff;h=27c…
Module: sip-router
Branch: master
Commit: 583ea36b97bf1f2669086b30d022ba619c3fa1b3
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=583ea36…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Fri Apr 3 16:07:04 2009 +0200
Merge commit 'origin/ser_core_cvs'
* commit 'origin/ser_core_cvs':
Wrapper functions for regcomp, regexec, regfree, and regerror using shared
make: minor optimizations
make: fail if make version < 3.80
make: workaround for make 3.80
make: workaround for backwards compat. with make 3.80
dns: fix selecting neg. cname entry
---
Module: sip-router
Branch: ser_core_cvs
Commit: e01a458045ad4363110dad04a774342a57b5851a
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=e01a458…
Author: Miklos Tirpak <miklos(a)iptel.org>
Committer: Miklos Tirpak <miklos(a)iptel.org>
Date: Fri Apr 3 13:03:46 2009 +0000
Wrapper functions for regcomp, regexec, regfree, and regerror using shared
memory allocators instead of libc malloc/realloc/free.
Check the README file for more details.
---
lib/Makefile | 2 +-
lib/README | 22 ++++++--
lib/shm_regex/Makefile | 14 +++++
lib/shm_regex/README | 23 ++++++++
lib/shm_regex/shm_regex.c | 129 +++++++++++++++++++++++++++++++++++++++++++++
lib/shm_regex/shm_regex.h | 45 ++++++++++++++++
6 files changed, 228 insertions(+), 7 deletions(-)
diff --git a/lib/Makefile b/lib/Makefile
index 431e37d..01bbc1d 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -7,7 +7,7 @@
#
-SUBDIRS=binrpc cds xcap presence
+SUBDIRS=binrpc cds xcap presence shm_regex
.PHONY: subdirs $(SUBDIRS)
diff --git a/lib/README b/lib/README
index 289b9f6..317fd3e 100644
--- a/lib/README
+++ b/lib/README
@@ -24,28 +24,32 @@ xcap - Common XCAP operations and structures (XCAP authorization documents
requires external libraries: libxml2, libcurl3 (nonSER version)
requires internal libraries: cds
+shm_regex - Wrapper functions for regcomp, regexec, regfree and regerror
+ using shared memory. See 'man regex' for details.
+
Used by modules: pa, rls, dialog, rpa
Usage:
-----
-All libraries can be compiled "with ser" or "without ser". Compilation
-without ser may be useful for debugging purposes or for example for
+All libraries except shm_regex can be compiled "with ser" or "without ser".
+Compilation without ser may be useful for debugging purposes or for example for
searching for memory leaks with some tool like valgrind.
+shm_regex library can be compiled only with ser.
Compilation with ser:
--------------------
Compilation and installation of these libraries is NOT DONE by running
-main ser makefile now - it MUST be done MANUALLY. For this purpose
-is there Makefile.ser. To compile and install libraries simply run
+main ser makefile now - it MUST be done MANUALLY. To compile and install
+libraries simply run
- make -f Makefile.ser install
+ make install
in lib directory. You can select destination directory like in the case
of ser, for example:
- make -f Makefile.ser install prefix="/my/ser/directory"
+ make install prefix="/my/ser/directory"
AFTER COMPILATION of libraries you can COMPILE MODULES using this
libraries like PA, RLS or dialog.
@@ -61,6 +65,12 @@ you should set LD_LIBRARY_PATH=/usr/local/lib/ser. In the case of
nonstandard installation, you can use something like
LD_LIBRARY_PATH=/my/ser/directory/lib/ser.
+Compilation without ser:
+--------------------
+Use the alternate makefile, Makefile.noser:
+
+ make -f Makefile.noser install
+
Documentation
-------------
Documentation for all libraries is (or will be) in
diff --git a/lib/shm_regex/Makefile b/lib/shm_regex/Makefile
new file mode 100644
index 0000000..2a0c907
--- /dev/null
+++ b/lib/shm_regex/Makefile
@@ -0,0 +1,14 @@
+#
+# makefile for shm_regex
+#
+
+include ../../Makefile.defs
+auto_gen=
+NAME:=ser_shm_regex
+MAJOR_VER=0
+MINOR_VER=1
+BUGFIX_VER=0
+LIBS=
+
+include ../../Makefile.libs
+
diff --git a/lib/shm_regex/README b/lib/shm_regex/README
new file mode 100644
index 0000000..bfec807
--- /dev/null
+++ b/lib/shm_regex/README
@@ -0,0 +1,23 @@
+$Id$
+
+Wrapper functions for regcomp, regexec, regfree, and regerror using shared
+memory allocators instead of libc malloc/realloc/free. The original functions
+are prefixed with "shm_".
+
+The regular expression compiled with shm_regcomp() can be used with shm_regexec()
+simultaneously by multiple processes without locking, because regexec has its own
+internal locks. It can be later on freed with shm_regfree() when the expression
+is no longer used. Note however that
+
+1) shm_regexec allocates shared memory for the pattern buffer when it is successfully
+called for the first time.
+
+2) shm_regexec temporary allocates and deallocates memory for storing the registers
+for the pmatch array runtime if nmatch and pmatch parameters are not 0. This is
+done also in shared memory, therefore use the shared memory wrappers for
+regular expression based search-and-replace only if really necessary.
+
+See 'man regex' for the usage and parameters of the functions.
+
+Supported only with GNU C library.
+
diff --git a/lib/shm_regex/shm_regex.c b/lib/shm_regex/shm_regex.c
new file mode 100644
index 0000000..165d535
--- /dev/null
+++ b/lib/shm_regex/shm_regex.c
@@ -0,0 +1,129 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2009 iptelorg GmbH
+ *
+ * This file is part of ser, a free SIP server.
+ *
+ * ser 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
+ *
+ * For a license to use the ser software under conditions
+ * other than those described here, or to purchase support for this
+ * software, please contact iptel.org by e-mail at the following addresses:
+ * info(a)iptel.org
+ *
+ * ser 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * History
+ * -------
+ * 2009-04-03 Initial version (Miklos)
+ */
+
+#include <malloc.h> /* hook prototypes */
+
+#include "../../mem/shm_mem.h"
+#include "shm_regex.h"
+
+typedef void *(malloc_hook_t) (size_t, const void *);
+typedef void *(realloc_hook_t) (void *, size_t, const void *);
+typedef void (free_hook_t) (void *, const void *);
+
+/* The memory hooks are overwritten before calling regcomp(), regfree(),
+ * and regexec(), and shared memory function are called
+ * from the hooks instead of libc malloc/realloc/free.
+ */
+
+static void *shm_malloc_hook(size_t size, const void *caller)
+{
+ return shm_malloc (size);
+}
+
+static void *shm_realloc_hook(void *p, size_t size, const void *caller)
+{
+ return shm_realloc (p, size);
+}
+
+static void shm_free_hook(void *ptr, const void *caller)
+{
+ if (ptr) shm_free (ptr);
+}
+
+#define replace_malloc_hooks() \
+ do { \
+ orig_malloc_hook = __malloc_hook; \
+ orig_realloc_hook = __realloc_hook; \
+ orig_free_hook = __free_hook; \
+ __malloc_hook = shm_malloc_hook; \
+ __realloc_hook = shm_realloc_hook; \
+ __free_hook = shm_free_hook; \
+ } while (0)
+
+#define restore_malloc_hooks() \
+ do { \
+ __malloc_hook = orig_malloc_hook; \
+ __realloc_hook = orig_realloc_hook; \
+ __free_hook = orig_free_hook; \
+ } while (0)
+
+int shm_regcomp(regex_t *preg, const char *regex, int cflags)
+{
+ malloc_hook_t *orig_malloc_hook;
+ realloc_hook_t *orig_realloc_hook;
+ free_hook_t *orig_free_hook;
+ int ret;
+
+ replace_malloc_hooks();
+ ret = regcomp(preg, regex, cflags);
+ restore_malloc_hooks();
+
+ return ret;
+}
+
+void shm_regfree(regex_t *preg)
+{
+ malloc_hook_t *orig_malloc_hook;
+ realloc_hook_t *orig_realloc_hook;
+ free_hook_t *orig_free_hook;
+
+ replace_malloc_hooks();
+ regfree(preg);
+ restore_malloc_hooks();
+}
+
+int shm_regexec(const regex_t *preg, const char *string, size_t nmatch,
+ regmatch_t pmatch[], int eflags)
+{
+ malloc_hook_t *orig_malloc_hook;
+ realloc_hook_t *orig_realloc_hook;
+ free_hook_t *orig_free_hook;
+ int ret;
+
+ /* regexec() allocates some memory for the pattern buffer
+ * when it is successfully called for the first time, therefore
+ * shared memory is required also here.
+ * The drawback is that shared memory allocation is also used
+ * needlessly for allocating the temporary space for
+ * the elements of pmatch. -- Does not happen if pmatch and
+ * nmatch are 0.
+ * It is safe to call regexec() concurrently without locking,
+ * because regexec() has its own locks.
+ * (Miklos)
+ */
+ replace_malloc_hooks();
+ ret = regexec(preg, string, nmatch,
+ pmatch, eflags);
+ restore_malloc_hooks();
+
+ return ret;
+}
+
diff --git a/lib/shm_regex/shm_regex.h b/lib/shm_regex/shm_regex.h
new file mode 100644
index 0000000..42ec52b
--- /dev/null
+++ b/lib/shm_regex/shm_regex.h
@@ -0,0 +1,45 @@
+/*
+ * $Id$
+ *
+ * Copyright (C) 2009 iptelorg GmbH
+ *
+ * This file is part of ser, a free SIP server.
+ *
+ * ser 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
+ *
+ * For a license to use the ser software under conditions
+ * other than those described here, or to purchase support for this
+ * software, please contact iptel.org by e-mail at the following addresses:
+ * info(a)iptel.org
+ *
+ * ser 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * History
+ * -------
+ * 2009-04-03 Initial version (Miklos)
+ */
+
+#ifndef _SHM_REGEX_H
+#define _SHM_REGEX_H
+
+#include <sys/types.h>
+#include <regex.h>
+
+int shm_regcomp(regex_t *preg, const char *regex, int cflags);
+void shm_regfree(regex_t *preg);
+int shm_regexec(const regex_t *preg, const char *string, size_t nmatch,
+ regmatch_t pmatch[], int eflags);
+
+#define shm_regerror regerror
+
+#endif /* _SHM_REGEX_H */
Module: sip-router
Branch: ser_core_cvs
Commit: 96d9c662abfdc108f64925ad89931c7a5df54c49
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=96d9c66…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Fri Apr 3 11:06:57 2009 +0000
make: fail if make version < 3.80
---
INSTALL | 2 +-
Makefile | 10 ++++++++++
2 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/INSTALL b/INSTALL
index 0da2303..eca400b 100644
--- a/INSTALL
+++ b/INSTALL
@@ -53,7 +53,7 @@ Requirements:
- bison or yacc (Berkley yacc)
- flex
- GNU make (on Linux this is the standard "make", on *BSD and Solaris is
- called "gmake") version >= 3.80.
+ called "gmake") version >= 3.80 (recommended 3.81).
- sed and tr (used in the makefiles)
- GNU tar ("gtar" on Solaris) and gzip if you want "make tar" to work
- GNU install, BSD install or Solaris install if you want "make
diff --git a/Makefile b/Makefile
index 4c75fe0..fd3a20e 100644
--- a/Makefile
+++ b/Makefile
@@ -61,6 +61,16 @@
# $(MAKE) invocation (andrei)
#
+# check make version
+# required 3.80, recommended 3.81
+req_ver=3.80
+# the check below works for version number of the type x.yy or x.yy.z*
+# (from the GNU Make Cookbook)
+ifeq (,$(filter $(req_ver),$(firstword $(sort $(MAKE_VERSION) $(req_ver)))))
+$(error make version $(MAKE_VERSION) not supported, use at least $(req_ver))
+endif
+
+
auto_gen=lex.yy.c cfg.tab.c #lexx, yacc etc
auto_gen_others=cfg.tab.h # auto generated, non-c
Module: sip-router
Branch: ser_core_cvs
Commit: 25ba1f0f4cd2b059e3f2a27d619ca054122cf4cb
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=25ba1f0…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Tue Mar 31 18:11:25 2009 +0000
dns: fix selecting neg. cname entry
- do not select a neg. cache cname entry as a response, unless
the request is for a cname.
This fixes an unlikely bug: someone makes a specific cname
request (from ser) for a name that doesn't resolve and then later when
a normal non-cname request is made (e.g. A) the empty negative cname
entry is selected, leading to a coredump. So far there is no
code in ser that could trigger this bug. Only dns.lookup cname
... from sip-router could trigger it.
---
dns_cache.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/dns_cache.c b/dns_cache.c
index b0e7a4d..a5167c4 100644
--- a/dns_cache.c
+++ b/dns_cache.c
@@ -580,8 +580,11 @@ again:
#endif
#endif
return e;
- }else if ((e->type==T_CNAME) && (e->name_len==name->len) &&
- (strncasecmp(e->name, name->s, e->name_len)==0)){
+ }else if ((e->type==T_CNAME) && !((e->rr_lst==0) || e->err_flags) &&
+ (e->name_len==name->len) &&
+ (strncasecmp(e->name, name->s, e->name_len)==0)){
+ /*if CNAME matches and CNAME is entry is not a neg. cache entry
+ (could be produced by a specific CNAME lookup)*/
e->last_used=now;
#ifdef DNS_LU_LST
/* add it at the end */