Hi,
I was using debian version of kannel (1.4.1-2) and noticed that if
initialization of GSM modem fail (for example, USB cable is not connected and
modem device doesn't exist), bearerbox uses 100% CPU.
I've modified smsc_at.c so that it sleeps for reconnect-delay seconds between
retries even when failures occur early in initialization process.
Also now it should exit the retry loop if privdata->shutdown is set.
If someone is interested - my changes are attached to this message. Of course
if it isn't already fixed in the CVS :)
--
BR,
Ernestas Vaiciukevičius
http://ernis.blogsite.org/
--- kannel-1.4.1/gw/smsc/smsc_at.c.orig 2006-05-23 16:27:31.000000000 +0300
+++ kannel-1.4.1/gw/smsc/smsc_at.c 2008-02-06 21:57:31.000000000 +0200
@@ -1093,7 +1093,7 @@
{
SMSCConn *conn = arg;
PrivAT2data *privdata = conn->data;
- int l, reconnecting = 0, error_count = 0;
+ int l, reconnecting = 0, error_count = 0, starting = 1;
long idle_timeout, memory_poll_timeout = 0;
conn->status = SMSCCONN_CONNECTING;
@@ -1103,7 +1103,7 @@
reconnect:
- do {
+ while (!privdata->shutdown) {
if (reconnecting) {
if (conn->status == SMSCCONN_ACTIVE) {
mutex_lock(conn->flow_mutex);
@@ -1112,8 +1112,11 @@
}
error(0, "AT2[%s]: Couldn't connect (retrying in %ld seconds).",
octstr_get_cstr(privdata->name), conn->reconnect_delay);
- gwthread_sleep(conn->reconnect_delay);
}
+ if (! starting) {
+ gwthread_sleep(conn->reconnect_delay);
+ }
+ starting = 0;
/* If modems->speed is defined, try to use it, else autodetect */
if (privdata->speed == 0 && privdata->modem != NULL && privdata->modem->speed != 0) {
@@ -1167,7 +1170,7 @@
/* If we got here, then the device is opened */
break;
- } while (!privdata->shutdown);
+ }
mutex_lock(conn->flow_mutex);
conn->status = SMSCCONN_ACTIVE;