Skip to content

Releases: FedeDP/libmodule

v5.0.1

20 Dec 10:15
Compare
Choose a tag to compare

Hi everyone, long time no see;
actually pushing forward libmodule 6.0.0 that will contain lots of API breaks but fortunately lots of goodies too!

This is just a minor release that just fixes a small bug:

  • Properly manage EPOLLERR event flag in epoll plugin

And, by the way, merry xmas everyone!

v5.0.0

07 Sep 07:41
Compare
Choose a tag to compare

Libmodule 5.0.0

I am proud to present you a new major version of libmodule.
There has been lots of work to any area of the library to provide an elegant, simple and beautiful API, while being more effective.
This release breaks API thus version was bumped.

Highlights

Module

Module API has seen quite lots of improvements in nearly every aspects.
It now spots more coherent namings, uses less resources and it always trusts user pointers, now as core principle.

New APIs

  • self() macro is now exposed in module_easy API to retrieve _self variable
  • module_poisonpill() is a new function to enqueue a system message in a module's message queue that will stop it. This is useful to avoid stopping a module right away (like module_stop()), instead waiting for it to receive other enqueued pubsub messages
  • module_dump() will dump various informations about a module using module_log(), eg: its fds, its subscriptions...
  • module_load() will runtime link an externally compiled module
  • module_unload() will unload a module previously loaded

New Features

  • Added regex topic subscriptions support
  • Added 2 new system messages: MODULE_STARTED/STOPPED
  • System messages will now have valued sender whenever possible
  • Avoid telling system messages like MODULE_STARTED to module which generated these messages
  • A default (weak symbol) main() that just runs modules_ctx_loop() on any found ctx is now provided by libmodule
  • Automatically stop looping on context when there are no RUNNING modules in it

API breaks

  • module_tell()/module_publish()/module_broadcast() take an additional parameter: bool autofree -> whether to automatically free message data after last recipient receives it
  • Avoid strdupping module's name and ctx's name
  • module_subscribe()/module_unsubscribe() now avoids checking if topic is registered in context
  • module_register_topic()/module_deregister_topic() have been dropped
  • pubsub interface now takes const void* instead of const unsigned char* as data
  • Added a new parameter to module_broadcast(): bool global. It will broadcast a message to every module in every context
  • Renamed pubsub_msg field to ps_msg inside msg_t
  • Renamed pubsub_msg_t type to ps_msg_t
  • Topic is no more strdupped when publishing/broadcasting a message
  • Renamed MODULE_DEFAULT_CTX and MODULE_MODULE_MAX_EVENTS to MODULES_*
  • Actually call init() callback only first time module is started, even without passing from evaluate_module (thus when started explicitly through module_start())
  • module_get_name()/module_get_ctx() return a strdup string
  • Renamed modules_set_memalloc_hook() to modules_set_memhook()
  • Renamed memalloc_hook to memhook_t
  • Renamed userhook to userhook_t
  • Avoid exposing in modules.h main() and modules_pre_start() functions: they're not part of libmodule's API and cannot be called as functions

Fixes

  • When stop looping on a context, flush all pubsub messages to RUNNING modules only. Destroy messages for non-running modules
  • When deregistering, remove module from context before stopping it

Map

Map API has undergone a full rewrite, and it is now based on work by David Leeds: https://github.com/DavidLeeds/hashmap. (thanks!)
Moreover, it is now properly tested too, with a stress test that will insert 1000000 keys and iterate on them.

New APIs

  • Added map_itr_t type and its functions: map_itr_new(), map_itr_next(), map_itr_get_key(), map_itr_get_data(), map_itr_set_data(), map_itr_remove()

API breaks

  • map_new() takes 2 new parameters whether to duplicate key, and a dtor function for values
  • Dropped map_set_dtor()
  • map_put takes 2 parameters less: bool dupkey and bool autofree value

Fixes

  • Avoid incrementing map size on value update
  • Destroy old value upon val update, if any dtor is set

Stack

New APIs

  • Added stack_itr_t type and its functions: stack_itr_new(), stack_itr_next(), stack_itr_get_data(), stack_itr_set_data()

API breaks

  • stack_new() takes a new parameter: bool autofree
  • stack_set_dtor() has been dropped

Queue

Libmodule now offers a queue implementation, in <module/queue.h>.
It is very similar to stack API.

Obviously documentation, tests and examples were all updated accordingly.
Happy developing!

v4.2.0

16 Jun 09:42
Compare
Choose a tag to compare

Here's a new release for libmodule.
While API is not changed, minor version was bumped because there was a behavioural change.

New Behaviour

  • Modules are now registered only as soon as program starts (they're not started right away).
    They're then started as soon as their context starts looping.
    This is a much more correct behaviour.

Bugfixes

  • Fixed default values for pubsub_fd[] for each module

v4.1.0

17 Mar 10:05
Compare
Choose a tag to compare

Hi there!
Here is another libmodule release, with some new features and a couple of bugfixes.

Please note that libmodule switched to MIT license in a strive to gain some more interest!

New features:

  • Cpack DEB and RPM support in Cmake: you can now create deb/rpm pkgs instead of "make install"; thus libmodule will be installed as a system package, and will be much more easily trackable
  • Libmodule can now be built as static library, by setting STATIC_MODULE to true in cmake

New API:

  • modules_ctx_get_fd() to retrieve a pollable fd for a given context
  • modules_ctx_dispatch() to dispatch messages in a non-blocking way for a given context

This two new API let developers integrate libmodule into their own loop.

Fixes:

  • Avoid unsetting dtor in map/stack_clear functions
  • module_unbecome now properly returns MOD_OK if stack is not empty (and thus it was able to pop recv)

Tests:

  • Added module_unbecome() and modules_ctx_dispatch() tests
  • Added CI builds and tests on fedora and ubuntu too

Samples:

  • Added a new "Poll" sample, that is equal to Easy sample, but integrates libmodule's loop inside a poll loop.

v4.0.0

26 Jan 09:57
Compare
Choose a tag to compare

Here is a new libmodule release.
This release breaks API thus the version bump.

Highlights:

New APIs

  • module_get_ref should now be used to take another module reference. All Actor-like API has been changed to make use of module references. A module reference is a self_t object that is marked as reference, and thus it cannot be used to pretend being another module.
  • stack_clear to completely reset a stack_t object.
  • stack_set_dtor to set a dtor function to be called on each element marked with autofree upon deletion.
  • map_clear to completely reset a map_t object.
  • map_set_dtor to set a dtor function to be called on each element marked with autofree upon deletion.

API breaks

  • module_tell now takes a self_t as second parameter; this leads to better performance too as no more hasmap lookups must be done for each module_tell.
  • map_put now takes an additional "autofree" parameter, to mark data to be autofreed by map API (upon map_clear or map_free.

Fixes

  • You cannot use another module "self_t" as obtained by pubsub msg sender to impersonate it.
  • module_register now avoids memleaks when it fails with NOMEM.
  • Fixed an issue in map_new if m->data calloc fails: map object was not memsetted to 0 thus leading to a crash when map_free was called.
  • Actually honor current module's callback when flushing pubsub messages.

Generic

  • More tests have been added, making libmodule more robust.
  • Code has been refactored and it is now more easy to read.
  • Doc has been obviously updated.

v3.2.0

15 Dec 09:36
cfa6caf
Compare
Choose a tag to compare

A new libmodule release is here!
This release add a stack implementation that is used inside libmodule for module_become/unbecome functions.

New Features:

  • Actually implement a stack for module_become/unbecome
  • Expose stack through a stack.h public header
  • Added tests for stack implementation
  • Added doc for stack implementation

Bugfixes:

  • Properly always check write/read return code

v3.1.1

23 Nov 16:37
Compare
Choose a tag to compare

New bugfix release for libmodule 3.1 is out.

Highlights:

  • performance improvements, by highly reducing hashmap lookups.
  • Added new MOD_NO_MEM and MOD_WRONG_PARAM error codes
  • Added new MAP_WRONG_PARAM error codes for map.h API
  • Switch CI to builds.sr.ht

v3.1.0

15 Nov 19:04
Compare
Choose a tag to compare

A new libmodule release is here. Lots of small fixes, and some improvements.

Fixes

  • Updated CMakeLists to build on older (supported) cmake
  • Call destroy() callback after module has been destroyed; this way no other libmodule function can be called with that self_t handler
  • modules_loop received support for EINTR/EAGAIN errors
  • pkg-config CFLAGS will now use CMAKE_INSTALL_INCLUDEDIR
  • dropped _GNU_SOURCE define
  • Avoid MOD_ASSERT macro spamming in release mode

Improvements

  • Internal libmodule hashmap api is now public, available in module/map.h
  • Added support for libkqueue for non-Linux-platforms where kqueue is not provided by libc

v3.0.1

02 Nov 11:16
Compare
Choose a tag to compare

Bugfix release for libmodule:

  • module_deregister_fd() will now gracefully remove the fd from epoll. Note that a close() is enough to remove it from epoll, but if autoclose is false, it won't be closed. Thus we need to assure to remove it from epoll.
  • When deregistering a module, actually stop it even if it was already stopped, to free/close any registered fd while it was stopped.
  • PAUSED module have to be delivered PubSub messages, but they will only receive them as soon as they get resumed (thus RUNNING state).
  • module_stop() can be called on PAUSED module too (and not IDLE as before!)
  • Set FD_CLOEXEC flag in non-linux poll implementation for both pipe and kqueue
  • Fixed CMakeLists to runt tests even if valgrind could not be found
  • Special handling of STDIN_FILENO in poll_set_new_evt for epoll/kqueue

v3.0.0

01 Nov 10:45
Compare
Choose a tag to compare

New libmodule release; highlights:

New Features

  • You can now send any data through libmodule pubsub api
  • Avoid strdupping /mallocing data sent through pubsub api, trusting user pointers

Api breaks

  • module_register_fd() now takes an autoclose boolean parameter; set it to true if you wish the fd to be closed at module stop or at fd deregistration.
  • module_register_fd() now takes an userptr, that will be forwarded in receive() callback through msg->fd_msg->userptr.
  • module_deregister_fd() does not take a "close" parameter anymore
  • modules_quit() now takes an "exit_code" parameter. Its value will be returned by modules_loop.
  • Dropped module_update_fd() function
  • Dropped module_add_fd() alias function (it was aliasing module_register_fd())
  • Dropped module_rm_fd() alias function (it was aliasing module_deregister_fd())

Generic improvements

  • Install license file in /usr/share/licenses/libmodule/
  • Added 2 more headers: <module/module_easy.h> and <module/modules_easy.h>
  • constify as much as possible
  • MODULE ctor now has a lower priority; this way a developer can calls its own ctors before
  • Use stdbool where needed

Fixes

  • Always use memhook!
  • Fixed memleak in hashmap_rehash() internal function
  • Avoid stopping an already-stopped module when deregistering a module