Skip to content

Commit

Permalink
Added a STOPPED status to avoid re-evaluating a stopped module. Updat…
Browse files Browse the repository at this point in the history
…ed todo.
  • Loading branch information
FedeDP committed Mar 13, 2018
1 parent d453079 commit dc0dafa
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Extra/Arch/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pkgname=libmodule-git
_gitname=libmodule
pkgver=r36.5372354
pkgver=r37.d453079
pkgrel=1
pkgdesc="C linux library to build simple and modular projects"
arch=(x86_64)
Expand Down
4 changes: 2 additions & 2 deletions Lib/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,10 @@ int module_resume(const void *self) {
return MOD_ERR;
}

int module_stop(const void *self) {
int module_stop(const void *self) {
GET_MOD(self);
MODULE_DEBUG("Stopping module %s.\n", ((self_t *)self)->name);
mod->state = IDLE;
mod->state = STOPPED;
if (close(mod->fd) == 0) { // implicitly calls EPOLL_CTL_DEL
return MOD_OK;
}
Expand Down
2 changes: 1 addition & 1 deletion Lib/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
/** Structs types **/

/* Modules states */
enum module_states { IDLE, RUNNING, PAUSED };
enum module_states { IDLE, RUNNING, PAUSED, STOPPED };

typedef struct {
int fd;
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ You have some nice examples too, check [Samples](https://github.com/FedeDP/libmo

You only need cmake to build libmodule.
It does not depend upon external software.
Libmodule includes an [hashmap](https://github.com/petewarden/c_hashmap) implementation provided by Pete Warden (thank you!).
Libmodule includes an [hashmap](https://github.com/petewarden/c_hashmap) implementation provided by Pete Warden (thank you!).
To build, you only need to issue:

$ mkdir build
Expand Down
23 changes: 23 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,34 @@
# TODO

## Drop on error callback?

- [ ] drop modules_ctx_on_error (easy)
- [ ] expand error defines (eg MOD_NOT_FOUND -2 etc etc) (easy)

## Generic

- [ ] Add a module_pre_start function for each module (easy)
- [X] After module_stop -> STOPPED status (to prevent it being evaluated again after new event)
- [ ] Add a m_update_fd(int fd) function to change fd (easy)

## Much more actor like?

- [ ] implement tell and publish (per-ctx) (easy)
- [ ] implement subscribe (mid)
- [ ] add a (void *) in message_t (easy)
- [ ] implement broadcast (global message, no ctx) (easy)

### UPDATE DOC with changes until there

## Submodules

- [ ] SUBMODULE(B, A) calls module_register(B) and module_binds_to(A);
- [ ] destroy children of modules at module deregister
- [ ] bind children to parent states (ie: parent paused -> children paused; parent resumed -> children resumed...)

### UPDATE DOC with SUBMODULE interface

## Test it

- [ ] Check libmodule with valgrind again (last time it had no memleaks)
- [ ] write some tests (cmocka?)

0 comments on commit dc0dafa

Please sign in to comment.