Skip to content

Commit

Permalink
make z_close take session by mutable reference
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisBiryukov91 committed Oct 4, 2024
1 parent 2556404 commit 973394f
Show file tree
Hide file tree
Showing 89 changed files with 197 additions and 156 deletions.
1 change: 1 addition & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,7 @@ Functions
^^^^^^^^^
.. autocfunction:: primitives.h::z_open
.. autocfunction:: primitives.h::z_close
.. autocfunction:: primitives.h::z_session_is_closed
.. autocfunction:: primitives.h::z_info_zid
.. autocfunction:: primitives.h::z_info_routers_zid
Expand Down
2 changes: 1 addition & 1 deletion examples/arduino/z_get.ino
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void setup() {
// Start read and lease tasks for zenoh-pico
if (zp_start_read_task(z_session_loan_mut(&s), NULL) < 0 || zp_start_lease_task(z_session_loan_mut(&s), NULL) < 0) {
Serial.println("Unable to start read and lease tasks\n");
z_close(z_session_move(&s), NULL);
z_session_drop(z_session_move(&s));
while (1) {
;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/arduino/z_pub.ino
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void setup() {
// Start read and lease tasks for zenoh-pico
if (zp_start_read_task(z_session_loan_mut(&s), NULL) < 0 || zp_start_lease_task(z_session_loan_mut(&s), NULL) < 0) {
Serial.println("Unable to start read and lease tasks\n");
z_close(z_session_move(&s), NULL);
z_session_drop(z_session_move(&s));
while (1) {
;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/arduino/z_pull.ino
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void setup() {
// Start read and lease tasks for zenoh-pico
if (zp_start_read_task(z_session_loan_mut(&s), NULL) < 0 || zp_start_lease_task(z_session_loan_mut(&s), NULL) < 0) {
Serial.println("Unable to start read and lease tasks\n");
z_close(z_session_move(&s), NULL);
z_session_drop(z_session_move(&s));
while (1) {
;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/arduino/z_queryable.ino
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void setup() {
// Start read and lease tasks for zenoh-pico
if (zp_start_read_task(z_session_loan_mut(&s), NULL) < 0 || zp_start_lease_task(z_session_loan_mut(&s), NULL) < 0) {
Serial.println("Unable to start read and lease tasks\n");
z_close(z_session_move(&s), NULL);
z_session_drop(z_session_move(&s));
while (1) {
;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/arduino/z_sub.ino
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void setup() {
// Start read and lease tasks for zenoh-pico
if (zp_start_read_task(z_session_loan_mut(&s), NULL) < 0 || zp_start_lease_task(z_session_loan_mut(&s), NULL) < 0) {
Serial.println("Unable to start read and lease tasks\n");
z_close(z_session_move(&s), NULL);
z_session_drop(z_session_move(&s));
while (1) {
;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/espidf/z_get.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ void app_main() {

printf("Closing Zenoh Session...");

z_close(z_move(s), NULL);
z_drop(z_move(s));
printf("OK!\n");
}
#else
Expand Down
2 changes: 1 addition & 1 deletion examples/espidf/z_pub.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ void app_main() {
printf("Closing Zenoh Session...");
z_undeclare_publisher(z_move(pub));

z_close(z_move(s), NULL);
z_drop(z_move(s));
printf("OK!\n");
}
#else
Expand Down
4 changes: 2 additions & 2 deletions examples/espidf/z_pull.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ void app_main() {
// Start read and lease tasks for zenoh-pico
if (zp_start_read_task(z_loan_mut(s), NULL) < 0 || zp_start_lease_task(z_loan_mut(s), NULL) < 0) {
printf("Unable to start read and lease tasks\n");
z_close(z_session_move(&s), NULL);
z_session_drop(z_session_move(&s));
exit(-1);
}

Expand Down Expand Up @@ -181,7 +181,7 @@ void app_main() {
z_undeclare_subscriber(z_move(sub));
z_drop(z_move(handler));

z_close(z_move(s), NULL);
z_drop(z_move(s));
printf("OK!\n");
}
#else
Expand Down
2 changes: 1 addition & 1 deletion examples/espidf/z_queryable.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void app_main() {
printf("Closing Zenoh Session...");
z_undeclare_queryable(z_move(qable));

z_close(z_move(s), NULL);
z_drop(z_move(s));
printf("OK!\n");
}
#else
Expand Down
2 changes: 1 addition & 1 deletion examples/espidf/z_sub.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ void app_main() {
printf("Closing Zenoh Session...");
z_undeclare_subscriber(z_move(sub));

z_close(z_move(s), NULL);
z_drop(z_move(s));
printf("OK!\n");
}
#else
Expand Down
4 changes: 2 additions & 2 deletions examples/freertos_plus_tcp/z_get.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void app_main(void) {
// Start read and lease tasks for zenoh-pico
if (zp_start_read_task(z_loan_mut(s), NULL) < 0 || zp_start_lease_task(z_loan_mut(s), NULL) < 0) {
printf("Unable to start read and lease tasks\n");
z_close(z_session_move(&s), NULL);
z_session_drop(z_session_move(&s));
return;
}

Expand Down Expand Up @@ -100,7 +100,7 @@ void app_main(void) {
}
}

z_close(z_move(s), NULL);
z_drop(z_move(s));
}
#else
void app_main(void) {
Expand Down
4 changes: 2 additions & 2 deletions examples/freertos_plus_tcp/z_pub.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void app_main(void) {
if (zp_start_read_task(z_loan_mut(s), &read_task_opt) < 0 ||
zp_start_lease_task(z_loan_mut(s), &lease_task_opt) < 0) {
printf("Unable to start read and lease tasks\n");
z_close(z_session_move(&s), NULL);
z_session_drop(z_session_move(&s));
return;
}

Expand Down Expand Up @@ -108,7 +108,7 @@ void app_main(void) {

// Clean-up
z_undeclare_publisher(z_move(pub));
z_close(z_move(s), NULL);
z_drop(z_move(s));
}
#else
void app_main(void) {
Expand Down
2 changes: 1 addition & 1 deletion examples/freertos_plus_tcp/z_pub_st.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void app_main(void) {

z_undeclare_publisher(z_move(pub));

z_close(z_move(s), NULL);
z_drop(z_move(s));
}
#else
void app_main(void) {
Expand Down
4 changes: 2 additions & 2 deletions examples/freertos_plus_tcp/z_pull.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void app_main(void) {
// Start read and lease tasks for zenoh-pico
if (zp_start_read_task(z_loan_mut(s), NULL) < 0 || zp_start_lease_task(z_loan_mut(s), NULL) < 0) {
printf("Unable to start read and lease tasks\n");
z_close(z_session_move(&s), NULL);
z_session_drop(z_session_move(&s));
return;
}

Expand Down Expand Up @@ -90,7 +90,7 @@ void app_main(void) {
z_undeclare_subscriber(z_move(sub));
z_drop(z_move(handler));

z_close(z_move(s), NULL);
z_drop(z_move(s));
}
#else
void app_main(void) {
Expand Down
6 changes: 3 additions & 3 deletions examples/freertos_plus_tcp/z_put.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void app_main(void) {
// Start read and lease tasks for zenoh-pico
if (zp_start_read_task(z_loan_mut(s), NULL) < 0 || zp_start_lease_task(z_loan_mut(s), NULL) < 0) {
printf("Unable to start read and lease tasks\n");
z_close(z_session_move(&s), NULL);
z_session_drop(z_session_move(&s));
return;
}

Expand All @@ -57,7 +57,7 @@ void app_main(void) {
z_view_keyexpr_from_str_unchecked(&vke, KEYEXPR);
if (z_declare_keyexpr(&ke, z_loan(s), z_loan(vke)) < 0) {
printf("Unable to declare key expression!\n");
z_close(z_move(s), NULL);
z_drop(z_move(s));
return;
}

Expand All @@ -79,7 +79,7 @@ void app_main(void) {

// Clean up
z_undeclare_keyexpr(z_move(ke), z_loan(s));
z_close(z_move(s), NULL);
z_drop(z_move(s));
}
#else
void app_main(void) {
Expand Down
4 changes: 2 additions & 2 deletions examples/freertos_plus_tcp/z_queryable.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void app_main(void) {
// Start read and lease tasks for zenoh-pico
if (zp_start_read_task(z_loan_mut(s), NULL) < 0 || zp_start_lease_task(z_loan_mut(s), NULL) < 0) {
printf("Unable to start read and lease tasks\n");
z_close(z_session_move(&s), NULL);
z_session_drop(z_session_move(&s));
return;
}

Expand All @@ -98,7 +98,7 @@ void app_main(void) {

z_undeclare_queryable(z_move(qable));

z_close(z_move(s), NULL);
z_drop(z_move(s));
}
#else
void app_main(void) {
Expand Down
4 changes: 2 additions & 2 deletions examples/freertos_plus_tcp/z_sub.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void app_main(void) {
// Start read and lease tasks for zenoh-pico
if (zp_start_read_task(z_loan_mut(s), NULL) < 0 || zp_start_lease_task(z_loan_mut(s), NULL) < 0) {
printf("Unable to start read and lease tasks\n");
z_close(z_session_move(&s), NULL);
z_session_drop(z_session_move(&s));
return;
}

Expand All @@ -78,7 +78,7 @@ void app_main(void) {

z_undeclare_subscriber(z_move(sub));

z_close(z_move(s), NULL);
z_drop(z_move(s));
}
#else
void app_main(void) {
Expand Down
2 changes: 1 addition & 1 deletion examples/freertos_plus_tcp/z_sub_st.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void app_main(void) {

z_undeclare_subscriber(z_move(sub));

z_close(z_move(s), NULL);
z_drop(z_move(s));
}
#else
void app_main(void) {
Expand Down
2 changes: 1 addition & 1 deletion examples/mbed/z_get.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ int main(int argc, char **argv) {

printf("Closing Zenoh Session...");

z_close(z_session_move(&s), NULL);
z_session_drop(z_session_move(&s));
printf("OK!\n");

return 0;
Expand Down
2 changes: 1 addition & 1 deletion examples/mbed/z_pub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ int main(int argc, char **argv) {
printf("Closing Zenoh Session...");
z_undeclare_publisher(z_publisher_move(&pub));

z_close(z_session_move(&s), NULL);
z_session_drop(z_session_move(&s));
printf("OK!\n");

return 0;
Expand Down
4 changes: 2 additions & 2 deletions examples/mbed/z_pull.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ int main(int argc, char **argv) {
// Start read and lease tasks for zenoh-pico
if (zp_start_read_task(z_session_loan_mut(&s), NULL) < 0 || zp_start_lease_task(z_session_loan_mut(&s), NULL) < 0) {
printf("Unable to start read and lease tasks\n");
z_close(z_session_move(&s), NULL);
z_session_drop(z_session_move(&s));
return -1;
}

Expand Down Expand Up @@ -104,7 +104,7 @@ int main(int argc, char **argv) {
z_undeclare_subscriber(z_subscriber_move(&sub));
z_ring_handler_sample_drop(z_ring_handler_sample_move(&handler));

z_close(z_session_move(&s), NULL);
z_session_drop(z_session_move(&s));
printf("OK!\n");

return 0;
Expand Down
2 changes: 1 addition & 1 deletion examples/mbed/z_queryable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ int main(int argc, char **argv) {
printf("Closing Zenoh Session...");
z_undeclare_queryable(z_queryable_move(&qable));

z_close(z_session_move(&s), NULL);
z_session_drop(z_session_move(&s));
printf("OK!\n");

return 0;
Expand Down
2 changes: 1 addition & 1 deletion examples/mbed/z_sub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ int main(int argc, char **argv) {
printf("Closing Zenoh Session...");
z_undeclare_subscriber(z_subscriber_move(&sub));

z_close(z_session_move(&s), NULL);
z_session_drop(z_session_move(&s));
printf("OK!\n");

return 0;
Expand Down
4 changes: 2 additions & 2 deletions examples/unix/c11/z_get.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ int main(int argc, char **argv) {
// Start read and lease tasks for zenoh-pico
if (zp_start_read_task(z_loan_mut(s), NULL) < 0 || zp_start_lease_task(z_loan_mut(s), NULL) < 0) {
printf("Unable to start read and lease tasks\n");
z_close(z_session_move(&s), NULL);
z_session_drop(z_session_move(&s));
return -1;
}

Expand Down Expand Up @@ -143,7 +143,7 @@ int main(int argc, char **argv) {
z_condvar_wait(z_loan_mut(cond), z_loan_mut(mutex));
z_mutex_unlock(z_loan_mut(mutex));

z_close(z_move(s), NULL);
z_drop(z_move(s));
return 0;
}

Expand Down
4 changes: 2 additions & 2 deletions examples/unix/c11/z_get_attachment.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ int main(int argc, char **argv) {
// Start read and lease tasks for zenoh-pico
if (zp_start_read_task(z_loan_mut(s), NULL) < 0 || zp_start_lease_task(z_loan_mut(s), NULL) < 0) {
printf("Unable to start read and lease tasks\n");
z_close(z_session_move(&s), NULL);
z_session_drop(z_session_move(&s));
return -1;
}

Expand Down Expand Up @@ -201,7 +201,7 @@ int main(int argc, char **argv) {
z_condvar_wait(z_loan_mut(cond), z_loan_mut(mutex));
z_mutex_unlock(z_loan_mut(mutex));

z_close(z_move(s), NULL);
z_drop(z_move(s));
return 0;
}
#else
Expand Down
4 changes: 2 additions & 2 deletions examples/unix/c11/z_get_channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ int main(int argc, char **argv) {
// Start read and lease tasks for zenoh-pico
if (zp_start_read_task(z_loan_mut(s), NULL) < 0 || zp_start_lease_task(z_loan_mut(s), NULL) < 0) {
printf("Unable to start read and lease tasks\n");
z_close(z_session_move(&s), NULL);
z_session_drop(z_session_move(&s));
return -1;
}

Expand Down Expand Up @@ -123,7 +123,7 @@ int main(int argc, char **argv) {

z_drop(z_move(handler));

z_close(z_move(s), NULL);
z_drop(z_move(s));

return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions examples/unix/c11/z_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ int main(int argc, char **argv) {
// Start read and lease tasks for zenoh-pico
if (zp_start_read_task(z_loan_mut(s), NULL) < 0 || zp_start_lease_task(z_loan_mut(s), NULL) < 0) {
printf("Unable to start read and lease tasks\n");
z_close(z_session_move(&s), NULL);
z_session_drop(z_session_move(&s));
return -1;
}

Expand All @@ -96,5 +96,5 @@ int main(int argc, char **argv) {
z_closure(&callback2, print_zid);
z_info_peers_zid(z_loan(s), z_move(callback2));

z_close(z_move(s), NULL);
z_drop(z_move(s));
}
4 changes: 2 additions & 2 deletions examples/unix/c11/z_ping.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ int main(int argc, char** argv) {

if (zp_start_read_task(z_loan_mut(session), NULL) < 0 || zp_start_lease_task(z_loan_mut(session), NULL) < 0) {
printf("Unable to start read and lease tasks\n");
z_close(z_session_move(&session), NULL);
z_drop(z_move(session));
return -1;
}

Expand Down Expand Up @@ -135,7 +135,7 @@ int main(int argc, char** argv) {
z_drop(z_move(pub));
z_drop(z_move(sub));

z_close(z_move(session), NULL);
z_drop(z_move(session));
}

char* getopt(int argc, char** argv, char option) {
Expand Down
Loading

0 comments on commit 973394f

Please sign in to comment.