gnokii-commit
[Top][All Lists]
Advanced

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

[SCM] libgnokii and core programs branch, master, updated. rel_0_6_29-23


From: Jan Derfinak
Subject: [SCM] libgnokii and core programs branch, master, updated. rel_0_6_29-232-gff3c162
Date: Mon, 30 May 2011 20:29:53 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "libgnokii and core programs".

The branch, master has been updated
       via  ff3c16272faf192690521674f318d20691c6ade1 (commit)
      from  f173ccab754c9f13510e5f04f0e0999b6b48c836 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/gnokii.git/commit/?id=ff3c16272faf192690521674f318d20691c6ade1


commit ff3c16272faf192690521674f318d20691c6ade1
Author: Jan Derfinak <address@hidden>
Date:   Mon May 30 22:29:14 2011 +0200

    Added 5 seconds sleep if outbox doesn't contain unprocessed sms.

diff --git a/smsd/ChangeLog b/smsd/ChangeLog
index 9ed9186..f16a707 100644
--- a/smsd/ChangeLog
+++ b/smsd/ChangeLog
@@ -1,3 +1,9 @@
+* Sat 28 May 2011 Jan Derfinak
+- After patch from 09 Apr 2011, the query interval for looking to outbox was
+  too small and smsd overloads db server. Added 5 seconds sleep if outbox
+  doesn't contain unprocessed sms. (Bug report from João Areias).
+
+
 * Fri 13 May 2011 Paweł Kot
 - Do not call GetSMSC every time SMS is being sent.
 
diff --git a/smsd/db.h b/smsd/db.h
index b037e05..c5a0437 100644
--- a/smsd/db.h
+++ b/smsd/db.h
@@ -36,6 +36,6 @@ GNOKII_API void (*DB_Bye) (void);
 GNOKII_API gint (*DB_ConnectInbox) (const DBConfig);
 GNOKII_API gint (*DB_ConnectOutbox) (const DBConfig);
 GNOKII_API gint (*DB_InsertSMS) (const gn_sms * const, const gchar * const);
-GNOKII_API void (*DB_Look) (const gchar * const);
+GNOKII_API gint (*DB_Look) (const gchar * const);
 
 #endif
diff --git a/smsd/mysql.c b/smsd/mysql.c
index 9d7617d..2959493 100644
--- a/smsd/mysql.c
+++ b/smsd/mysql.c
@@ -304,12 +304,13 @@ GNOKII_API gint DB_InsertSMS (const gn_sms * const data, 
const gchar * const pho
 }
 
 
-GNOKII_API void DB_Look (const gchar * const phone)
+GNOKII_API gint DB_Look (const gchar * const phone)
 {
   GString *buf, *phnStr;
   MYSQL_RES *res1;
   MYSQL_ROW row;
   gint numError, error;
+  gint empty = 1;
 
   if (phone[0] == '\0')
     phnStr = g_string_new ("");
@@ -335,7 +336,7 @@ GNOKII_API void DB_Look (const gchar * const phone)
     g_print (_("Error: %s\n"), mysql_error (&mysqlOut));
     mysql_real_query (&mysqlOut, "ROLLBACK TRANSACTION", strlen ("ROLLBACK 
TRANSACTION"));
     g_string_free (buf, TRUE);
-    return;
+    return (SMSD_NOK);
   }
 
   if (!(res1 = mysql_store_result (&mysqlOut)))
@@ -344,13 +345,14 @@ GNOKII_API void DB_Look (const gchar * const phone)
     g_print (_("Error: %s\n"), mysql_error (&mysqlOut));
     mysql_real_query (&mysqlOut, "ROLLBACK TRANSACTION", strlen ("ROLLBACK 
TRANSACTION"));
     g_string_free (buf, TRUE);
-    return;
+    return (SMSD_NOK);
   }
   
   while ((row = mysql_fetch_row (res1)))
   {
     gn_sms sms;
 
+    empty = 0;
     gn_sms_default_submit (&sms);    
     memset (&sms.remote.number, 0, sizeof (sms.remote.number));
     sms.delivery_report = atoi (row[3]);
@@ -403,4 +405,9 @@ GNOKII_API void DB_Look (const gchar * const phone)
   mysql_real_query (&mysqlOut, "COMMIT", strlen ("COMMIT"));
   
   g_string_free (buf, TRUE);
+  
+  if (empty)
+    return (SMSD_OUTBOXEMPTY);
+  else
+    return (SMSD_OK);
 }
diff --git a/smsd/pq.c b/smsd/pq.c
index 0e7f05b..02bf8c8 100644
--- a/smsd/pq.c
+++ b/smsd/pq.c
@@ -341,12 +341,13 @@ GNOKII_API gint DB_InsertSMS (const gn_sms * const data, 
const gchar * const pho
 }
 
 
-GNOKII_API void DB_Look (const gchar * const phone)
+GNOKII_API gint DB_Look (const gchar * const phone)
 {
   GString *buf, *phnStr;
   PGresult *res1, *res2;
   register int i;
   gint numError, error;
+  gint empty = 1;
 
   if (phone[0] == '\0')
     phnStr = g_string_new ("");
@@ -377,13 +378,14 @@ GNOKII_API void DB_Look (const gchar * const phone)
     res1 = PQexec (connOut, "ROLLBACK TRANSACTION");
     PQclear (res1);
     g_string_free (buf, TRUE);
-    return;
+    return (SMSD_NOK);
   }
 
   for (i = 0; i < PQntuples (res1); i++)
   {
     gn_sms sms;
     
+    empty = 0;
     gn_sms_default_submit (&sms);
     memset (&sms.remote.number, 0, sizeof (sms.remote.number));
     sms.delivery_report = atoi (PQgetvalue (res1, i, 3));
@@ -433,4 +435,9 @@ GNOKII_API void DB_Look (const gchar * const phone)
   PQclear (res1);
 
   g_string_free (buf, TRUE);
+  
+  if (empty)
+    return (SMSD_OUTBOXEMPTY);
+  else
+    return (SMSD_OK);
 }
diff --git a/smsd/smsd.c b/smsd/smsd.c
index 779522a..4e47381 100644
--- a/smsd/smsd.c
+++ b/smsd/smsd.c
@@ -71,7 +71,7 @@ void (*DB_Bye) (void) = NULL;
 gint (*DB_ConnectInbox) (const DBConfig) = NULL;
 gint (*DB_ConnectOutbox) (const DBConfig) = NULL;
 gint (*DB_InsertSMS) (const gn_sms * const, const gchar * const) = NULL;
-void (*DB_Look) (const gchar * const) = NULL;
+gint (*DB_Look) (const gchar * const) = NULL;
 
 static pthread_t db_monitor_th;
 pthread_mutex_t db_monitorMutex;
@@ -372,7 +372,8 @@ static void *SendSMS (void *a)
     }
     pthread_mutex_unlock (&db_monitorMutex);
 
-    (*DB_Look) (smsdConfig.phone);
+    if ((*DB_Look) (smsdConfig.phone) == SMSD_OUTBOXEMPTY)
+      sleep (5);
   }
 }
 
diff --git a/smsd/smsd.h b/smsd/smsd.h
index ddfadcb..1de8bc0 100644
--- a/smsd/smsd.h
+++ b/smsd/smsd.h
@@ -40,6 +40,7 @@
 #define SMSD_NOK       1
 #define SMSD_DUPLICATE 2
 #define SMSD_WAITING   3
+#define SMSD_OUTBOXEMPTY       4
 
 typedef enum {
   SMSD_READ_REPORTS = 1
diff --git a/smsd/sqlite.c b/smsd/sqlite.c
index 10ebebf..dac3659 100644
--- a/smsd/sqlite.c
+++ b/smsd/sqlite.c
@@ -142,13 +142,14 @@ GNOKII_API gint DB_InsertSMS(const gn_sms * const data, 
const gchar * const phon
     return SMSD_OK;
 }
 
-GNOKII_API void DB_Look(const gchar * const phone)
+GNOKII_API gint DB_Look(const gchar * const phone)
 {
     GString *buf, *phnStr, *timebuf;
     gint ret1, numError, error;
     time_t rawtime;
     struct tm * timeinfo;
     sqlite3_stmt * stmt;
+    gint empty = 1;
 
     if (phone[0] == '\0')
         phnStr = g_string_new("");
@@ -180,7 +181,7 @@ GNOKII_API void DB_Look(const gchar * const phone)
     if (ret1 != SQLITE_OK) {
         g_print(_("%d: Parsing query %s failed!"), __LINE__, buf->str);
         g_print(_("Error: %s"), sqlite3_errmsg(ppDbInbox));
-        return;
+        return (SMSD_NOK);
     }
 
     g_string_printf(timebuf, "'%02d-%02d-%02d %02d:%02d:%02d'",
@@ -194,6 +195,7 @@ GNOKII_API void DB_Look(const gchar * const phone)
         int gerror = 0;
         gn_sms sms;
 
+        empty = 0;
         gn_sms_default_submit(&sms);
         memset(&sms.remote.number, 0, sizeof (sms.remote.number));
         sms.delivery_report = sqlite3_column_int(stmt, 3);
@@ -241,11 +243,16 @@ GNOKII_API void DB_Look(const gchar * const phone)
 
         g_string_free(timebuf, TRUE);
         g_string_free(buf, TRUE);
-        return;
+        return (SMSD_NOK);
     }
     sqlite3_finalize(stmt);
     sqlite3_exec(ppDbOutbox, "COMMIT;", NULL, NULL, NULL);
 
     g_string_free(timebuf, TRUE);
     g_string_free(buf, TRUE);
+    
+    if (empty)
+      return (SMSD_OUTBOXEMPTY);
+    else
+      return (SMSD_OK);
 }

-----------------------------------------------------------------------

Summary of changes:
 smsd/ChangeLog |    6 ++++++
 smsd/db.h      |    2 +-
 smsd/mysql.c   |   13 ++++++++++---
 smsd/pq.c      |   11 +++++++++--
 smsd/smsd.c    |    5 +++--
 smsd/smsd.h    |    1 +
 smsd/sqlite.c  |   13 ++++++++++---
 7 files changed, 40 insertions(+), 11 deletions(-)


hooks/post-receive
-- 
libgnokii and core programs



reply via email to

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