smartnode / telebot

Telegram Bot API in C
https://elmurod.net/telebot
Apache License 2.0
159 stars 35 forks source link

Possible deadlock in telebot-core.telebot_core_curl_perform() #31

Closed Nik4053 closed 4 years ago

Nik4053 commented 4 years ago

The method sets core_h->busy = true, but never sets it back to false on error. -> Next time program will halt indefinitely.

smartnode commented 4 years ago

Indeed, there is a bug that may cause deadlock. Following patch fixes it. https://github.com/smartnode/telebot/commit/e4adb7189d57dc88d1f7aaba28d957122555eff0

Nik4053 commented 4 years ago

I am new to this kind of thing but why can we use just a normal variable as a lock? I thought a mutex or an atomic operation has to be used in such cases.

smartnode commented 4 years ago

I was using simpler alternative to mutex, and remove necessity for locking, and/or busy waiting.