Daily patch: gateway

kannel at kannel.org kannel at kannel.org
Fri Jul 25 06:30:18 CEST 2008


File gateway/ChangeLog changed from revision 1.2957 to 1.2960
File gateway/configure changed from revision 1.169 to 1.170
File gateway/configure.in changed from revision 1.177 to 1.178
File gateway/gwlib/cfg.c changed from revision 1.39 to 1.40
File gateway/gwlib/dbpool.c changed from revision 1.19 to 1.20



Index: gateway/ChangeLog
diff -u gateway/ChangeLog:1.2957 gateway/ChangeLog:1.2960
--- gateway/ChangeLog:1.2957	Sat Jul 19 14:44:42 2008
+++ gateway/ChangeLog	Thu Jul 24 16:25:36 2008
@@ -1,3 +1,17 @@
+2008-07-24 Alexander Malysh <amalysh at kannel.org>
+    * configure.in, configure: fixed hardcoded library detection for oracle. Not
+      all OSs have .so.
+
+2008-07-24 Alexander Malysh <amalysh at kannel.org>
+    * gwlib/dbpool.c: Fixed deadlock in dbpool_conn_consume if we don't have any
+      database connections available anymore and database is temporarely not
+      available.
+
+2008-07-24  Stipe Tolj  <stolj at kannel.org>
+    * gwlib/cfg.c: add more semantical error statement if we detect an unknown
+      group identifier. This shall help the users to find their config typos.
+      [Msg-Id: <48877F65.8060605 at tolj.org>]
+
 2008-07-19  Stipe Tolj  <stolj at kannel.org>
     * gwlib/mime.c: memory leak fix while duplicating headers.
       Thanks to Paul Bagyenda for providing the patch.
Index: gateway/configure.in
diff -u gateway/configure.in:1.177 gateway/configure.in:1.178
--- gateway/configure.in:1.177	Wed Jul  2 14:56:31 2008
+++ gateway/configure.in	Thu Jul 24 16:25:36 2008
@@ -1068,7 +1068,7 @@
 
 AC_MSG_CHECKING([whether to compile with Oracle support])
 AC_ARG_WITH(oracle,
-[  --with-oracle           enable Oracle storage @<:@disabled@:>@],
+[  --with-oracle           enable ORACLE storage @<:@disabled@:>@],
 [
 if test "$withval" != yes ; then
     AC_MSG_RESULT(disabled)
@@ -1076,7 +1076,7 @@
     AC_MSG_RESULT(searching)
         AC_ARG_WITH(
                 oracle-includes,
-                [  --with-oracle-includes=DIR  adds Oracle include paths],
+                [  --with-oracle-includes=DIR  adds oracle include paths],
                 [ ORACLE_INCLUDE_PATH="$withval" ],
                 [ ORACLE_INCLUDE_PATH="$ORACLE_HOME/rdbms/demo $ORACLE_HOME/rdbms/public" ]
         )
@@ -1088,21 +1088,9 @@
         AC_TRY_CPP([#include <oci.h>],AC_MSG_RESULT(yes), AC_MSG_ERROR([oci.h not found]))
         CFLAGS="$CFLAGS $CPPFLAGS"
 
-        AC_MSG_CHECKING([Oracle OCI version])
-        oracle_version_major=`cat $ORACLE_INCLUDE_PATH/oci.h \
-                             | grep '#define.*OCI_MAJOR_VERSION.*' \
-                             | sed -e 's/#define OCI_MAJOR_VERSION  *//' \
-                             | sed -e 's/  *\/\*.*\*\///'`
-        oracle_version_minor=`cat $ORACLE_INCLUDE_PATH/oci.h \
-                             | grep '#define.*OCI_MINOR_VERSION.*' \
-                             | sed -e 's/#define OCI_MINOR_VERSION  *//' \
-                             | sed -e 's/  *\/\*.*\*\///'`
-        ORACLE_OCI_VERSION="$oracle_version_major.$oracle_version_minor"
-        AC_MSG_RESULT([$ORACLE_OCI_VERSION])
-
         AC_ARG_WITH(
                 oracle-libs,
-                [  --with-oracle-libs=DIR  adds Oracle library path],
+                [  --with-oracle-libs=DIR  adds oracle library path],
                 [ ORACLE_LIB_PATH="$withval" ],
                 [ ORACLE_LIB_PATH="$ORACLE_HOME/lib" ]
         )
@@ -1110,26 +1098,19 @@
         do
                 LIBS="$LIBS -L$a"
         done
-        
+
         dnl Check for Oracle 10g instant client
-        if test -f "$ORACLE_LIB_PATH/libnnz10.so" && \
-           test -f "$ORACLE_LIB_PATH/libclntsh.so.10.1"; then
-          LIBS="$LIBS -lnnz10"
+        AC_CHECK_LIB(clntsh,OCIEnvCreate,[ LIBS="$LIBS -lclntsh" ],
           AC_CHECK_LIB(clntsh,OCIEnvCreate,[ LIBS="$LIBS -lclntsh -lnnz10" ],exit)
-        else
-          AC_CHECK_LIB(clntsh,OCIEnvCreate,[ LIBS="$LIBS -lclntsh" ],exit)
-        fi
+        )
 
         dnl Beware that Oracle 10g doesn't use anymore the libwtcX.so libs,
         dnl so we don't break hard in case they are not present.
-        if test -f "$ORACLE_HOME/lib/libwtc8.so"; then
-          AC_CHECK_LIB(wtc8,wtcstu,[ LIBS="$LIBS -lwtc8" ],AC_MSG_ERROR([Oracle libwtc8.so not found]))
-        fi
-        if test -f "$ORACLE_HOME/lib/libwtc9.so"; then
-          AC_CHECK_LIB(wtc9,wtcstu,[ LIBS="$LIBS -lwtc9" ],AC_MSG_ERROR([Oracle libwtc9.so not found]))
-        fi
+        AC_CHECK_LIB(wtc8,wtcstu,[ LIBS="$LIBS -lwtc8" ],
+          AC_CHECK_LIB(wtc9,wtcstu,[ LIBS="$LIBS -lwtc9" ], true)
+        )
 
-    AC_DEFINE(HAVE_ORACLE)
+    AC_DEFINE(HAVE_ORACLE, 1, [Do we have Oracle])
     AC_MSG_CHECKING([whether to compile with Oracle support])
     AC_MSG_RESULT(yes)
 fi
Index: gateway/gwlib/cfg.c
diff -u gateway/gwlib/cfg.c:1.39 gateway/gwlib/cfg.c:1.40
--- gateway/gwlib/cfg.c:1.39	Wed Jan  9 20:06:56 2008
+++ gateway/gwlib/cfg.c	Thu Jul 24 15:07:40 2008
@@ -186,7 +186,8 @@
 	}
     #include "cfg.def"
 
-    return 0;
+    /* unknown group identifier */
+    return -1;
 }
 
 
@@ -207,14 +208,15 @@
 static int is_allowed_in_group(Octstr *group, Octstr *variable)
 {
     long i;
-    int r = 0;
+    int x, r = -1;
 
     for (i = 0; i < gwlist_len(allowed_hooks); ++i) {
-        r += ((int(*)(Octstr *, Octstr *))
+        x = ((int(*)(Octstr *, Octstr *))
             gwlist_get(allowed_hooks, i))(group, variable);
+        r = (x == -1 ? (r == -1 ? x : r) : (r == -1 ? x : r + x));
     }
 
-    return (r > 0);
+    return r;
 }
 
 
@@ -248,34 +250,48 @@
     
     groupname = cfg_get(grp, octstr_imm("group"));
     if (groupname == NULL) {
-	error(0, "Group does not contain variable 'group'.");
-    	return -1;
+        error(0, "Group does not contain variable 'group'.");
+        return -1;
     }
     set_group_name(grp, groupname);
 
     names = dict_keys(grp->vars);
+
     while ((name = gwlist_extract_first(names)) != NULL) {
-	if (!is_allowed_in_group(groupname, name)) {
-	    error(0, "Group '%s' may not contain field '%s'.",
-		  octstr_get_cstr(groupname), octstr_get_cstr(name));
-	    octstr_destroy(name);
-	    octstr_destroy(groupname);
-	    gwlist_destroy(names, octstr_destroy_item);
-	    return -1;
-	}
-	octstr_destroy(name);
+        int a = is_allowed_in_group(groupname, name);
+        switch (a) {
+            case 0:
+                error(0, "Group '%s' may not contain field '%s'.",
+                      octstr_get_cstr(groupname), octstr_get_cstr(name));
+                octstr_destroy(name);
+                octstr_destroy(groupname);
+                gwlist_destroy(names, octstr_destroy_item);
+                return -1;
+                break;
+            case -1:
+                error(0, "Group '%s' is no valid group identifier.",
+                      octstr_get_cstr(groupname));
+                octstr_destroy(name);
+                octstr_destroy(groupname);
+                gwlist_destroy(names, octstr_destroy_item);
+                return -1;
+                break;
+            default:
+                octstr_destroy(name);
+                break;
+        }
     }
     gwlist_destroy(names, NULL);
 
-    if (is_single_group(groupname))
-    	dict_put(cfg->single_groups, groupname, grp);
-    else {
-	list = dict_get(cfg->multi_groups, groupname);
-	if (list == NULL) {
-	    list = gwlist_create();
-	    dict_put(cfg->multi_groups, groupname, list);
-	}
-    	gwlist_append(list, grp);
+    if (is_single_group(groupname)) {
+        dict_put(cfg->single_groups, groupname, grp);
+    } else {
+        list = dict_get(cfg->multi_groups, groupname);
+        if (list == NULL) {
+            list = gwlist_create();
+            dict_put(cfg->multi_groups, groupname, list);
+        }
+        gwlist_append(list, grp);
     }
 
     octstr_destroy(groupname);
@@ -564,7 +580,8 @@
                     grp = create_group(); 
                  
                 if (grp->configfile != NULL) {
-                    octstr_destroy(grp->configfile); grp->configfile=NULL;
+                    octstr_destroy(grp->configfile); 
+                    grp->configfile = NULL;
                 }
                 grp->configfile = octstr_duplicate(cfg->filename); 
 
Index: gateway/gwlib/dbpool.c
diff -u gateway/gwlib/dbpool.c:1.19 gateway/gwlib/dbpool.c:1.20
--- gateway/gwlib/dbpool.c:1.19	Wed Jan  9 20:06:55 2008
+++ gateway/gwlib/dbpool.c	Thu Jul 24 16:22:55 2008
@@ -240,7 +240,7 @@
 
 long dbpool_conn_count(DBPool *p)
 {
-    gw_assert(p->pool != NULL);
+    gw_assert(p != NULL && p->pool != NULL);
 
     return gwlist_len(p->pool);
 }
@@ -251,11 +251,19 @@
     DBPoolConn *pc;
 
     gw_assert(p != NULL && p->pool != NULL);
-
-    /* check if we have any connection, if no return NULL; otherwise we have deadlock */
-    if (p->curr_size < 1)
-        panic(0, "DBPOOL: Deadlock detected!!!");
-
+    
+    /* check for max connections and if 0 return NULL */
+    if (p->max_size < 1)
+        return NULL;
+
+    /* check if we have any connection */
+    while (p->curr_size < 1) {
+        debug(0, "dbpool", "DBPool has no connections, reconnecting up to maximum...");
+        /* dbpool_increase ensure max_size is not exceeded so don't lock */
+        dbpool_increase(p, p->max_size - p->curr_size);
+        if (p->curr_size < 1)
+            gwthread_sleep(0.1);
+    }
 
     /* garantee that you deliver a valid connection to the caller */
     while ((pc = gwlist_consume(p->pool)) != NULL) {
@@ -277,7 +285,14 @@
              * can be dangeros if all connections where broken, then we will
              * block here for ever.
              */
-            dbpool_increase(p, 1);
+            while (p->curr_size < 1) {
+                debug(0, "dbpool", "DBPool has too few connections, reconnecting up to maximum...");
+                /* dbpool_increase ensure max_size is not exceeded so don't lock */
+                dbpool_increase(p, p->max_size - p->curr_size);
+                if (p->curr_size < 1)
+                    gwthread_sleep(0.1);
+            }
+
         } else {
             break;
         }



More information about the devel-reports mailing list