sms: Make sure that this loop is broken from time to time.
diff --git a/openbsc/src/sms_queue.c b/openbsc/src/sms_queue.c
index f6ac660..dda8ce9 100644
--- a/openbsc/src/sms_queue.c
+++ b/openbsc/src/sms_queue.c
@@ -219,7 +219,7 @@
 	int attempts = smsq->max_pending - smsq->pending;
 	int initialized = 0;
 	unsigned long long first_sub = 0;
-	int attempted = 0;
+	int attempted = 0, rounds = 0;
 
 	LOGP(DSMS, LOGL_NOTICE, "Attempting to send %d SMS\n", attempts);
 
@@ -232,6 +232,8 @@
 		if (!sms)
 			break;
 
+		rounds += 1;
+
 		/*
 		 * This code needs to detect a loop. It assumes that no SMS
 		 * will vanish during the time this is executed. We will remember
@@ -277,9 +279,9 @@
 		smsq->pending += 1;
 		llist_add(&pending->entry, &smsq->pending_sms);
 		gsm411_send_sms_subscr(sms->receiver, sms);
-	} while (attempted < attempts);
+	} while (attempted < attempts && rounds < 1000);
 
-	LOGP(DSMS, LOGL_DEBUG, "SMSqueue added %d messages\n", attempted);
+	LOGP(DSMS, LOGL_DEBUG, "SMSqueue added %d messages in %d rounds\n", attempted, rounds);
 }
 
 /*