Skip to content

Commit

Permalink
Fixed possible memleak in Poll example.
Browse files Browse the repository at this point in the history
  • Loading branch information
FedeDP committed Mar 10, 2019
1 parent 22a8371 commit 3fcba79
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions Samples/Poll/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@ int main() {
int ret = 0;
int fd = 0;

/* Get default context fd */
if (modules_get_fd(&fd) != MOD_OK) {
/* No context! */
/* Initial dispatch */
if (modules_dispatch(&ret) != MOD_OK) {
return 1;
}

/* Initial dispatch */
if (modules_dispatch(&ret) != MOD_OK) {
/* Get default context fd */
if (modules_get_fd(&fd) != MOD_OK) {
return 1;
}

Expand Down
2 changes: 1 addition & 1 deletion docs/src/concepts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ Libmodule offers an internal loop, started with modules_ctx_loop(); note that ea
Moreover, you can even easily integrate it into your own loop: modules_ctx_get_fd() will retrieve a pollable fd and POLLIN events will be raised whenever a new message is available. |br|
Remember that before starting your loop, modules_ctx_dispatch() should be called, to dispatch initial "LoopStarted" messages to each module. |br|
Then, whenever POLLIN data is available on libmodule's fd, you only need to call modules_ctx_dispatch() again. |br|
Finally, remember to close libmodule's fd retrieved through modules_ctx_get_fd(). |br|
Finally, remember to close() libmodule's fd retrieved through modules_ctx_get_fd(). |br|

0 comments on commit 3fcba79

Please sign in to comment.