简体   繁体   English

dbus:刷新连接?

[英]dbus: flush connection?

When I do a "dbus_connection_close", do I need to flush the message queue? 当我执行“dbus_connection_close”时,是否需要刷新消息队列?

In other words, do I need to continue with "dbus_connection_read_write_dispatch" until I receive the "disconnected" indication or is it safe to stop dispatching? 换句话说,我是否需要继续使用“dbus_connection_read_write_dispatch”,直到我收到“断开连接”指示或者是否可以安全地停止调度?

Updated: I need to close the connection to DBus in a clean manner. 更新:我需要以干净的方式关闭与DBus的连接。 From reading the documentation, all the clean-up must be done prior to "unreferencing" the connection and this process isn't very well documented IMO. 从阅读文档开始,所有的清理工作都必须在“不参考”连接之前完成,而且这个过程并没有很好地记录在IMO中。

After some more digging, it appears that there are two types of connection: shared and private. 经过一些挖掘后,似乎有两种类型的连接:共享和私有。

The shared connection mustn't be closed just unreferenced . 不能仅在未引用的情况下关闭共享连接。 Furthermore, it does not appear that the connection must be flushed & dispatched unless the outgoing messages must be delivered. 此外, 除非必须传递外发消息,否则似乎不必刷新和分派连接。

In my case, I just needed to end the communication over DBus as soon as possible without trying to salvage any outgoing messages. 就我而言,我只需要尽快结束对DBus的通信,而不是试图挽救任何传出的消息。

Thus the short answer is: NO - no flushing / no dispatching needs to be done prior to dbus_connection_unref . 因此简短的回答是:NO - 在dbus_connection_unref之前不需要刷新/不需要调度。

Looking at the documentation for dbus_connection_close() , the only thing that may be invoked is the dispatch status function to indicate that the connection has been closed. 查看dbus_connection_close()的文档 ,唯一可以调用的是调度状态函数,以指示连接已关闭。

So, ordering here is something you probably want to pay attention to .. ie getting notified of a closed / dropped connection prior to things left in the message queue. 因此,在这里订购是您可能需要注意的事项......即在消息队列中的事情发生之前获得关闭/断开连接的通知。

Looking at the source of the function , it looks like the only thing its going to do is return if fail, ie invalid connection / NULL pointer. 查看函数来源 ,看起来它唯一要做的就是失败时返回,即无效的连接/ NULL指针。 Otherwise, it (seems) to just hang up. 否则,它(好像)只是挂断电话。

This means yes, you probably should flush the message queue prior to hanging up. 这意味着是的,您可能应该在挂起之前刷新消息队列。

Disclaimer : I've only had to talk to dbus a few times, I'm not by any means an authority on it. 免责声明 :我只需要与dbus谈几次,我绝对不是权威。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM