Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

更新cpp-httplib以保证线程安全 #133

Closed
Numendacil opened this issue Jan 26, 2022 · 1 comment · Fixed by #135
Closed

更新cpp-httplib以保证线程安全 #133

Numendacil opened this issue Jan 26, 2022 · 1 comment · Fixed by #135
Labels
enhancement New feature or request

Comments

@Numendacil
Copy link
Contributor

项目里所用的httplib.h版本存在线程安全问题(不同线程同时调用send()会导致socket创建出现问题,见 #492),而原仓库在commit e022b8b给send函数加了锁,从而避免了这一问题(见 #679

(不过在多个线程里共用一个HttpClient感觉是不是也不太好?我觉得可能更好的方式是在程序调用SendMessage时不直接发送请求而是先把请求push到一个消息队列里,然后再MiraiBot单独开一个线程专门负责消息队列的处理。这样其实也就不用关心第三方库是否实现了thread-safety了

@cyanray
Copy link
Owner

cyanray commented Jan 26, 2022

居然还有这种问题,我欠考虑了。
加一个消息队列的做法是值得考虑的,因为我最近也想用什么方法控制发送消息的频率。
这几天会弄上去的。

@cyanray cyanray added the enhancement New feature or request label Jan 26, 2022
@cyanray cyanray changed the title 请求更新cpp-httplib 更新cpp-httplib以保证线程安全 Jan 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants