diff -uNr gnokii/smsd/mysql.c gnokii.new/smsd/mysql.c --- gnokii/smsd/mysql.c 2011-02-28 01:28:15.669526667 +0100 +++ gnokii.new/smsd/mysql.c 2011-04-03 01:34:28.327642339 +0200 @@ -321,9 +321,11 @@ buf = g_string_sized_new (256); + mysql_real_query (&mysqlOut, "BEGIN", strlen ("BEGIN")); + g_string_printf (buf, "SELECT id, number, text, dreport FROM outbox \ WHERE processed='0' AND CURTIME() >= not_before \ - AND CURTIME() <= not_after %s", phnStr->str); + AND CURTIME() <= not_after %s LIMIT 1 FOR UPDATE", phnStr->str); g_string_free (phnStr, TRUE); if (mysql_real_query (&mysqlOut, buf->str, buf->len)) @@ -331,6 +333,7 @@ g_print (_("%d: SELECT FROM outbox command failed.\n"), __LINE__); gn_log_xdebug ("%s\n", buf->str); g_print (_("Error: %s\n"), mysql_error (&mysqlOut)); + mysql_real_query (&mysqlOut, "ROLLBACK TRANSACTION", strlen ("ROLLBACK TRANSACTION")); g_string_free (buf, TRUE); return; } @@ -339,6 +342,7 @@ { g_print (_("%d: Store Mysql Result Failed.\n"), __LINE__); g_print (_("Error: %s\n"), mysql_error (&mysqlOut)); + mysql_real_query (&mysqlOut, "ROLLBACK TRANSACTION", strlen ("ROLLBACK TRANSACTION")); g_string_free (buf, TRUE); return; } @@ -396,5 +400,7 @@ mysql_free_result (res1); + mysql_real_query (&mysqlOut, "COMMIT", strlen ("COMMIT")); + g_string_free (buf, TRUE); } diff -uNr gnokii/smsd/pq.c gnokii.new/smsd/pq.c --- gnokii/smsd/pq.c 2011-02-28 01:28:15.669526667 +0100 +++ gnokii.new/smsd/pq.c 2011-04-03 01:27:37.217642343 +0200 @@ -358,9 +358,12 @@ buf = g_string_sized_new (256); + res1 = PQexec (connOut, "BEGIN"); + PQclear (res1); + g_string_printf (buf, "SELECT id, number, text, dreport FROM %s.outbox \ WHERE processed='f' AND localtime(0) >= not_before \ - AND localtime(0) <= not_after %s FOR UPDATE", + AND localtime(0) <= not_after %s LIMIT 1 FOR UPDATE", schema, phnStr->str); g_string_free (phnStr, TRUE); @@ -371,6 +374,8 @@ gn_log_xdebug ("%s\n", buf->str); g_print (_("Error: %s\n"), PQerrorMessage (connOut)); PQclear (res1); + res1 = PQexec (connOut, "ROLLBACK TRANSACTION"); + PQclear (res1); g_string_free (buf, TRUE); return; } @@ -424,6 +429,8 @@ } PQclear (res1); + res1 = PQexec (connOut, "COMMIT"); + PQclear (res1); g_string_free (buf, TRUE); } diff -uNr gnokii/smsd/smsd.c gnokii.new/smsd/smsd.c --- gnokii/smsd/smsd.c 2011-03-14 14:37:58.936369334 +0100 +++ gnokii.new/smsd/smsd.c 2011-04-03 01:22:05.410975672 +0200 @@ -373,8 +373,6 @@ pthread_mutex_unlock (&db_monitorMutex); (*DB_Look) (smsdConfig.phone); - - sleep (3); } }