pkot / gnokii

Open source tools for your mobile phone
http://www.gnokii.org/
GNU General Public License v2.0
38 stars 13 forks source link

smsd uses 100% CPU when SMS sending is not configured #3

Open Malvineous opened 6 years ago

Malvineous commented 6 years ago

Is it possible to stop smsd from using 100% CPU when it's running? I'm not sure why it does this, as strace reports it sitting at a futex call. Perhaps this is a libgnokii issue?

I am running with a Huawei USB device on /dev/ttyUSB0. Everything works, I can receive SMS messages, it just slows the machine down quite a bit with top reporting smsd using 100% CPU continuously.

Is this problem unique to me or do other people also see very high CPU use?

Malvineous commented 6 years ago

I've done some more investigation on this and the problem is in smsd.c:370. There is only a sleep() if the SMS outbox is empty (SMSD_OUTBOXEMPTY) but in my case the value is SMSD_NOK, which means sleep() does not get called and so the loop uses 100% CPU.

I think this behaviour is related to this message I receive at startup:

You have not set spool directory, sms sending is disabled!

I don't need to send SMS messages, so I think this is a bug that in this scenario smsd uses 100% CPU. I think instead of calling sleep() only when there are no messages waiting, it should always be called unless there is another message to send (SMSD_OK?)

This would fix the high CPU usage when smsd is not configured to send messages.