diff --git a/.gitignore b/.gitignore index dd193d0..15d1756 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ opensips-1.6.3-tls_src.tar.gz /opensips-1.7.1_src.tar.gz /opensips-1.7.2_src.tar.gz /opensips-1.8.0-beta_src.tar.gz +/opensips-1.8.1_src.tar.gz diff --git a/opensips-0001-Consistently-use-rtpproxy-switches.patch b/opensips-0001-Consistently-use-rtpproxy-switches.patch new file mode 100644 index 0000000..321ef35 --- /dev/null +++ b/opensips-0001-Consistently-use-rtpproxy-switches.patch @@ -0,0 +1,40 @@ +From f0981bcbe43ec290fa18bebbe1d63b1d74c19391 Mon Sep 17 00:00:00 2001 +From: Peter Lemenkov +Date: Thu, 11 Aug 2011 16:37:04 +0400 +Subject: [PATCH 1/5] Consistently use rtpproxy switches + +Signed-off-by: Peter Lemenkov +--- + modules/rtpproxy/doc/rtpproxy_admin.xml | 2 +- + modules/rtpproxy/rtpproxy.c | 2 -- + 2 files changed, 1 insertion(+), 3 deletions(-) + +diff --git a/modules/rtpproxy/doc/rtpproxy_admin.xml b/modules/rtpproxy/doc/rtpproxy_admin.xml +index 01dbffd..fc3da42 100644 +--- a/modules/rtpproxy/doc/rtpproxy_admin.xml ++++ b/modules/rtpproxy/doc/rtpproxy_admin.xml +@@ -545,7 +545,7 @@ rtpproxy_offer(); + connection information. + + +- s/w - flags that for the UA from which ++ s - flags that for the UA from which + message is received, support symmetric RTP must be forced. + + +diff --git a/modules/rtpproxy/rtpproxy.c b/modules/rtpproxy/rtpproxy.c +index 073d05f..eda5c84 100644 +--- a/modules/rtpproxy/rtpproxy.c ++++ b/modules/rtpproxy/rtpproxy.c +@@ -3028,8 +3028,6 @@ force_rtp_proxy_body(struct sip_msg* msg, struct force_rtpp_args *args) + enable_notification = 1; + break; + +- case 'w': +- case 'W': + case 's': + case 'S': + if (append_opts(&opts, 'S') == -1) { +-- +1.7.11.2 + diff --git a/opensips-0001-packaging-fedora-Improve-packaging-for-Fedora-RHEL-a.patch b/opensips-0001-packaging-fedora-Improve-packaging-for-Fedora-RHEL-a.patch deleted file mode 100644 index d47b84e..0000000 --- a/opensips-0001-packaging-fedora-Improve-packaging-for-Fedora-RHEL-a.patch +++ /dev/null @@ -1,91 +0,0 @@ -From d5de2e7015ec76de01d500c718e36cab77266ebf Mon Sep 17 00:00:00 2001 -From: osas -Date: Tue, 26 Jun 2012 14:53:42 +0000 -Subject: [PATCH 01/13] packaging/fedora: Improve packaging for Fedora/RHEL - and derivatives - closes bug id: 3535148 - backport - from trunk rev 9114 - backport from trunk rev 9115 - ---- - packaging/fedora/opensips.init | 8 ++++---- - packaging/fedora/opensips.service | 14 ++++++++++++++ - packaging/fedora/opensips.sysconfig | 2 ++ - packaging/fedora/opensips.tmpfiles.conf | 1 + - 4 files changed, 21 insertions(+), 4 deletions(-) - create mode 100644 packaging/fedora/opensips.service - create mode 100644 packaging/fedora/opensips.sysconfig - create mode 100644 packaging/fedora/opensips.tmpfiles.conf - -diff --git a/packaging/fedora/opensips.init b/packaging/fedora/opensips.init -index 1489b55..7e8ac40 100644 ---- a/packaging/fedora/opensips.init -+++ b/packaging/fedora/opensips.init -@@ -34,11 +34,11 @@ start() { - echo -n $"Starting $prog: " - - # check whether OpenSIPs was already started -- if status $prog > /dev/null 2>&1 ; then -+ if status -p $pidfile $prog > /dev/null 2>&1 ; then - echo -n "already running" && warning && echo - return 0 - fi -- -+ - # there is something at end of this output which is needed to - # report proper [ OK ] status in Fedora scripts - daemon $oser -P $pidfile -f $configfile $OPTIONS 2>/dev/null | tail -1 -@@ -51,7 +51,7 @@ start() { - stop() { - echo -n $"Stopping $prog: " - # check whether OpenSIPs is running -- if ! status $prog > /dev/null 2>&1 ; then -+ if ! status -p $pidfile $prog > /dev/null 2>&1 ; then - echo -n "not running" && warning && echo - return 0 - fi -@@ -72,7 +72,7 @@ case "$1" in - stop - ;; - status) -- status $prog -+ status -p $pidfile $prog - RETVAL=$? - ;; - restart|reload) -diff --git a/packaging/fedora/opensips.service b/packaging/fedora/opensips.service -new file mode 100644 -index 0000000..c69f164 ---- /dev/null -+++ b/packaging/fedora/opensips.service -@@ -0,0 +1,14 @@ -+[Unit] -+Description=OpenSIPS is a very fast and flexible SIP (RFC3261) server -+After=network.target mysqld.service postgresql.service rtpproxy.service -+ -+[Service] -+Type=forking -+User=opensips -+Group=opensips -+EnvironmentFile=-/etc/sysconfig/opensips -+PIDFile=/var/run/opensips/opensips.pid -+ExecStart=/usr/sbin/opensips -P /var/run/opensips/opensips.pid -f /etc/opensips/opensips.cfg $OPTIONS -+ -+[Install] -+WantedBy=multi-user.target -diff --git a/packaging/fedora/opensips.sysconfig b/packaging/fedora/opensips.sysconfig -new file mode 100644 -index 0000000..78dd88f ---- /dev/null -+++ b/packaging/fedora/opensips.sysconfig -@@ -0,0 +1,2 @@ -+# Add extra options here -+OPTIONS="" -diff --git a/packaging/fedora/opensips.tmpfiles.conf b/packaging/fedora/opensips.tmpfiles.conf -new file mode 100644 -index 0000000..16f9031 ---- /dev/null -+++ b/packaging/fedora/opensips.tmpfiles.conf -@@ -0,0 +1 @@ -+d /var/run/opensips 0755 opensips opensips --- -1.7.10.4 - diff --git a/opensips-0002-Cleanup-Oracle-s-makefiles.patch b/opensips-0002-Cleanup-Oracle-s-makefiles.patch new file mode 100644 index 0000000..084ec54 --- /dev/null +++ b/opensips-0002-Cleanup-Oracle-s-makefiles.patch @@ -0,0 +1,141 @@ +From fa56a2c404360e368a3a9d2f8f94c3580ad69439 Mon Sep 17 00:00:00 2001 +From: Peter Lemenkov +Date: Thu, 14 Jun 2012 11:38:48 +0400 +Subject: [PATCH 2/5] Cleanup Oracle's makefiles + +Signed-off-by: Peter Lemenkov +--- + modules/db_oracle/Makefile | 54 ++-------------------------------------------- + utils/db_oracle/Makefile | 52 ++------------------------------------------ + 2 files changed, 4 insertions(+), 102 deletions(-) + +diff --git a/modules/db_oracle/Makefile b/modules/db_oracle/Makefile +index 6b7e685..a721aba 100644 +--- a/modules/db_oracle/Makefile ++++ b/modules/db_oracle/Makefile +@@ -6,57 +6,7 @@ include ../../Makefile.defs + auto_gen= + NAME=db_oracle.so + +-# can be defined for non standard placement of oracle so's +-ORAPATH= +-LIBS= +- +-# use for multiple client sdk version install +-ifneq ($(ORAVERSION),) +- ORAVERDIR=/$(ORAVERSION) +-endif +- +-# use include/library path's for full client installation +-ifneq ($(ORAHOME),) +- DEFS +=-I$(ORAHOME)/include +- LIBS +=-L$(ORAHOME)/lib +-ifeq ($(ORAPATH),) +- ORAPATH=$(ORAHOME)/lib +-endif +-else +-# use standard know paths oci.h locations (linux) +-DEFS +=-I$(LOCALBASE)/include/oracle$(ORAVERDIR) \ +- -I$(SYSBASE)/include/oracle$(ORAVERDIR) +-endif +- +-# search 'so' path if it non standard (possible liboclntsh locations on linux) +-ifeq ($(ORAPATH),) +- ORAPATH=$(shell [ -f $(LOCALBASE)/lib64/oracle$(ORAVERDIR)/libocci.so ] && \ +- echo $(LOCALBASE)/lib64/oracle$(ORAVERDIR) ) +-endif +-ifeq ($(ORAPATH),) +- ORAPATH=$(shell [ -f $(SYSBASE)/lib64/oracle$(ORAVERDIR)/libocci.so ] && \ +- echo $(SYSBASE)/lib64/oracle$(ORAVERDIR) ) +-endif +-ifeq ($(ORAPATH),) +- ORAPATH=$(shell [ -f $(SYSBASE)/lib/oracle$(ORAVERDIR)/libocci.so ] && \ +- echo $(SYSBASE)/lib/oracle$(ORAVERDIR) ) +-endif +-ifeq ($(ORAPATH),) +- ORAPATH=$(shell [ -f $(SYSBASE)/lib/oracle$(ORAVERDIR)/libocci.so ] && \ +- echo $(SYSBASE)/lib/oracle$(ORAVERDIR) ) +-endif +- +-ifneq ($(ORAPATH),) +- LIBS +=-L$(ORAPATH) +-endif +- +-LIBS +=-locci -lclntsh +- +-#DEFS+=-DLINUX -D_GNU_SOURCE -D_REENTRANT +-#LIBS+=-lpthread +- +-ifneq ($(ORAPATH),) +- LIBS +=-Wl,-rpath $(ORAPATH) +-endif ++DEFS +=-I$(ORAHOME)/include ++LIBS +=-L$(ORAHOME)/lib -locci -lclntsh + + include ../../Makefile.modules +diff --git a/utils/db_oracle/Makefile b/utils/db_oracle/Makefile +index b1c8231..9565134 100644 +--- a/utils/db_oracle/Makefile ++++ b/utils/db_oracle/Makefile +@@ -10,56 +10,8 @@ NAME=opensips_orasel + + include ../../Makefile.sources + +-ORAPATH= +- +-# use for multiple client sdk version install +-ifneq ($(ORAVERSION),) +- ORAVERDIR=/$(ORAVERSION) +-endif +- +-# use include/library path's for full client installation +-ifneq ($(ORAHOME),) +- DEFS +=-I$(ORAHOME)/include +- LIBS +=-L$(ORAHOME)/lib +-ifeq ($(ORAPATH),) +- ORAPATH=$(ORAHOME)/lib +-endif +-else +-# use standard know paths oci.h locations (linux) +- DEFS +=-I$(LOCALBASE)/include/oracle$(ORAVERDIR) \ +- -I$(SYSBASE)/include/oracle$(ORAVERDIR) +-endif +- +-# search 'so' path if it non standard (possible liboclntsh locations on linux) +-ifeq ($(ORAPATH),) +- ORAPATH=$(shell [ -f $(LOCALBASE)/lib64/oracle$(ORAVERDIR)/libocci.so ] && \ +- echo $(LOCALBASE)/lib64/oracle$(ORAVERDIR) ) +-endif +-ifeq ($(ORAPATH),) +- ORAPATH=$(shell [ -f $(SYSBASE)/lib64/oracle$(ORAVERDIR)/libocci.so ] && \ +- echo $(SYSBASE)/lib64/oracle$(ORAVERDIR) ) +-endif +-ifeq ($(ORAPATH),) +- ORAPATH=$(shell [ -f $(SYSBASE)/lib/oracle$(ORAVERDIR)/libocci.so ] && \ +- echo $(SYSBASE)/lib/oracle$(ORAVERDIR) ) +-endif +-ifeq ($(ORAPATH),) +- ORAPATH=$(shell [ -f $(SYSBASE)/lib/oracle$(ORAVERDIR)/libocci.so ] && \ +- echo $(SYSBASE)/lib/oracle$(ORAVERDIR) ) +-endif +- +-ifneq ($(ORAPATH),) +- LIBS +=-L$(ORAPATH) +-endif +- +-LIBS +=-locci -lclntsh +- +-#DEFS +=-DLINUX -D_GNU_SOURCE -D_REENTRANT +-#LIBS +=-lpthread +- +-ifneq ($(ORAPATH),) +- LIBS +=-Wl,-rpath $(ORAPATH) +-endif ++DEFS +=-I$(ORAHOME)/include ++LIBS +=-L$(ORAHOME)/lib -locci -lclntsh + + include ../../Makefile.rules + +-- +1.7.11.2 + diff --git a/opensips-0002-backport-from-trunk-rev-9099.patch b/opensips-0002-backport-from-trunk-rev-9099.patch deleted file mode 100644 index 9395d3b..0000000 --- a/opensips-0002-backport-from-trunk-rev-9099.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 3fe207bbb9c719abd5483188e4cffa847c510b4c Mon Sep 17 00:00:00 2001 -From: vladut-paiu -Date: Thu, 14 Jun 2012 09:56:13 +0000 -Subject: [PATCH 02/13] backport from trunk (rev #9099) - -removed call to ns_get16 glibc private function -Credits to Peter Lemenkov ---- - resolve.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/resolve.c b/resolve.c -index 57c1538..d4fd2d7 100644 ---- a/resolve.c -+++ b/resolve.c -@@ -205,7 +205,7 @@ int get_dns_answer(union dns_query *answer,int anslen,char *qname,int qtype,int - if (ttl<*min_ttl) - *min_ttl=ttl; - cp +=4; -- n = ns_get16(cp); -+ n = dns_get16(cp); - cp += 2; /* len */ - BOUNDS_CHECK(cp, n); - erdata = cp + n; --- -1.7.10.4 - diff --git a/opensips-0003-Backported-from-trunk-rev-9121.patch b/opensips-0003-Backported-from-trunk-rev-9121.patch deleted file mode 100644 index 85e7392..0000000 --- a/opensips-0003-Backported-from-trunk-rev-9121.patch +++ /dev/null @@ -1,40 +0,0 @@ -From d22103a9f14dc7b2f3fe4074d1b14c1d7f9cab6a Mon Sep 17 00:00:00 2001 -From: razvancrainea -Date: Wed, 27 Jun 2012 12:59:06 +0000 -Subject: [PATCH 03/13] Backported from trunk (rev# 9121): Fixed NICER - variable - ---- - Makefile | 2 +- - Makefile.defs | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/Makefile b/Makefile -index e52eafc..c787a04 100644 ---- a/Makefile -+++ b/Makefile -@@ -35,7 +35,7 @@ - #TLS=1 - #SCTP=1 - #FREERADIUS=1 --NICER=1 -+NICER?=1 - auto_gen=lex.yy.c cfg.tab.c #lexx, yacc etc - - #include source related defs -diff --git a/Makefile.defs b/Makefile.defs -index 8c02405..b585716 100644 ---- a/Makefile.defs -+++ b/Makefile.defs -@@ -140,7 +140,7 @@ endif - # nicer compilation? - Q= - NICER ?= --ifneq ($(NICER),) -+ifeq ($(NICER),1) - export Q=@ - endif - --- -1.7.10.4 - diff --git a/opensips-0003-Reset-column-types-to-NULL-upon-freeing-resultset-co.patch b/opensips-0003-Reset-column-types-to-NULL-upon-freeing-resultset-co.patch new file mode 100644 index 0000000..c778e4d --- /dev/null +++ b/opensips-0003-Reset-column-types-to-NULL-upon-freeing-resultset-co.patch @@ -0,0 +1,25 @@ +From 1367f5bb674eeb30881a13987cd95d553df0d921 Mon Sep 17 00:00:00 2001 +From: vladut-paiu +Date: Tue, 3 Jul 2012 09:34:52 +0000 +Subject: [PATCH 3/5] Reset column types to NULL upon freeing resultset + columns Credit to Peter Lemenkov + +--- + db/db_res.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/db/db_res.c b/db/db_res.c +index 78868ec..cbba30f 100644 +--- a/db/db_res.c ++++ b/db/db_res.c +@@ -77,6 +77,7 @@ int db_free_columns(db_res_t* _r) + /* free names and types */ + if (RES_NAMES(_r)) { + LM_DBG("freeing result columns at %p\n", RES_NAMES(_r)); ++ RES_TYPES(_r) = NULL; + pkg_free(RES_NAMES(_r)); + RES_NAMES(_r) = NULL; + } +-- +1.7.11.2 + diff --git a/opensips-0004-db_oracle-typo-fixes.patch b/opensips-0004-db_oracle-typo-fixes.patch deleted file mode 100644 index 6679f3d..0000000 --- a/opensips-0004-db_oracle-typo-fixes.patch +++ /dev/null @@ -1,129 +0,0 @@ -From 6bd50b3eaff70e299f4ee6489d6ebf8b327d2480 Mon Sep 17 00:00:00 2001 -From: osas -Date: Tue, 26 Jun 2012 14:41:27 +0000 -Subject: [PATCH 04/13] db_oracle: typo fixes - closes bug id: 3535168 - - backport from trunk rev 9116 - ---- - modules/db_oracle/db_oracle.c | 2 +- - modules/db_oracle/res.c | 22 +++++++++++----------- - 2 files changed, 12 insertions(+), 12 deletions(-) - -diff --git a/modules/db_oracle/db_oracle.c b/modules/db_oracle/db_oracle.c -index 4796440..70cfe40 100644 ---- a/modules/db_oracle/db_oracle.c -+++ b/modules/db_oracle/db_oracle.c -@@ -60,7 +60,7 @@ static param_export_t params[] = { - - - struct module_exports exports = { -- "oracle", -+ "db_oracle", - MODULE_VERSION, - DEFAULT_DLFLAGS, /* dlopen flags */ - cmds, -diff --git a/modules/db_oracle/res.c b/modules/db_oracle/res.c -index 12a6480..3230721 100644 ---- a/modules/db_oracle/res.c -+++ b/modules/db_oracle/res.c -@@ -84,7 +84,7 @@ static int get_columns(ora_con_t* con, db_res_t* _r, OCIStmt* _c, dmap_t* _d) - } - - if (db_allocate_columns(_r, n) != 0) { -- LM_ERR("could not allocate columns"); -+ LM_ERR("could not allocate columns\n"); - return -4; - } - memset(RES_NAMES(_r), 0, sizeof(db_key_t) * n); -@@ -126,14 +126,14 @@ static int get_columns(ora_con_t* con, db_res_t* _r, OCIStmt* _c, dmap_t* _d) - switch (dtype) { - case SQLT_UIN: /* unsigned integer */ - set_bitmap: -- LM_DBG("use DB_BITMAP type"); -+ LM_DBG("use DB_BITMAP type\n"); - RES_TYPES(_r)[i] = DB_BITMAP; - len = sizeof(VAL_BITMAP((db_val_t*)NULL)); - break; - - case SQLT_INT: /* (ORANET TYPE) integer */ - set_int: -- LM_DBG("use DB_INT result type"); -+ LM_DBG("use DB_INT result type\n"); - RES_TYPES(_r)[i] = DB_INT; - len = sizeof(VAL_INT((db_val_t*)NULL)); - break; -@@ -159,7 +159,7 @@ set_int: - goto set_bitmap; - } - } -- LM_DBG("use DB_BIGINT result type"); -+ LM_DBG("use DB_BIGINT result type\n"); - RES_TYPES(_r)[i] = DB_BIGINT; - len = sizeof(VAL_BIGINT((db_val_t*)NULL)); - dtype = SQLT_NUM; -@@ -171,7 +171,7 @@ set_int: - case SQLT_IBFLOAT: /* binary float canonical */ - case SQLT_IBDOUBLE: /* binary double canonical */ - case SQLT_PDN: /* (ORANET TYPE) Packed Decimal Numeric */ -- LM_DBG("use DB_DOUBLE result type"); -+ LM_DBG("use DB_DOUBLE result type\n"); - RES_TYPES(_r)[i] = DB_DOUBLE; - len = sizeof(VAL_DOUBLE((db_val_t*)NULL)); - dtype = SQLT_FLT; -@@ -187,7 +187,7 @@ set_int: - case SQLT_TIMESTAMP_LTZ:/* TIMESTAMP WITH LOCAL TZ */ - // case SQLT_INTERVAL_YM: /* INTERVAL YEAR TO MONTH */ - // case SQLT_INTERVAL_DS: /* INTERVAL DAY TO SECOND */ -- LM_DBG("use DB_DATETIME result type"); -+ LM_DBG("use DB_DATETIME result type\n"); - RES_TYPES(_r)[i] = DB_DATETIME; - len = sizeof(OCIDate); - dtype = SQLT_ODT; -@@ -199,7 +199,7 @@ set_int: - // case SQLT_CFILEE: /* character file lob */ - // case SQLT_BIN: /* binary data(DTYBIN) */ - // case SQLT_LBI: /* long binary */ -- LM_DBG("use DB_BLOB result type"); -+ LM_DBG("use DB_BLOB result type\n"); - RES_TYPES(_r)[i] = DB_BLOB; - goto dyn_str; - -@@ -210,7 +210,7 @@ set_int: - case SQLT_AFC: /* Ansi fixed char */ - case SQLT_AVC: /* Ansi Var char */ - // case SQLT_RID: /* rowid */ -- LM_DBG("use DB_STR result type"); -+ LM_DBG("use DB_STR result type\n"); - RES_TYPES(_r)[i] = DB_STR; - dyn_str: - dtype = SQLT_CHR; -@@ -220,7 +220,7 @@ dyn_str: - con->errhp); - if (status != OCI_SUCCESS) goto ora_err; - if (len >= 4000) { -- LM_DBG("use DB_BLOB result type"); -+ LM_DBG("use DB_BLOB result type\n"); - RES_TYPES(_r)[i] = DB_BLOB; - } - ++len; -@@ -243,7 +243,7 @@ dyn_str: - #error - #endif - if (tsz > 65536) { -- LM_ERR("Row size exceed 65K. IOB's are not supported"); -+ LM_ERR("Row size exceed 65K. IOB's are not supported\n"); - goto stop_load; - } - return 0; -@@ -399,7 +399,7 @@ static int get_rows(ora_con_t* con, db_res_t* _r, OCIStmt* _c, dmap_t* _d) - - while ( 1 ) { - if (convert_row(_r, &RES_ROWS(_r)[--rcnt], _d) < 0) { -- LM_ERR("erroc convert row\n"); -+ LM_ERR("error convert row\n"); - goto stop_load; - } - --- -1.7.10.4 - diff --git a/opensips-0004-fixed-DB-type-inconsistency.patch b/opensips-0004-fixed-DB-type-inconsistency.patch new file mode 100644 index 0000000..4deaee5 --- /dev/null +++ b/opensips-0004-fixed-DB-type-inconsistency.patch @@ -0,0 +1,30 @@ +From 491b37a23ae25b5e585f3324dc581d3b5ede0559 Mon Sep 17 00:00:00 2001 +From: vladut-paiu +Date: Tue, 3 Jul 2012 10:01:52 +0000 +Subject: [PATCH 4/5] fixed DB type inconsistency Credits to Peter Lemenkov + +--- + modules/usrloc/ucontact.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/modules/usrloc/ucontact.c b/modules/usrloc/ucontact.c +index 17992d5..ea400d2 100644 +--- a/modules/usrloc/ucontact.c ++++ b/modules/usrloc/ucontact.c +@@ -605,11 +605,11 @@ int db_update_ucontact(ucontact_t* _c) + vals2[2].nul = 0; + vals2[2].val.int_val = _c->cseq; + +- vals2[3].type = DB_INT; ++ vals2[3].type = DB_BITMAP; + vals2[3].nul = 0; + vals2[3].val.bitmap_val = _c->flags; + +- vals2[4].type = DB_INT; ++ vals2[4].type = DB_BITMAP; + vals2[4].nul = 0; + vals2[4].val.bitmap_val = _c->cflags; + +-- +1.7.11.2 + diff --git a/opensips-0005-Drop-rpath-from-Oracle-s-module.patch b/opensips-0005-Drop-rpath-from-Oracle-s-module.patch deleted file mode 100644 index 796019c..0000000 --- a/opensips-0005-Drop-rpath-from-Oracle-s-module.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 2bd1b8d6b84f7e34adf802ffeec2cc0bd0247104 Mon Sep 17 00:00:00 2001 -From: Peter Lemenkov -Date: Thu, 14 Jun 2012 11:38:48 +0400 -Subject: [PATCH 05/13] Drop rpath from Oracle's module - -Signed-off-by: Peter Lemenkov ---- - modules/db_oracle/Makefile | 4 ---- - utils/db_oracle/Makefile | 4 ---- - 2 files changed, 8 deletions(-) - -diff --git a/modules/db_oracle/Makefile b/modules/db_oracle/Makefile -index 6b7e685..3a240f4 100644 ---- a/modules/db_oracle/Makefile -+++ b/modules/db_oracle/Makefile -@@ -55,8 +55,4 @@ LIBS +=-locci -lclntsh - #DEFS+=-DLINUX -D_GNU_SOURCE -D_REENTRANT - #LIBS+=-lpthread - --ifneq ($(ORAPATH),) -- LIBS +=-Wl,-rpath $(ORAPATH) --endif -- - include ../../Makefile.modules -diff --git a/utils/db_oracle/Makefile b/utils/db_oracle/Makefile -index b1c8231..edf1a3b 100644 ---- a/utils/db_oracle/Makefile -+++ b/utils/db_oracle/Makefile -@@ -57,10 +57,6 @@ LIBS +=-locci -lclntsh - #DEFS +=-DLINUX -D_GNU_SOURCE -D_REENTRANT - #LIBS +=-lpthread - --ifneq ($(ORAPATH),) -- LIBS +=-Wl,-rpath $(ORAPATH) --endif -- - include ../../Makefile.rules - - modules: --- -1.7.10.4 - diff --git a/opensips-0005-Removed-all-async-Oracle-operations-they-didn-t-work.patch b/opensips-0005-Removed-all-async-Oracle-operations-they-didn-t-work.patch new file mode 100644 index 0000000..17506e3 --- /dev/null +++ b/opensips-0005-Removed-all-async-Oracle-operations-they-didn-t-work.patch @@ -0,0 +1,621 @@ +From 2097ba18efdfd5f98a726eb1890aa61723b3807e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9=20=D0=A1=D0=B0=D0=BC=D1?= + =?UTF-8?q?=83=D1=81=D0=B5=D0=BD=D0=BA=D0=BE?= +Date: Mon, 25 Jun 2012 17:54:27 +0400 +Subject: [PATCH 5/5] Removed all async Oracle operations - they didn't work + well anyway + +--- + modules/db_oracle/asynch.c | 270 ------------------------------------------ + modules/db_oracle/asynch.h | 62 ---------- + modules/db_oracle/db_oracle.c | 2 +- + modules/db_oracle/dbase.c | 53 +++------ + modules/db_oracle/ora_con.c | 73 ++++-------- + modules/db_oracle/ora_con.h | 3 +- + modules/db_oracle/res.c | 114 ++++++++++-------- + modules/db_oracle/timer.c | 131 ++++++++++++++++++++ + modules/db_oracle/timer.h | 22 ++++ + 9 files changed, 258 insertions(+), 472 deletions(-) + delete mode 100644 modules/db_oracle/asynch.c + delete mode 100644 modules/db_oracle/asynch.h + create mode 100644 modules/db_oracle/timer.c + create mode 100644 modules/db_oracle/timer.h + +diff --git a/modules/db_oracle/db_oracle.c b/modules/db_oracle/db_oracle.c +index 70cfe40..40c7692 100644 +--- a/modules/db_oracle/db_oracle.c ++++ b/modules/db_oracle/db_oracle.c +@@ -31,7 +31,7 @@ + #include "../../sr_module.h" + #include "../../db/db.h" + #include "dbase.h" +-#include "asynch.h" ++#include "timer.h" + + static int oracle_mod_init(void); + static void destroy(void); +diff --git a/modules/db_oracle/dbase.c b/modules/db_oracle/dbase.c +index d129e11..be2352e 100644 +--- a/modules/db_oracle/dbase.c ++++ b/modules/db_oracle/dbase.c +@@ -36,7 +36,7 @@ + #include "val.h" + #include "ora_con.h" + #include "res.h" +-#include "asynch.h" ++#include "timer.h" + #include "dbase.h" + + +@@ -212,7 +212,6 @@ static int db_oracle_submit_query(const db_con_t* _h, const str* _s) + OCIDate odt[sizeof(bind)/sizeof(bind[0])]; + str tmps; + sword status; +- int pass; + ora_con_t* con = CON_ORA(_h); + query_data_t* pqd = con->pqdata; + size_t hc = pqd->_n + pqd->_nw; +@@ -223,32 +222,16 @@ static int db_oracle_submit_query(const db_con_t* _h, const str* _s) + (unsigned)hc); + return -1; + } +- +- if (!pqd->_rs) { +- /* +- * This method is at ~25% faster as set OCI_COMMIT_ON_SUCCESS +- * in StmtExecute +- */ +- tmps.len = snprintf(st_buf, sizeof(st_buf), +- "begin %.*s; commit write batch nowait; end;", +- _s->len, _s->s); +- if ((unsigned)tmps.len >= sizeof(st_buf)) +- return sql_buf_small(); +- tmps.s = st_buf; +- _s = &tmps; +- } + +- pass = 1; +- if (!con->connected) { ++ if (con->connected != 2) { + status = db_oracle_reconnect(con); + if (status != OCI_SUCCESS) { + LM_ERR("can't restore connection: %s\n", db_oracle_error(con, status)); + return -2; + } + LM_INFO("connection restored\n"); +- --pass; + } +-repeat: ++ + stmthp = NULL; + status = OCIHandleAlloc(con->envhp, (dvoid**)(dvoid*)&stmthp, + OCI_HTYPE_STMT, 0, NULL); +@@ -291,14 +274,10 @@ bind_err: + } + } + +- // timelimited operation +- status = begin_timelimit(con, 0); +- if (status != OCI_SUCCESS) goto ora_err; +- do status = OCIStmtExecute(con->svchp, stmthp, con->errhp, +- !pqd->_rs, 0, NULL, NULL, +- pqd->_rs ? OCI_STMT_SCROLLABLE_READONLY : OCI_DEFAULT); +- while (wait_timelimit(con, status)); +- if (done_timelimit(con, status)) goto stop_exec; ++ request_timer(); ++ status = OCIStmtExecute(con->svchp, stmthp, con->errhp, ++ !pqd->_rs, 0, NULL, NULL, pqd->_rs ? OCI_DEFAULT : OCI_COMMIT_ON_SUCCESS); ++ timer_stop(); + switch (status) { + case OCI_SUCCESS_WITH_INFO: + LM_WARN("driver: %s\n", db_oracle_errorinfo(con)); +@@ -310,8 +289,8 @@ bind_err: + OCIHandleFree(stmthp, OCI_HTYPE_STMT); + return 0; + default: +- pass = -pass; +- break; ++ LM_ERR("timeout/not connected to oracle\n"); ++ break; + } + + ora_err: +@@ -319,15 +298,13 @@ ora_err: + stop_exec: + if (stmthp) + OCIHandleFree(stmthp, OCI_HTYPE_STMT); +- if (pass == -1 && !con->connected) { +- /* Attemtp to reconnect */ +- if (db_oracle_reconnect(con) == OCI_SUCCESS) { +- LM_NOTICE("attempt repeat after reconnect\n"); +- pass = 0; +- goto repeat; +- } ++ LM_INFO("reconnecting to oracle...\n"); ++ /* Attempt to reconnect */ ++ if (db_oracle_reconnect(con) == OCI_SUCCESS) ++ LM_INFO("connection restored\n"); ++ else + LM_ERR("connection loss\n"); +- } ++ + return -4; + } + +diff --git a/modules/db_oracle/ora_con.c b/modules/db_oracle/ora_con.c +index 73ced27..f03f753 100644 +--- a/modules/db_oracle/ora_con.c ++++ b/modules/db_oracle/ora_con.c +@@ -22,9 +22,10 @@ + + #include + #include ++#include + #include "../../mem/mem.h" + #include "../../dprint.h" +-#include "asynch.h" ++#include "timer.h" + #include "ora_con.h" + + /*************************************************************************/ +@@ -105,6 +106,12 @@ bad_param: + status = OCIAttrSet(con->svchp, OCI_HTYPE_SVCCTX, con->authp, 0, + OCI_ATTR_SESSION, con->errhp); + if (status != OCI_SUCCESS) goto connect_err; ++ ++ if (init_ora_timer(con) != 0) { ++ LM_ERR("can't start oracle timer thread\n"); ++ goto drop_connection; ++ } ++ + status = db_oracle_reconnect(con); + if (status != OCI_SUCCESS) { + connect_err: +@@ -122,12 +129,11 @@ drop_connection: + } + + // timelimited operation +- status = begin_timelimit(con, 0); +- if (status != OCI_SUCCESS) goto connect_err; +- do status = OCIServerVersion(con->svchp, con->errhp, (OraText*)buf, ++ request_timer(); ++ status = OCIServerVersion(con->svchp, con->errhp, (OraText*)buf, + (ub4)sizeof(buf), OCI_HTYPE_SVCCTX); +- while (wait_timelimit(con, status)); +- if (done_timelimit(con, status)) goto drop_connection; ++ timer_stop(); ++ + if (status != OCI_SUCCESS) goto connect_err; + LM_INFO("server version is %s\n", buf); + return con; +@@ -139,6 +145,7 @@ drop_connection: + */ + void db_oracle_free_connection(ora_con_t* con) + { ++ destroy_ora_timer(con); + if (!con) return; + + if (con->connected) +@@ -164,20 +171,17 @@ void db_oracle_free_connection(ora_con_t* con) + void db_oracle_disconnect(ora_con_t* con) + { + sword status; +- +- switch (con->connected) { +- default: +- status = OCISessionEnd(con->svchp, con->errhp, con->authp, +- OCI_DEFAULT); +- if (status != OCI_SUCCESS) +- LM_ERR("driver: %s\n", db_oracle_error(con, status)); +- case 1: ++ if (con->connected > 0) { ++ if (con->connected > 1) { ++ status = OCISessionEnd(con->svchp, con->errhp, con->authp, ++ OCI_DEFAULT); ++ if (status != OCI_SUCCESS) ++ LM_ERR("driver: %s\n", db_oracle_error(con, status)); ++ } + status = OCIServerDetach(con->srvhp, con->errhp, OCI_DEFAULT); + if (status != OCI_SUCCESS) + LM_ERR("driver: %s\n", db_oracle_error(con, status)); + con->connected = 0; +- case 0: +- break; + } + } + +@@ -192,48 +196,19 @@ sword db_oracle_reconnect(ora_con_t* con) + if (con->connected) + db_oracle_disconnect(con); + +- /* timelimited operation, but OCI tcp-network does not support it :( */ ++ restore_timer(); + status = OCIServerAttach(con->srvhp, con->errhp, (OraText*)con->uri, + con->uri_len, 0); ++ timer_stop(); + if (status == OCI_SUCCESS) { + ++con->connected; +- /* +- * timelimited operation, but OCI has BUG in asynch +- * implementation of OCISessionBegin :(. +- * +- * Next code is 'empiric hack' that work (tested) in v10/v11. +- */ +- status = begin_timelimit(con, 1); +- if (status != OCI_SUCCESS) goto done; ++ request_timer(); + status = OCISessionBegin(con->svchp, con->errhp, con->authp, + OCI_CRED_RDBMS, OCI_DEFAULT); +- while (wait_timelimit(con, status)) { +- sword code; +- +- status = OCIServerVersion(con->svchp, con->errhp, NULL, +- 0, OCI_HTYPE_SVCCTX); +- +- if ( status != OCI_ERROR +- || OCIErrorGet(con->errhp, 1, NULL, &code, NULL, 0, +- OCI_HTYPE_ERROR) != OCI_SUCCESS) break; +- switch (code) { +- case 24909: /* other call in progress */ +- status = OCI_STILL_EXECUTING; +- continue; +- +- case 3127: /* no new operation until active ends */ +- status = OCISessionBegin(con->svchp, con->errhp, +- con->authp, OCI_CRED_RDBMS, OCI_DEFAULT); +- default: +- break; +- } +- break; +- } +- if (done_timelimit(con, status)) goto done; ++ timer_stop(); + + if (status == OCI_SUCCESS) + ++con->connected; + } +-done: + return status; + } +diff --git a/modules/db_oracle/ora_con.h b/modules/db_oracle/ora_con.h +index 5835ffe..7267bee 100644 +--- a/modules/db_oracle/ora_con.h ++++ b/modules/db_oracle/ora_con.h +@@ -50,7 +50,8 @@ struct ora_con { + + int connected; /* Authorized session started */ + int bindpos; /* Last Bind handle position */ +- ++ pthread_t timer; ++ + query_data_t* pqdata; /* Temporary: cb data for submit_query/store_result */ + + int uri_len; +diff --git a/modules/db_oracle/res.c b/modules/db_oracle/res.c +index e9e6233..22f10ee 100644 +--- a/modules/db_oracle/res.c ++++ b/modules/db_oracle/res.c +@@ -32,7 +32,7 @@ + #include "../../dprint.h" + #include "ora_con.h" + #include "dbase.h" +-#include "asynch.h" ++#include "timer.h" + #include "res.h" + + +@@ -54,6 +54,10 @@ struct dmap { + }; + typedef struct dmap dmap_t; + ++typedef struct ora_row { ++ struct db_row hdr; ++ struct ora_row* next; ++} ora_row_t; + + /* + * Get and convert columns from a result. Define handlers and buffers +@@ -211,8 +215,8 @@ set_int: + case SQLT_AFC: /* Ansi fixed char */ + case SQLT_AVC: /* Ansi Var char */ + // case SQLT_RID: /* rowid */ +- LM_DBG("use DB_STR result type\n"); +- RES_TYPES(_r)[i] = DB_STR; ++ LM_DBG("use DB_STRING result type\n"); ++ RES_TYPES(_r)[i] = DB_STRING; + dyn_str: + dtype = SQLT_CHR; + len = 0; /* DATA_SIZE is ub2 */ +@@ -362,66 +366,74 @@ static int convert_row(db_res_t* _res, db_row_t* _r, dmap_t* _d) + */ + static int get_rows(ora_con_t* con, db_res_t* _r, OCIStmt* _c, dmap_t* _d) + { +- ub4 rcnt; ++ ub4 i = 0, rcnt = 0; + sword status; + unsigned n = RES_COL_N(_r); +- ++ // Since OCI have not "mysql_num_rows()", sequentialy fetch all rows into tmp area orow_list. ++ // Then call db_allocate_rows() and copy tmp to db module. ++ ora_row_t *orow_list = NULL, *orow_it, *orow_tail; ++ + memcpy(_d->len, _d->ilen, sizeof(_d->len[0]) * n); +- +- // timelimited operation +- status = begin_timelimit(con, 0); +- if (status != OCI_SUCCESS) goto ora_err; +- do status = OCIStmtFetch2(_c, con->errhp, 1, OCI_FETCH_NEXT, 0, +- OCI_DEFAULT); +- while (wait_timelimit(con, status)); +- if (done_timelimit(con, status)) goto stop_load; +- if (status != OCI_SUCCESS) { +- if (status != OCI_NO_DATA) +- goto ora_err; +- +- RES_ROW_N(_r) = 0; +- RES_ROWS(_r) = NULL; +- return 0; +- } +- +- status = OCIAttrGet(_c, OCI_HTYPE_STMT, &rcnt, NULL, +- OCI_ATTR_CURRENT_POSITION, con->errhp); +- if (status != OCI_SUCCESS) goto ora_err; +- if (!rcnt) { +- LM_ERR("lastpos==0\n"); +- goto stop_load; ++ ++ request_timer(); ++ while ((status = OCIStmtFetch2(_c, con->errhp, 1, OCI_FETCH_NEXT, 0, ++ OCI_DEFAULT)) == OCI_SUCCESS) { ++ timer_stop(); ++ ++ orow_it = (ora_row_t*) pkg_malloc(sizeof(ora_row_t) + sizeof(db_val_t)*RES_COL_N(_r)); ++ if (orow_it == NULL) { ++ LM_ERR("no private memory left\n"); ++ goto stop_load; ++ } ++ memset(orow_it, 0, sizeof(ora_row_t) + sizeof(db_val_t)*RES_COL_N(_r)); ++ orow_it->hdr.values = (db_val_t*)(orow_it+1); ++ ++ if (orow_list == NULL) ++ orow_list = orow_it; ++ else ++ orow_tail->next = orow_it; ++ orow_tail = orow_it; ++ ++ if (convert_row(_r, &orow_it->hdr, _d) < 0) { ++ LM_ERR("erroc convert row\n"); ++ goto stop_load; ++ } ++ memcpy(_d->len, _d->ilen, sizeof(_d->len[0]) * n); ++ ++rcnt; ++ request_timer(); + } +- ++ timer_stop(); ++ if (status != OCI_NO_DATA) ++ goto ora_err; ++ + RES_ROW_N(_r) = rcnt; + if (db_allocate_rows( _r, rcnt)!=0) { + LM_ERR("no private memory left\n"); +- return -1; ++ goto stop_load; + } +- +- while ( 1 ) { +- if (convert_row(_r, &RES_ROWS(_r)[--rcnt], _d) < 0) { +- LM_ERR("error convert row\n"); +- goto stop_load; +- } +- +- if (!rcnt) +- return 0; +- +- memcpy(_d->len, _d->ilen, sizeof(_d->len[0]) * n); +- // timelimited operation +- status = begin_timelimit(con, 0); +- if (status != OCI_SUCCESS) goto ora_err; +- do status = OCIStmtFetch2(_c, con->errhp, 1, OCI_FETCH_PRIOR, 0, +- OCI_DEFAULT); +- while (wait_timelimit(con, status)); +- if (done_timelimit(con, status)) goto stop_load; +- if (status != OCI_SUCCESS) break; ++ ++ for (orow_it = orow_list; orow_it; orow_it = orow_it->next) { ++ memcpy(ROW_VALUES(&RES_ROWS(_r)[i]), ROW_VALUES(&orow_it->hdr), sizeof(db_val_t)*RES_COL_N(_r)); ++ ROW_N(&RES_ROWS(_r)[i]) = ROW_N(&orow_it->hdr); ++ ++i; ++ } ++ ++ for (orow_it = orow_list; orow_it; orow_it = orow_list) { ++ orow_list = orow_it->next; ++ pkg_free(orow_it); ++ orow_it = NULL; + } ++ return 0; ++ + ora_err: + LM_ERR("driver: %s\n", db_oracle_error(con, status)); + stop_load: +- db_free_rows(_r); +- RES_ROW_N(_r) = 0; /* TODO: skipped in db_res.c :) */ ++ for (orow_it = orow_list; orow_it; orow_it = orow_list) { ++ orow_list = orow_it->next; ++ db_free_row(&orow_it->hdr); ++ pkg_free(orow_it); ++ orow_it = NULL; ++ } + return -3; + } + +diff --git a/modules/db_oracle/timer.c b/modules/db_oracle/timer.c +new file mode 100644 +index 0000000..50484f4 +--- /dev/null ++++ b/modules/db_oracle/timer.c +@@ -0,0 +1,131 @@ ++#include "timer.h" ++#include "../../dprint.h" ++#include "../../sr_module.h" ++ ++#include ++#include ++#include ++#include ++ ++#define MAX_TIMEOUT_S 10 ++#define MIN_TIMEOUT_MCS 100000 ++ ++/* Default is 3.0 second */ ++struct itimerval request_tm = {{0,0}, {3,0}}; ++// unsigned request_tm; ++ ++/* Default is 0.2 second */ ++struct itimerval restore_tm = {{0,0}, {0,200000}}; ++ ++struct itimerval stop_tm = {{0,0}, {0,0}}; ++ ++/* Simple error handling functions */ ++ ++#define handle_error_en(en, msg) \ ++ do { LM_ERR(msg": %s\n", strerror(en)); return 1; } while (0) ++ ++static ora_con_t *g_con; ++ ++static int set_tv(unsigned type, const char* val, struct timeval* tv) ++{ ++ char *eptr; ++ struct itimerval tt; ++ unsigned long s, ms; ++ double dv; ++ ++ if (type != STR_PARAM) { ++ LM_ERR("type of parameter is no STR\n"); ++ return -1; ++ } ++ ++ if (!val || !*val) { ++ LM_ERR("empty parameter\n"); ++ return -1; ++ } ++ ++ errno = 0; ++ dv = strtod(val, &eptr); ++ ++ if (*eptr) { ++ LM_ERR("invalid parameter string\n"); ++ return -2; ++ } ++ ++ if ( errno ++ || dv > (double)MAX_TIMEOUT_S ++ || (dv < ((double)MIN_TIMEOUT_MCS)/100000)) ++ { ++ LM_ERR("value must be between 0.%.6u and %u.0\n", ++ MIN_TIMEOUT_MCS, MAX_TIMEOUT_S); ++ return -3; ++ } ++ ++ s = (unsigned)dv; ++ dv -= (double)s; ++ ms = (unsigned)(dv * 1000000); ++ tv->tv_sec = (time_t)s; ++ tv->tv_usec = (suseconds_t)ms; ++ return 0; ++} ++ ++ ++/* ++ * set operation timeout ++ */ ++int set_timeout(unsigned type, const char* val) ++{ ++ return set_tv(type, val, &request_tm.it_value); ++} ++ ++ ++/* ++ * set (re)connect timeout ++ */ ++int set_reconnect(unsigned type, const char* val) ++{ ++ return set_tv(type, val, &restore_tm.it_value); ++} ++ ++void ora_alarm_handle(int sig) { ++ LM_INFO("ora_alarm_handle\n"); ++ sword status; ++ status = OCIBreak(g_con->svchp, g_con->errhp); ++ if (status != OCI_SUCCESS) { ++ LM_ERR("OCIBreak: %s\n", db_oracle_error(g_con, status)); ++ } ++} ++ ++int init_ora_timer(ora_con_t* con) { ++ g_con = con; ++ struct sigaction sa; ++ memset(&sa, 0, sizeof(sa)); ++ sa.sa_handler = ora_alarm_handle; ++ if (sigaction(SIGALRM, &sa, NULL) < -1) ++ handle_error_en(errno, "sigaction"); ++ ++ return 0; ++} ++ ++int destroy_ora_timer() ++{ ++ timer_stop(); ++} ++ ++void request_timer() ++{ ++ if (setitimer(ITIMER_REAL, &request_tm, NULL) < 0) ++ LM_ERR("setitimer: %s\n", strerror(errno)); ++} ++ ++void restore_timer() ++{ ++ if (setitimer(ITIMER_REAL, &restore_tm, NULL) < 0) ++ LM_ERR("setitimer: %s\n", strerror(errno)); ++} ++ ++void timer_stop() ++{ ++ if (setitimer(ITIMER_REAL, &stop_tm, NULL) < 0) ++ LM_ERR("setitimer: %s\n", strerror(errno)); ++} ++ +\ No newline at end of file +diff --git a/modules/db_oracle/timer.h b/modules/db_oracle/timer.h +new file mode 100644 +index 0000000..24aa4a9 +--- /dev/null ++++ b/modules/db_oracle/timer.h +@@ -0,0 +1,22 @@ ++#ifndef ORA_TIMER_H ++#define ORA_TIMER_H ++ ++#include "ora_con.h" ++ ++/* ++ * parse timeout value for operation in syntax: nnn.mmm (sec/ms) ++ */ ++int set_timeout(unsigned type, const char* val); ++ ++/* ++ * parse timeout value for reconnect in syntax: nnn.mmm (sec/ms) ++ */ ++int set_reconnect(unsigned type, const char* val); ++ ++int init_ora_timer(ora_con_t* con); ++int destroy_ora_timer(); ++ ++void request_timer(); ++void restore_timer(); ++void timer_stop(); ++#endif // ORA_TIMER_H +\ No newline at end of file +-- +1.7.11.2 + diff --git a/opensips-0006-Clean-Makefile-for-Oracle.patch b/opensips-0006-Clean-Makefile-for-Oracle.patch deleted file mode 100644 index 5fd1cfd..0000000 --- a/opensips-0006-Clean-Makefile-for-Oracle.patch +++ /dev/null @@ -1,72 +0,0 @@ -From dd96303016e7fd149a7a3da3db09f2e6db5c384b Mon Sep 17 00:00:00 2001 -From: Peter Lemenkov -Date: Thu, 14 Jun 2012 11:39:39 +0400 -Subject: [PATCH 06/13] Clean Makefile for Oracle - -Signed-off-by: Peter Lemenkov ---- - modules/db_oracle/Makefile | 48 +------------------------------------------- - 1 file changed, 1 insertion(+), 47 deletions(-) - -diff --git a/modules/db_oracle/Makefile b/modules/db_oracle/Makefile -index 3a240f4..a8f099e 100644 ---- a/modules/db_oracle/Makefile -+++ b/modules/db_oracle/Makefile -@@ -6,53 +6,7 @@ include ../../Makefile.defs - auto_gen= - NAME=db_oracle.so - --# can be defined for non standard placement of oracle so's --ORAPATH= --LIBS= -- --# use for multiple client sdk version install --ifneq ($(ORAVERSION),) -- ORAVERDIR=/$(ORAVERSION) --endif -- --# use include/library path's for full client installation --ifneq ($(ORAHOME),) -- DEFS +=-I$(ORAHOME)/include -- LIBS +=-L$(ORAHOME)/lib --ifeq ($(ORAPATH),) -- ORAPATH=$(ORAHOME)/lib --endif --else --# use standard know paths oci.h locations (linux) --DEFS +=-I$(LOCALBASE)/include/oracle$(ORAVERDIR) \ -- -I$(SYSBASE)/include/oracle$(ORAVERDIR) --endif -- --# search 'so' path if it non standard (possible liboclntsh locations on linux) --ifeq ($(ORAPATH),) -- ORAPATH=$(shell [ -f $(LOCALBASE)/lib64/oracle$(ORAVERDIR)/libocci.so ] && \ -- echo $(LOCALBASE)/lib64/oracle$(ORAVERDIR) ) --endif --ifeq ($(ORAPATH),) -- ORAPATH=$(shell [ -f $(SYSBASE)/lib64/oracle$(ORAVERDIR)/libocci.so ] && \ -- echo $(SYSBASE)/lib64/oracle$(ORAVERDIR) ) --endif --ifeq ($(ORAPATH),) -- ORAPATH=$(shell [ -f $(SYSBASE)/lib/oracle$(ORAVERDIR)/libocci.so ] && \ -- echo $(SYSBASE)/lib/oracle$(ORAVERDIR) ) --endif --ifeq ($(ORAPATH),) -- ORAPATH=$(shell [ -f $(SYSBASE)/lib/oracle$(ORAVERDIR)/libocci.so ] && \ -- echo $(SYSBASE)/lib/oracle$(ORAVERDIR) ) --endif -- --ifneq ($(ORAPATH),) -- LIBS +=-L$(ORAPATH) --endif -- -+DEFS +=-I$(ORAHOME)/include - LIBS +=-locci -lclntsh - --#DEFS+=-DLINUX -D_GNU_SOURCE -D_REENTRANT --#LIBS+=-lpthread -- - include ../../Makefile.modules --- -1.7.10.4 - diff --git a/opensips-0007-Don-t-fetch-the-last-record-use-next-one.patch b/opensips-0007-Don-t-fetch-the-last-record-use-next-one.patch deleted file mode 100644 index ede76ce..0000000 --- a/opensips-0007-Don-t-fetch-the-last-record-use-next-one.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 2cb25437a2bc3f4e5b11ec3234f40dd98d9bdca1 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9=20=D0=A1=D0=B0=D0=BC=D1?= - =?UTF-8?q?=83=D1=81=D0=B5=D0=BD=D0=BA=D0=BE?= -Date: Thu, 14 Jun 2012 11:52:01 +0400 -Subject: [PATCH 07/13] Don't fetch the last record - use next one - ---- - modules/db_oracle/res.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/modules/db_oracle/res.c b/modules/db_oracle/res.c -index 3230721..1a0f9fe 100644 ---- a/modules/db_oracle/res.c -+++ b/modules/db_oracle/res.c -@@ -370,7 +370,7 @@ static int get_rows(ora_con_t* con, db_res_t* _r, OCIStmt* _c, dmap_t* _d) - // timelimited operation - status = begin_timelimit(con, 0); - if (status != OCI_SUCCESS) goto ora_err; -- do status = OCIStmtFetch2(_c, con->errhp, 1, OCI_FETCH_LAST, 0, -+ do status = OCIStmtFetch2(_c, con->errhp, 1, OCI_FETCH_NEXT, 0, - OCI_DEFAULT); - while (wait_timelimit(con, status)); - if (done_timelimit(con, status)) goto stop_load; --- -1.7.10.4 - diff --git a/opensips-0008-Fix-SQL-types.patch b/opensips-0008-Fix-SQL-types.patch deleted file mode 100644 index 1e394c9..0000000 --- a/opensips-0008-Fix-SQL-types.patch +++ /dev/null @@ -1,58 +0,0 @@ -From abf48e295a266b4a987c4f5283114bd80019a202 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9=20=D0=A1=D0=B0=D0=BC=D1?= - =?UTF-8?q?=83=D1=81=D0=B5=D0=BD=D0=BA=D0=BE?= -Date: Thu, 14 Jun 2012 11:55:35 +0400 -Subject: [PATCH 08/13] Fix SQL types - ---- - modules/db_oracle/val.c | 34 +++++++++++++++++++++++++++++++--- - 1 file changed, 31 insertions(+), 3 deletions(-) - -diff --git a/modules/db_oracle/val.c b/modules/db_oracle/val.c -index 85c0de7..80f4016 100644 ---- a/modules/db_oracle/val.c -+++ b/modules/db_oracle/val.c -@@ -58,9 +58,37 @@ int db_oracle_val2bind(bmap_t* _m, const db_val_t* _v, OCIDate* _o) - if (VAL_NULL(_v)) { - _m->addr = NULL; - _m->size = 0; -- _m->type = SQLT_NON; -- return 0; -- } -+ switch(VAL_TYPE(_v)) { -+ case DB_INT: -+ _m->type = SQLT_INT; -+ break; -+ case DB_BIGINT: -+ _m->type = SQLT_NUM; -+ break; -+ case DB_BITMAP: -+ _m->type = SQLT_UIN; -+ break; -+ case DB_DOUBLE: -+ _m->type = SQLT_FLT; -+ break; -+ case DB_STRING: -+ _m->type = SQLT_STR; -+ break; -+ case DB_STR: -+ _m->type = SQLT_CHR; -+ break; -+ case DB_DATETIME: -+ _m->type = SQLT_ODT; -+ break; -+ case DB_BLOB: -+ _m->type = SQLT_CLOB; -+ break; -+ default: -+ LM_ERR("unknown data type\n"); -+ return -1; -+ } -+ return 0; -+ } - - switch (VAL_TYPE(_v)) { - case DB_INT: --- -1.7.10.4 - diff --git a/opensips-0009-Reset-column-types-to-NULL-upon-freeing-resultset-co.patch b/opensips-0009-Reset-column-types-to-NULL-upon-freeing-resultset-co.patch deleted file mode 100644 index 1136977..0000000 --- a/opensips-0009-Reset-column-types-to-NULL-upon-freeing-resultset-co.patch +++ /dev/null @@ -1,25 +0,0 @@ -From f45b4ec621335dd1cbd36983cd16bb2c246f29cd Mon Sep 17 00:00:00 2001 -From: vladut-paiu -Date: Tue, 3 Jul 2012 09:34:52 +0000 -Subject: [PATCH 09/13] Reset column types to NULL upon freeing resultset - columns Credit to Peter Lemenkov - ---- - db/db_res.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/db/db_res.c b/db/db_res.c -index 78868ec..cbba30f 100644 ---- a/db/db_res.c -+++ b/db/db_res.c -@@ -77,6 +77,7 @@ int db_free_columns(db_res_t* _r) - /* free names and types */ - if (RES_NAMES(_r)) { - LM_DBG("freeing result columns at %p\n", RES_NAMES(_r)); -+ RES_TYPES(_r) = NULL; - pkg_free(RES_NAMES(_r)); - RES_NAMES(_r) = NULL; - } --- -1.7.10.4 - diff --git a/opensips-0010-fixed-DB-type-inconsistency.patch b/opensips-0010-fixed-DB-type-inconsistency.patch deleted file mode 100644 index eae9fd9..0000000 --- a/opensips-0010-fixed-DB-type-inconsistency.patch +++ /dev/null @@ -1,30 +0,0 @@ -From d4f6843c5669ff24460981619338699fba1fb22c Mon Sep 17 00:00:00 2001 -From: vladut-paiu -Date: Tue, 3 Jul 2012 10:01:52 +0000 -Subject: [PATCH 10/13] fixed DB type inconsistency Credits to Peter Lemenkov - ---- - modules/usrloc/ucontact.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/modules/usrloc/ucontact.c b/modules/usrloc/ucontact.c -index 17992d5..ea400d2 100644 ---- a/modules/usrloc/ucontact.c -+++ b/modules/usrloc/ucontact.c -@@ -605,11 +605,11 @@ int db_update_ucontact(ucontact_t* _c) - vals2[2].nul = 0; - vals2[2].val.int_val = _c->cseq; - -- vals2[3].type = DB_INT; -+ vals2[3].type = DB_BITMAP; - vals2[3].nul = 0; - vals2[3].val.bitmap_val = _c->flags; - -- vals2[4].type = DB_INT; -+ vals2[4].type = DB_BITMAP; - vals2[4].nul = 0; - vals2[4].val.bitmap_val = _c->cflags; - --- -1.7.10.4 - diff --git a/opensips-0011-Proper-memory-zeroing.patch b/opensips-0011-Proper-memory-zeroing.patch deleted file mode 100644 index 7b19e33..0000000 --- a/opensips-0011-Proper-memory-zeroing.patch +++ /dev/null @@ -1,27 +0,0 @@ -From aa98879132476af97f43eb3ea6b65b1305ebe283 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9=20=D0=A1=D0=B0=D0=BC=D1?= - =?UTF-8?q?=83=D1=81=D0=B5=D0=BD=D0=BA=D0=BE?= -Date: Thu, 14 Jun 2012 11:51:25 +0400 -Subject: [PATCH 11/13] Proper memory zeroing - ---- - modules/db_oracle/res.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/modules/db_oracle/res.c b/modules/db_oracle/res.c -index 1a0f9fe..e9e6233 100644 ---- a/modules/db_oracle/res.c -+++ b/modules/db_oracle/res.c -@@ -87,7 +87,8 @@ static int get_columns(ora_con_t* con, db_res_t* _r, OCIStmt* _c, dmap_t* _d) - LM_ERR("could not allocate columns\n"); - return -4; - } -- memset(RES_NAMES(_r), 0, sizeof(db_key_t) * n); -+ for (i = 0; i < n; ++i) -+ memset(RES_NAMES(_r)[i], 0, sizeof(db_key_t)); - - RES_COL_N(_r) = n; - --- -1.7.10.4 - diff --git a/opensips-0012-Free-columns-data-only-in-Oracle.patch b/opensips-0012-Free-columns-data-only-in-Oracle.patch deleted file mode 100644 index 1a784a4..0000000 --- a/opensips-0012-Free-columns-data-only-in-Oracle.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 6ee02b3d27f241dc8ea262ae4233a9e6ef18a0cd Mon Sep 17 00:00:00 2001 -From: Peter Lemenkov -Date: Fri, 29 Jun 2012 14:10:32 +0400 -Subject: [PATCH 12/13] Free columns data only in Oracle - ---- - modules/db_oracle/dbase.c | 7 +++++++ - 1 file changed, 7 insertions(+) - -diff --git a/modules/db_oracle/dbase.c b/modules/db_oracle/dbase.c -index 4dcc757..d129e11 100644 ---- a/modules/db_oracle/dbase.c -+++ b/modules/db_oracle/dbase.c -@@ -182,11 +182,18 @@ void db_oracle_close(db_con_t* _h) - */ - int db_oracle_free_result(db_con_t* _h, db_res_t* _r) - { -+ ub4 i; -+ - if (!_h || !_r) { - LM_ERR("invalid parameter value\n"); - return -1; - } - -+ if (RES_NAMES(_r)) -+ for (i=0; i < RES_COL_N(_r); ++i) -+ if (RES_NAMES(_r)[i]->s) -+ pkg_free(RES_NAMES(_r)[i]->s); -+ - if (db_free_result(_r) < 0) - { - LM_ERR("failed to free result structure\n"); --- -1.7.10.4 - diff --git a/opensips-0013-Removed-all-async-Oracle-operations-they-didn-t-work.patch b/opensips-0013-Removed-all-async-Oracle-operations-they-didn-t-work.patch deleted file mode 100644 index 890fd5a..0000000 --- a/opensips-0013-Removed-all-async-Oracle-operations-they-didn-t-work.patch +++ /dev/null @@ -1,610 +0,0 @@ -From ae9ec4f6793f7278d00d2b93eb671480a4cac40c Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9=20=D0=A1=D0=B0=D0=BC=D1?= - =?UTF-8?q?=83=D1=81=D0=B5=D0=BD=D0=BA=D0=BE?= -Date: Mon, 25 Jun 2012 17:54:27 +0400 -Subject: [PATCH 13/13] Removed all async Oracle operations - they didn't work - well anyway - ---- - modules/db_oracle/asynch.c | 270 ----------------------------------------- - modules/db_oracle/asynch.h | 62 ---------- - modules/db_oracle/db_oracle.c | 2 +- - modules/db_oracle/dbase.c | 53 +++----- - modules/db_oracle/ora_con.c | 73 ++++------- - modules/db_oracle/ora_con.h | 3 +- - modules/db_oracle/res.c | 110 +++++++++-------- - modules/db_oracle/timer.c | 131 ++++++++++++++++++++ - modules/db_oracle/timer.h | 22 ++++ - 9 files changed, 256 insertions(+), 470 deletions(-) - delete mode 100644 modules/db_oracle/asynch.c - delete mode 100644 modules/db_oracle/asynch.h - create mode 100644 modules/db_oracle/timer.c - create mode 100644 modules/db_oracle/timer.h - -diff --git a/modules/db_oracle/db_oracle.c b/modules/db_oracle/db_oracle.c -index 70cfe40..40c7692 100644 ---- a/modules/db_oracle/db_oracle.c -+++ b/modules/db_oracle/db_oracle.c -@@ -31,7 +31,7 @@ - #include "../../sr_module.h" - #include "../../db/db.h" - #include "dbase.h" --#include "asynch.h" -+#include "timer.h" - - static int oracle_mod_init(void); - static void destroy(void); -diff --git a/modules/db_oracle/dbase.c b/modules/db_oracle/dbase.c -index d129e11..be2352e 100644 ---- a/modules/db_oracle/dbase.c -+++ b/modules/db_oracle/dbase.c -@@ -36,7 +36,7 @@ - #include "val.h" - #include "ora_con.h" - #include "res.h" --#include "asynch.h" -+#include "timer.h" - #include "dbase.h" - - -@@ -212,7 +212,6 @@ static int db_oracle_submit_query(const db_con_t* _h, const str* _s) - OCIDate odt[sizeof(bind)/sizeof(bind[0])]; - str tmps; - sword status; -- int pass; - ora_con_t* con = CON_ORA(_h); - query_data_t* pqd = con->pqdata; - size_t hc = pqd->_n + pqd->_nw; -@@ -223,32 +222,16 @@ static int db_oracle_submit_query(const db_con_t* _h, const str* _s) - (unsigned)hc); - return -1; - } -- -- if (!pqd->_rs) { -- /* -- * This method is at ~25% faster as set OCI_COMMIT_ON_SUCCESS -- * in StmtExecute -- */ -- tmps.len = snprintf(st_buf, sizeof(st_buf), -- "begin %.*s; commit write batch nowait; end;", -- _s->len, _s->s); -- if ((unsigned)tmps.len >= sizeof(st_buf)) -- return sql_buf_small(); -- tmps.s = st_buf; -- _s = &tmps; -- } - -- pass = 1; -- if (!con->connected) { -+ if (con->connected != 2) { - status = db_oracle_reconnect(con); - if (status != OCI_SUCCESS) { - LM_ERR("can't restore connection: %s\n", db_oracle_error(con, status)); - return -2; - } - LM_INFO("connection restored\n"); -- --pass; - } --repeat: -+ - stmthp = NULL; - status = OCIHandleAlloc(con->envhp, (dvoid**)(dvoid*)&stmthp, - OCI_HTYPE_STMT, 0, NULL); -@@ -291,14 +274,10 @@ bind_err: - } - } - -- // timelimited operation -- status = begin_timelimit(con, 0); -- if (status != OCI_SUCCESS) goto ora_err; -- do status = OCIStmtExecute(con->svchp, stmthp, con->errhp, -- !pqd->_rs, 0, NULL, NULL, -- pqd->_rs ? OCI_STMT_SCROLLABLE_READONLY : OCI_DEFAULT); -- while (wait_timelimit(con, status)); -- if (done_timelimit(con, status)) goto stop_exec; -+ request_timer(); -+ status = OCIStmtExecute(con->svchp, stmthp, con->errhp, -+ !pqd->_rs, 0, NULL, NULL, pqd->_rs ? OCI_DEFAULT : OCI_COMMIT_ON_SUCCESS); -+ timer_stop(); - switch (status) { - case OCI_SUCCESS_WITH_INFO: - LM_WARN("driver: %s\n", db_oracle_errorinfo(con)); -@@ -310,8 +289,8 @@ bind_err: - OCIHandleFree(stmthp, OCI_HTYPE_STMT); - return 0; - default: -- pass = -pass; -- break; -+ LM_ERR("timeout/not connected to oracle\n"); -+ break; - } - - ora_err: -@@ -319,15 +298,13 @@ ora_err: - stop_exec: - if (stmthp) - OCIHandleFree(stmthp, OCI_HTYPE_STMT); -- if (pass == -1 && !con->connected) { -- /* Attemtp to reconnect */ -- if (db_oracle_reconnect(con) == OCI_SUCCESS) { -- LM_NOTICE("attempt repeat after reconnect\n"); -- pass = 0; -- goto repeat; -- } -+ LM_INFO("reconnecting to oracle...\n"); -+ /* Attempt to reconnect */ -+ if (db_oracle_reconnect(con) == OCI_SUCCESS) -+ LM_INFO("connection restored\n"); -+ else - LM_ERR("connection loss\n"); -- } -+ - return -4; - } - -diff --git a/modules/db_oracle/ora_con.c b/modules/db_oracle/ora_con.c -index 73ced27..f03f753 100644 ---- a/modules/db_oracle/ora_con.c -+++ b/modules/db_oracle/ora_con.c -@@ -22,9 +22,10 @@ - - #include - #include -+#include - #include "../../mem/mem.h" - #include "../../dprint.h" --#include "asynch.h" -+#include "timer.h" - #include "ora_con.h" - - /*************************************************************************/ -@@ -105,6 +106,12 @@ bad_param: - status = OCIAttrSet(con->svchp, OCI_HTYPE_SVCCTX, con->authp, 0, - OCI_ATTR_SESSION, con->errhp); - if (status != OCI_SUCCESS) goto connect_err; -+ -+ if (init_ora_timer(con) != 0) { -+ LM_ERR("can't start oracle timer thread\n"); -+ goto drop_connection; -+ } -+ - status = db_oracle_reconnect(con); - if (status != OCI_SUCCESS) { - connect_err: -@@ -122,12 +129,11 @@ drop_connection: - } - - // timelimited operation -- status = begin_timelimit(con, 0); -- if (status != OCI_SUCCESS) goto connect_err; -- do status = OCIServerVersion(con->svchp, con->errhp, (OraText*)buf, -+ request_timer(); -+ status = OCIServerVersion(con->svchp, con->errhp, (OraText*)buf, - (ub4)sizeof(buf), OCI_HTYPE_SVCCTX); -- while (wait_timelimit(con, status)); -- if (done_timelimit(con, status)) goto drop_connection; -+ timer_stop(); -+ - if (status != OCI_SUCCESS) goto connect_err; - LM_INFO("server version is %s\n", buf); - return con; -@@ -139,6 +145,7 @@ drop_connection: - */ - void db_oracle_free_connection(ora_con_t* con) - { -+ destroy_ora_timer(con); - if (!con) return; - - if (con->connected) -@@ -164,20 +171,17 @@ void db_oracle_free_connection(ora_con_t* con) - void db_oracle_disconnect(ora_con_t* con) - { - sword status; -- -- switch (con->connected) { -- default: -- status = OCISessionEnd(con->svchp, con->errhp, con->authp, -- OCI_DEFAULT); -- if (status != OCI_SUCCESS) -- LM_ERR("driver: %s\n", db_oracle_error(con, status)); -- case 1: -+ if (con->connected > 0) { -+ if (con->connected > 1) { -+ status = OCISessionEnd(con->svchp, con->errhp, con->authp, -+ OCI_DEFAULT); -+ if (status != OCI_SUCCESS) -+ LM_ERR("driver: %s\n", db_oracle_error(con, status)); -+ } - status = OCIServerDetach(con->srvhp, con->errhp, OCI_DEFAULT); - if (status != OCI_SUCCESS) - LM_ERR("driver: %s\n", db_oracle_error(con, status)); - con->connected = 0; -- case 0: -- break; - } - } - -@@ -192,48 +196,19 @@ sword db_oracle_reconnect(ora_con_t* con) - if (con->connected) - db_oracle_disconnect(con); - -- /* timelimited operation, but OCI tcp-network does not support it :( */ -+ restore_timer(); - status = OCIServerAttach(con->srvhp, con->errhp, (OraText*)con->uri, - con->uri_len, 0); -+ timer_stop(); - if (status == OCI_SUCCESS) { - ++con->connected; -- /* -- * timelimited operation, but OCI has BUG in asynch -- * implementation of OCISessionBegin :(. -- * -- * Next code is 'empiric hack' that work (tested) in v10/v11. -- */ -- status = begin_timelimit(con, 1); -- if (status != OCI_SUCCESS) goto done; -+ request_timer(); - status = OCISessionBegin(con->svchp, con->errhp, con->authp, - OCI_CRED_RDBMS, OCI_DEFAULT); -- while (wait_timelimit(con, status)) { -- sword code; -- -- status = OCIServerVersion(con->svchp, con->errhp, NULL, -- 0, OCI_HTYPE_SVCCTX); -- -- if ( status != OCI_ERROR -- || OCIErrorGet(con->errhp, 1, NULL, &code, NULL, 0, -- OCI_HTYPE_ERROR) != OCI_SUCCESS) break; -- switch (code) { -- case 24909: /* other call in progress */ -- status = OCI_STILL_EXECUTING; -- continue; -- -- case 3127: /* no new operation until active ends */ -- status = OCISessionBegin(con->svchp, con->errhp, -- con->authp, OCI_CRED_RDBMS, OCI_DEFAULT); -- default: -- break; -- } -- break; -- } -- if (done_timelimit(con, status)) goto done; -+ timer_stop(); - - if (status == OCI_SUCCESS) - ++con->connected; - } --done: - return status; - } -diff --git a/modules/db_oracle/ora_con.h b/modules/db_oracle/ora_con.h -index 5835ffe..7267bee 100644 ---- a/modules/db_oracle/ora_con.h -+++ b/modules/db_oracle/ora_con.h -@@ -50,7 +50,8 @@ struct ora_con { - - int connected; /* Authorized session started */ - int bindpos; /* Last Bind handle position */ -- -+ pthread_t timer; -+ - query_data_t* pqdata; /* Temporary: cb data for submit_query/store_result */ - - int uri_len; -diff --git a/modules/db_oracle/res.c b/modules/db_oracle/res.c -index e9e6233..2c625f8 100644 ---- a/modules/db_oracle/res.c -+++ b/modules/db_oracle/res.c -@@ -32,7 +32,7 @@ - #include "../../dprint.h" - #include "ora_con.h" - #include "dbase.h" --#include "asynch.h" -+#include "timer.h" - #include "res.h" - - -@@ -54,6 +54,10 @@ struct dmap { - }; - typedef struct dmap dmap_t; - -+typedef struct ora_row { -+ struct db_row hdr; -+ struct ora_row* next; -+} ora_row_t; - - /* - * Get and convert columns from a result. Define handlers and buffers -@@ -362,66 +366,74 @@ static int convert_row(db_res_t* _res, db_row_t* _r, dmap_t* _d) - */ - static int get_rows(ora_con_t* con, db_res_t* _r, OCIStmt* _c, dmap_t* _d) - { -- ub4 rcnt; -+ ub4 i = 0, rcnt = 0; - sword status; - unsigned n = RES_COL_N(_r); -- -+ // Since OCI have not "mysql_num_rows()", sequentialy fetch all rows into tmp area orow_list. -+ // Then call db_allocate_rows() and copy tmp to db module. -+ ora_row_t *orow_list = NULL, *orow_it, *orow_tail; -+ - memcpy(_d->len, _d->ilen, sizeof(_d->len[0]) * n); -- -- // timelimited operation -- status = begin_timelimit(con, 0); -- if (status != OCI_SUCCESS) goto ora_err; -- do status = OCIStmtFetch2(_c, con->errhp, 1, OCI_FETCH_NEXT, 0, -- OCI_DEFAULT); -- while (wait_timelimit(con, status)); -- if (done_timelimit(con, status)) goto stop_load; -- if (status != OCI_SUCCESS) { -- if (status != OCI_NO_DATA) -- goto ora_err; -- -- RES_ROW_N(_r) = 0; -- RES_ROWS(_r) = NULL; -- return 0; -- } -- -- status = OCIAttrGet(_c, OCI_HTYPE_STMT, &rcnt, NULL, -- OCI_ATTR_CURRENT_POSITION, con->errhp); -- if (status != OCI_SUCCESS) goto ora_err; -- if (!rcnt) { -- LM_ERR("lastpos==0\n"); -- goto stop_load; -+ -+ request_timer(); -+ while ((status = OCIStmtFetch2(_c, con->errhp, 1, OCI_FETCH_NEXT, 0, -+ OCI_DEFAULT)) == OCI_SUCCESS) { -+ timer_stop(); -+ -+ orow_it = (ora_row_t*) pkg_malloc(sizeof(ora_row_t) + sizeof(db_val_t)*RES_COL_N(_r)); -+ if (orow_it == NULL) { -+ LM_ERR("no private memory left\n"); -+ goto stop_load; -+ } -+ memset(orow_it, 0, sizeof(ora_row_t) + sizeof(db_val_t)*RES_COL_N(_r)); -+ orow_it->hdr.values = (db_val_t*)(orow_it+1); -+ -+ if (orow_list == NULL) -+ orow_list = orow_it; -+ else -+ orow_tail->next = orow_it; -+ orow_tail = orow_it; -+ -+ if (convert_row(_r, &orow_it->hdr, _d) < 0) { -+ LM_ERR("erroc convert row\n"); -+ goto stop_load; -+ } -+ memcpy(_d->len, _d->ilen, sizeof(_d->len[0]) * n); -+ ++rcnt; -+ request_timer(); - } -- -+ timer_stop(); -+ if (status != OCI_NO_DATA) -+ goto ora_err; -+ - RES_ROW_N(_r) = rcnt; - if (db_allocate_rows( _r, rcnt)!=0) { - LM_ERR("no private memory left\n"); -- return -1; -+ goto stop_load; - } -- -- while ( 1 ) { -- if (convert_row(_r, &RES_ROWS(_r)[--rcnt], _d) < 0) { -- LM_ERR("error convert row\n"); -- goto stop_load; -- } -- -- if (!rcnt) -- return 0; -- -- memcpy(_d->len, _d->ilen, sizeof(_d->len[0]) * n); -- // timelimited operation -- status = begin_timelimit(con, 0); -- if (status != OCI_SUCCESS) goto ora_err; -- do status = OCIStmtFetch2(_c, con->errhp, 1, OCI_FETCH_PRIOR, 0, -- OCI_DEFAULT); -- while (wait_timelimit(con, status)); -- if (done_timelimit(con, status)) goto stop_load; -- if (status != OCI_SUCCESS) break; -+ -+ for (orow_it = orow_list; orow_it; orow_it = orow_it->next) { -+ memcpy(ROW_VALUES(&RES_ROWS(_r)[i]), ROW_VALUES(&orow_it->hdr), sizeof(db_val_t)*RES_COL_N(_r)); -+ ROW_N(&RES_ROWS(_r)[i]) = ROW_N(&orow_it->hdr); -+ ++i; -+ } -+ -+ for (orow_it = orow_list; orow_it; orow_it = orow_list) { -+ orow_list = orow_it->next; -+ pkg_free(orow_it); -+ orow_it = NULL; - } -+ return 0; -+ - ora_err: - LM_ERR("driver: %s\n", db_oracle_error(con, status)); - stop_load: -- db_free_rows(_r); -- RES_ROW_N(_r) = 0; /* TODO: skipped in db_res.c :) */ -+ for (orow_it = orow_list; orow_it; orow_it = orow_list) { -+ orow_list = orow_it->next; -+ db_free_row(&orow_it->hdr); -+ pkg_free(orow_it); -+ orow_it = NULL; -+ } - return -3; - } - -diff --git a/modules/db_oracle/timer.c b/modules/db_oracle/timer.c -new file mode 100644 -index 0000000..50484f4 ---- /dev/null -+++ b/modules/db_oracle/timer.c -@@ -0,0 +1,131 @@ -+#include "timer.h" -+#include "../../dprint.h" -+#include "../../sr_module.h" -+ -+#include -+#include -+#include -+#include -+ -+#define MAX_TIMEOUT_S 10 -+#define MIN_TIMEOUT_MCS 100000 -+ -+/* Default is 3.0 second */ -+struct itimerval request_tm = {{0,0}, {3,0}}; -+// unsigned request_tm; -+ -+/* Default is 0.2 second */ -+struct itimerval restore_tm = {{0,0}, {0,200000}}; -+ -+struct itimerval stop_tm = {{0,0}, {0,0}}; -+ -+/* Simple error handling functions */ -+ -+#define handle_error_en(en, msg) \ -+ do { LM_ERR(msg": %s\n", strerror(en)); return 1; } while (0) -+ -+static ora_con_t *g_con; -+ -+static int set_tv(unsigned type, const char* val, struct timeval* tv) -+{ -+ char *eptr; -+ struct itimerval tt; -+ unsigned long s, ms; -+ double dv; -+ -+ if (type != STR_PARAM) { -+ LM_ERR("type of parameter is no STR\n"); -+ return -1; -+ } -+ -+ if (!val || !*val) { -+ LM_ERR("empty parameter\n"); -+ return -1; -+ } -+ -+ errno = 0; -+ dv = strtod(val, &eptr); -+ -+ if (*eptr) { -+ LM_ERR("invalid parameter string\n"); -+ return -2; -+ } -+ -+ if ( errno -+ || dv > (double)MAX_TIMEOUT_S -+ || (dv < ((double)MIN_TIMEOUT_MCS)/100000)) -+ { -+ LM_ERR("value must be between 0.%.6u and %u.0\n", -+ MIN_TIMEOUT_MCS, MAX_TIMEOUT_S); -+ return -3; -+ } -+ -+ s = (unsigned)dv; -+ dv -= (double)s; -+ ms = (unsigned)(dv * 1000000); -+ tv->tv_sec = (time_t)s; -+ tv->tv_usec = (suseconds_t)ms; -+ return 0; -+} -+ -+ -+/* -+ * set operation timeout -+ */ -+int set_timeout(unsigned type, const char* val) -+{ -+ return set_tv(type, val, &request_tm.it_value); -+} -+ -+ -+/* -+ * set (re)connect timeout -+ */ -+int set_reconnect(unsigned type, const char* val) -+{ -+ return set_tv(type, val, &restore_tm.it_value); -+} -+ -+void ora_alarm_handle(int sig) { -+ LM_INFO("ora_alarm_handle\n"); -+ sword status; -+ status = OCIBreak(g_con->svchp, g_con->errhp); -+ if (status != OCI_SUCCESS) { -+ LM_ERR("OCIBreak: %s\n", db_oracle_error(g_con, status)); -+ } -+} -+ -+int init_ora_timer(ora_con_t* con) { -+ g_con = con; -+ struct sigaction sa; -+ memset(&sa, 0, sizeof(sa)); -+ sa.sa_handler = ora_alarm_handle; -+ if (sigaction(SIGALRM, &sa, NULL) < -1) -+ handle_error_en(errno, "sigaction"); -+ -+ return 0; -+} -+ -+int destroy_ora_timer() -+{ -+ timer_stop(); -+} -+ -+void request_timer() -+{ -+ if (setitimer(ITIMER_REAL, &request_tm, NULL) < 0) -+ LM_ERR("setitimer: %s\n", strerror(errno)); -+} -+ -+void restore_timer() -+{ -+ if (setitimer(ITIMER_REAL, &restore_tm, NULL) < 0) -+ LM_ERR("setitimer: %s\n", strerror(errno)); -+} -+ -+void timer_stop() -+{ -+ if (setitimer(ITIMER_REAL, &stop_tm, NULL) < 0) -+ LM_ERR("setitimer: %s\n", strerror(errno)); -+} -+ -\ No newline at end of file -diff --git a/modules/db_oracle/timer.h b/modules/db_oracle/timer.h -new file mode 100644 -index 0000000..24aa4a9 ---- /dev/null -+++ b/modules/db_oracle/timer.h -@@ -0,0 +1,22 @@ -+#ifndef ORA_TIMER_H -+#define ORA_TIMER_H -+ -+#include "ora_con.h" -+ -+/* -+ * parse timeout value for operation in syntax: nnn.mmm (sec/ms) -+ */ -+int set_timeout(unsigned type, const char* val); -+ -+/* -+ * parse timeout value for reconnect in syntax: nnn.mmm (sec/ms) -+ */ -+int set_reconnect(unsigned type, const char* val); -+ -+int init_ora_timer(ora_con_t* con); -+int destroy_ora_timer(); -+ -+void request_timer(); -+void restore_timer(); -+void timer_stop(); -+#endif // ORA_TIMER_H -\ No newline at end of file --- -1.7.10.4 - diff --git a/opensips.spec b/opensips.spec index 300ad38..4f66cf2 100644 --- a/opensips.spec +++ b/opensips.spec @@ -17,24 +17,16 @@ Summary: Open Source SIP Server Name: opensips -Version: 1.8.0 -Release: 3%{?dist} +Version: 1.8.1 +Release: 1%{?dist} License: GPLv2+ Group: System Environment/Daemons -Source0: http://opensips.org/pub/%{name}/%{version}/src/%{name}-%{version}-beta_src.tar.gz -Patch1: opensips-0001-packaging-fedora-Improve-packaging-for-Fedora-RHEL-a.patch -Patch2: opensips-0002-backport-from-trunk-rev-9099.patch -Patch3: opensips-0003-Backported-from-trunk-rev-9121.patch -Patch4: opensips-0004-db_oracle-typo-fixes.patch -Patch5: opensips-0005-Drop-rpath-from-Oracle-s-module.patch -Patch6: opensips-0006-Clean-Makefile-for-Oracle.patch -Patch7: opensips-0007-Don-t-fetch-the-last-record-use-next-one.patch -Patch8: opensips-0008-Fix-SQL-types.patch -Patch9: opensips-0009-Reset-column-types-to-NULL-upon-freeing-resultset-co.patch -Patch10: opensips-0010-fixed-DB-type-inconsistency.patch -Patch11: opensips-0011-Proper-memory-zeroing.patch -Patch12: opensips-0012-Free-columns-data-only-in-Oracle.patch -Patch13: opensips-0013-Removed-all-async-Oracle-operations-they-didn-t-work.patch +Source0: http://opensips.org/pub/%{name}/%{version}/src/%{name}-%{version}_src.tar.gz +Patch1: opensips-0001-Consistently-use-rtpproxy-switches.patch +Patch2: opensips-0002-Cleanup-Oracle-s-makefiles.patch +Patch3: opensips-0003-Reset-column-types-to-NULL-upon-freeing-resultset-co.patch +Patch4: opensips-0004-fixed-DB-type-inconsistency.patch +Patch5: opensips-0005-Removed-all-async-Oracle-operations-they-didn-t-work.patch URL: http://opensips.org BuildRequires: expat-devel @@ -286,6 +278,7 @@ a MySQL-Database to be used for persistent storage. Summary: Oracle Storage Support for the OpenSIPS Group: System Environment/Daemons Requires: %{name} = %{version}-%{release} +BuildRequires: oracle-instantclient-devel %description oracle The %{name}-oracle package contains the Oracle plugin for %{name}, which allows @@ -612,22 +605,14 @@ the exchange of instant messages between SIP clients and XMPP(jabber) clients. %prep -%setup -q -n %{name}-%{version}-beta-tls +%setup -q -n %{name}-%{version}-tls %patch1 -p1 %patch2 -p1 %patch3 -p1 %patch4 -p1 -%patch5 -p1 -%patch6 -p1 -%patch7 -p1 -%patch8 -p1 -%patch9 -p1 -%patch10 -p1 -%patch11 -p1 -%patch12 -p1 # Fix for broken behaviour of a git/rpmbuild in EL5 rm -f modules/db_oracle/asynch.* -%patch13 -p1 +%patch5 -p1 %build LOCALBASE=/usr NICER=0 CFLAGS="%{optflags}" %{?_with_oracle:ORAHOME="$ORACLE_HOME"} %{__make} all %{?_smp_mflags} TLS=1 \ @@ -1193,6 +1178,10 @@ chown -R %{opensips_user}:%{opensips_group} %{_sysconfdir}/%{name} %doc docdir/README.xmpp %changelog +* Wed Aug 15 2012 Peter Lemenkov - 1.8.1-1 +- Ver. 1.8.1 +- Dropped all upstreamed patches + * Fri Jul 20 2012 Fedora Release Engineering - 1.8.0-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild diff --git a/sources b/sources index 21989c1..1e20281 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -21a1bb74d8b8ed5adbaa0d3bf1084b48 opensips-1.8.0-beta_src.tar.gz +03703558bb78be73d77b1f4311863cc4 opensips-1.8.1_src.tar.gz