gnokii-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: smsd crash report


From: Pawel Kot
Subject: Re: smsd crash report
Date: Fri, 13 May 2011 19:17:09 +0200

Hi Jan,

While looking at the root cause of the problem described below, I've
come across that the sending from SMSD is not quite optimal. I may be
wrong as the smsc is stored somewhere in the data* structure being
passed to A_SendMessage() but could not trace that. If you ack the
patch below I'll push it.

>From 0613b277895a8bbb89fd97e35d437388ceea7497 Mon Sep 17 00:00:00 2001
From: Pawel Kot <address@hidden>
Date: Fri, 13 May 2011 19:09:35 +0200
Subject: [PATCH] smsd: do not call GetSMSCenter every time SMS is sent

GetSMSC is not quite cheap operation. We do in smsd following:
  calloc()
  GetSMSC()
  strcpy()
  free()

On the other hand in 99.999% cases SMSC does not change often or does not
change at all.  It is safe to get the value once and then cache it for the
subsequent runs.

If GetSMSCenter fails do not attempt retries.
---
 ChangeLog       |    2 ++
 smsd/ChangeLog  |    4 ++++
 smsd/lowlevel.c |   31 +++++++++++++++++++++++++------
 3 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 66a103f..dd10738 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -29,6 +29,8 @@
  * fake driver updates
     o add multipart message to SMS inbox                (Paweł Kot)
     o add ability to use --writephonebook               (Paweł Kot)
+ * smsd updates
+    o do not call GetSMSC every time SMS is sent        (Paweł Kot)

 0.6.30
 ======
diff --git a/smsd/ChangeLog b/smsd/ChangeLog
index 6f90ebb..9ed9186 100644
--- a/smsd/ChangeLog
+++ b/smsd/ChangeLog
@@ -1,3 +1,7 @@
+* Fri 13 May 2011 Paweł Kot
+- Do not call GetSMSC every time SMS is being sent.
+
+
 * Sat 09 Apr 2011 Jan Derfinak
 - Changed DB_Look() to use one trasaction per sms instead of one big
   transaction for all sms in the outbox table.
diff --git a/smsd/lowlevel.c b/smsd/lowlevel.c
index 7c728f8..c814475 100644
--- a/smsd/lowlevel.c
+++ b/smsd/lowlevel.c
@@ -255,14 +255,33 @@ static gint A_SendSMSMessage (gpointer data)
   dt = calloc (1, sizeof (gn_data));
   if (!d->sms->smsc.number[0])
   {
-    dt->message_center = calloc (1, sizeof (gn_sms_message_center));
-    dt->message_center->id = 1;
-    if (gn_sm_functions (GN_OP_GetSMSCenter, dt, sm) == GN_ERR_NONE)
+    /* keep the local cache of smsc information, it doesn't change too often */
+    static gn_gsm_number_type type = -1; /* -1: unititialized, -2:
GetSMSCenter does not work */
+    static char number[GN_BCD_STRING_MAX_LENGTH];
+
+    if (type == -2)
+      status = GN_ERR_FAILED;
+    else
+      status = GN_ERR_NONE;
+
+    if (type == -1)
+    {
+      dt->message_center = calloc (1, sizeof (gn_sms_message_center));
+      dt->message_center->id = 1;
+      if ((status = gn_sm_functions (GN_OP_GetSMSCenter, dt, sm)) ==
GN_ERR_NONE)
+      {
+        strcpy (number, dt->message_center->smsc.number);
+        type = dt->message_center->smsc.type;
+      } else {
+        type = -2;
+      }
+      free (dt->message_center);
+    }
+    if (status == GN_ERR_NONE)
     {
-      strcpy (d->sms->smsc.number, dt->message_center->smsc.number);
-      d->sms->smsc.type = dt->message_center->smsc.type;
+        strcpy (d->sms->smsc.number, number);
+        d->sms->smsc.type = type;
     }
-    free (dt->message_center);
   }

   if (!d->sms->smsc.type)
-- 
1.7.1



On Wed, May 4, 2011 at 12:26, Pawel Kot <address@hidden> wrote:
> Hi,
>
> On Wed, May 4, 2011 at 01:45, Chuck <address@hidden> wrote:
>> Hi,
>>
>> I have noticed regular smsd crashes with the version "GNOKII Version 
>> 0.6.31git".  I have several core dumps, each of which has a backtrace that 
>> terminates in nk6510.c, line 1921:
>>
>> Core was generated by `/usr/local/bin/smsd -u xxxxx -p xxxxx -d xxxxx -c 
>> xxxxxxxxx -m mysql -b IN -f /'.
>
> Thanks for this information. Does it happen on the first incoming
> message? Or after you get several ones?
>
>> Program terminated with signal 11, Segmentation fault.
>> [New process 18407]
>> [New process 18408]
>> [New process 18406]
>> #0  0xb76bbd42 in NK6510_IncomingSMS (messagetype=2,
>>    message=0x80e89f0 "\001|", length=58, data=0x81c6c98, state=0xb60a5008)
>>    at nk6510.c:1921
>> 1921                    data->message_center->id = message[8];
>
> So that's most likely because data->message_center is NULL. We'd need
> to find a reason why it is so.
>
>>
>> The phone identifies as a Nokia 6300:
>> [38885385.242588] usb 1-2: New USB device found, idVendor=0421, 
>> idProduct=04f9
>> [38885385.242588] usb 1-2: New USB device strings: Mfr=1, Product=2, 
>> SerialNumber=0
>> [38885385.242588] usb 1-2: Product: Nokia 6300
>> [38885385.242588] usb 1-2: Manufacturer: Nokia
>>
>> Is there any other information I can provide to aid in tracking down the 
>> cause of this crash?
>
> Based on the information you have provided you're using series40
> driver. However it is always useful to get the config, debug log, and
> in case of smsd also xdebug log.
>
> take care,
> --
> Pawel Kot
>



-- 
Pawel Kot



reply via email to

[Prev in Thread] Current Thread [Next in Thread]