eclipse-zenoh / zenoh-c

C API for Zenoh
http://zenoh.io
Other
80 stars 57 forks source link

`z_session_drop` should call `z_close` #689

Open milyin opened 2 months ago

milyin commented 2 months ago

Currenly z_session_drop simply drops rust's Session object and z_close explicitly calls Session::close().

This difference is not really significant: there is no clone operation for Session object in zenoh-c, so dropping last session instance is the same as explicit close.

But this difference makes code unclear for ones who want to understand difference between z_close and z_session_drop by reading sources. Is it a bug that z_session_drop doesn't close session explicitly? Is the behavior of z_close and z_session_drop different and how?

The fact that z_close accepts z_close_options_t parameter makes things even more complicated.

The proposal for right now is to explicitly call z_close from z_session_drop with NULL options parameter. I.e. it will be obvious, that z_session_drop and z_close are equal except this options parameter.

In the future if we decide to restore clone operation for the session this behavior could be changed