Hi,

I've working on setting up a kannel environment, using libsdb support and a
Oracle backend.  The data is not being returned from sdb_callback_add,
resulting in the following stack trace (with an abort in gw_panic):

krabbe:/opt/kannel/1.2.1-test # gdb ./sbin/bearerbox
GNU gdb 5.0
Copyright 2000 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you
are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-suse-linux"...
(gdb) set args -v 1 conf/kannel.conf
(gdb) run
Starting program: /opt/kannel/1.2.1-test/./sbin/bearerbox -v 1
conf/kannel.conf
[New Thread 1024 (LWP 26047)]
2003-07-01 13:23:06 [0] INFO: Debug_lvl = 1, log_file = <none>, log_lvl = 0
2003-07-01 13:23:06 [0] INFO: Connecting to sdb resource
<oracle:uid=cr_owner/[EMAIL PROTECTED]>.
2003-07-01 13:23:06 [0] INFO: Added logfile `log/kannel.log' with level
`0'.
2003-07-01 13:23:06 [0] INFO: Started access logfile `log/access.log'.
[New Thread 2049 (LWP 26050)]
[New Thread 1026 (LWP 26051)]
[New Thread 2051 (LWP 26052)]
[New Thread 3076 (LWP 26053)]
[New Thread 4101 (LWP 26054)]
[New Thread 5126 (LWP 26055)]
[New Thread 6151 (LWP 26056)]
[New Thread 7176 (LWP 26057)]
[New Thread 8201 (LWP 26060)]
2003-07-01 13:23:09 [0] INFO: ----------------------------------------
2003-07-01 13:23:09 [0] INFO: Kannel bearerbox II version 1.2.1 starting
2003-07-01 13:23:09 [0] INFO: Loading store file state/kannel.store
2003-07-01 13:23:09 [0] INFO: Store-file size 324, starting to unpack
2003-07-01 13:23:09 [0] INFO: Retrieved 1 messages, non-acknowledged
messages: 1
2003-07-01 13:23:09 [0] INFO: MAIN: Start-up done, entering mainloop
2003-07-01 13:23:10 [7] PANIC: gwlib/thread.c:65: mutex_lock_real:
Assertion `mutex != NULL' failed.

Program received signal SIGABRT, Aborted.
[Switching to Thread 7176 (LWP 26057)]
0x40836001 in kill () from /lib/libc.so.6
(gdb) where
#0  0x40836001 in kill () from /lib/libc.so.6
#1  0x40059a22 in raise () from /lib/libpthread.so.0
#2  0x40837401 in abort () from /lib/libc.so.6
#3  0x8093aa6 in gw_panic () at gwlib/log.c:302
#4  0x8099366 in mutex_lock_real (mutex=0x0, file=0x80aea95 "gwlib/list.c",
line=426, func=0x80aeb70 "lock") at gwlib/thread.c:65
#5  0x80930fc in lock (list=0x80e02a8) at gwlib/list.c:426
#6  0x8092b27 in list_get (list=0x80e02a8, pos=3) at gwlib/list.c:234
#7  0x8052bb1 in dlr_find_sdb (smsc=0x80df580 "LOGICA", ts=0x80e0598
"Smsc2004", dst=0x80e02a8 "04123031018", typ=8) at gw/dlr.c:736
#8  0x80531b8 in dlr_find (smsc=0x80df580 "LOGICA", ts=0x80e0598
"Smsc2004", dst=0x80e02a8 "04123031018", typ=8) at gw/dlr.c:832
#9  0x8066829 in handle_pdu (smpp=0x80df980, conn=0x80dfe70, pdu=0x80e06b0,
pending_submits=0xbebffabc) at gw/smsc/smsc_smpp.c:840
#10 0x8066cc2 in io_thread (arg=0x80df6b0) at gw/smsc/smsc_smpp.c:1007
#11 0x808cfd9 in new_thread (arg=0x80df6f0) at gwlib/gwthread-pthread.c:284
#12 0x40056ba3 in pthread_start_thread () from /lib/libpthread.so.0
#13 0x4005766e in pthread_start_thread_event () from /lib/libpthread.so.0

The patch below has kannel up and working, excepting it leaves out the
recently added ' LIMIT 1'.

Comments on the patch and thoughts on direction for the 'LIMIT 1' would be
greatly appreciated.

--
John Mark Vandenberg
Callista Software Services
www.callista.com.au
Tel: +61 3 9685 7923

Index: gw/dlr.c
===================================================================
RCS file: /home/cvs/gateway/gw/dlr.c,v
retrieving revision 1.30
diff -u -u -r1.30 dlr.c
--- gw/dlr.c    15 Oct 2002 19:59:37 -0000      1.30
+++ gw/dlr.c    1 Jul 2003 11:12:12 -0000
@@ -686,19 +686,31 @@
 #ifdef DLR_SDB
 static int sdb_callback_add(int n, char **p, void *row)
 {
-       if (!n) {
-        debug("dlr.sdb", 0, "no rows found");
+    if (n != 4) {
+        debug("dlr.sdb", 0, "Result has incorrect number of columns: %d",
n);
         return 0;
     }

-    /* strip string into words */
-    row = octstr_split(octstr_imm(p[0]), octstr_imm(" "));
+#if defined(DLR_TRACE)
+    debug("dlr.sdb", 0, "row=%s,%s,%s,%s",p[0],p[1],p[2],p[3]);
+#endif
+
+    if (list_len(row) != 0) {
+        debug("dlr.sdb", 0, "Row already stored; length %ld",
list_len(row));
+        return 0;
+    }
+
+    list_append(row, octstr_create(p[0]));
+    list_append(row, octstr_create(p[1]));
+    list_append(row, octstr_create(p[2]));
+    list_append(row, octstr_create(p[3]));
+
     if (list_len(row) != 4) {
         debug("dlr.sdb", 0, "Row has wrong length %ld", list_len(row));
         return 0;
     }

-       return 0;
+    return 0;
 }

 static int sdb_callback_msgs(int n, char **p, void *row)
@@ -715,7 +727,7 @@
     Octstr *dlr_service;
     Octstr *dlr_url;
     Octstr *source_addr;
-    List *row;
+    List *row = list_create();

     sql = octstr_format("SELECT %s, %s, %s, %s FROM %s WHERE %s='%s' AND
%s='%s'",
                         octstr_get_cstr(field_mask),
octstr_get_cstr(field_serv),
@@ -723,6 +735,10 @@
                         octstr_get_cstr(table),
octstr_get_cstr(field_smsc),
                         smsc, octstr_get_cstr(field_ts), ts);

+#if defined(DLR_TRACE)
+    debug("dlr.sdb", 0, "sql: %s", octstr_get_cstr(sql));
+#endif
+
     mutex_lock(dlr_mutex);

     state = sdb_query(connection, octstr_get_cstr(sql), sdb_callback_add,
row);
@@ -740,10 +756,9 @@
           octstr_get_cstr(list_get(row, 3)));

     dlr_mask = atoi(octstr_get_cstr(list_get(row, 0)));
-    dlr_service = octstr_duplicate(list_get(row, 1));
-    dlr_url = octstr_duplicate(list_get(row, 2));
-    source_addr = octstr_duplicate(list_get(row, 3));
-    list_destroy(row, octstr_destroy_item);
+    dlr_service = list_get(row, 1);
+    dlr_url = list_get(row, 2);
+    source_addr = list_get(row, 3);

     mutex_unlock(dlr_mutex);

@@ -752,6 +767,10 @@
                         typ, octstr_get_cstr(field_smsc), smsc,
                                octstr_get_cstr(field_ts), ts);

+#if defined(DLR_TRACE)
+    debug("dlr.sdb", 0, "sql: %s", octstr_get_cstr(sql));
+#endif
+
     mutex_lock(dlr_mutex);

     state = sdb_query(connection, octstr_get_cstr(sql), NULL, NULL);
@@ -795,10 +814,14 @@
         debug("dlr.sdb", 0, "DLR not deleted because we wait on more
reports");
     } else {
         debug("dlr.sdb", 0, "removing DLR from database");
-        sql = octstr_format("DELETE FROM %s WHERE %s='%s' AND %s='%s'
LIMIT 1",
+        sql = octstr_format("DELETE FROM %s WHERE %s='%s' AND %s='%s'",
                             octstr_get_cstr(table),
octstr_get_cstr(field_smsc),
                             smsc, octstr_get_cstr(field_ts), ts);

+#if defined(DLR_TRACE)
+        debug("dlr.sdb", 0, "sql: %s", octstr_get_cstr(sql));
+#endif
+
         mutex_lock(dlr_mutex);

         state = sdb_query(connection, octstr_get_cstr(sql), NULL, NULL);
@@ -810,9 +833,7 @@
         mutex_unlock(dlr_mutex);
     }

-    octstr_destroy(dlr_service);
-    octstr_destroy(dlr_url);
-    octstr_destroy(source_addr);
+    list_destroy(row, octstr_destroy_item);

 #endif
     return msg;


Reply via email to