Skip to content

Commit deebffc

Browse files
committed
Updated PKGBUILD and Cpack with new license.
Avoid waiting undefinitely in modules_dispatch if no POLLIN data is available.
1 parent 0a18c88 commit deebffc

File tree

7 files changed

+26
-37
lines changed

7 files changed

+26
-37
lines changed

CMakeLists.txt

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -fvisibility=hidden")
120120
# Packaging support
121121
# THANKS to libkqueue CMakeLists.txt for packaging support :)
122122
#
123+
SET(CPACK_SET_DESTDIR "on")
123124
set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
124125
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
125126
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
@@ -129,38 +130,24 @@ set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
129130
#
130131
# Metadata common to all packaging systems
131132
#
133+
set(CPACK_PACKAGE_CONTACT "Federico Di Pierro <[email protected]>")
134+
set(CPACK_PACKAGE_DESCRIPTION "Libmodule offers a small and simple implementation of an actor library, aiming at letting developers easily create modular C projects in a way which is both simple and elegant.")
132135
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Small and simple implementation of an actor library for C.")
133-
set(CPACK_COMPONENT_MAIN_DESCRIPTION "Libmodule offers a small and simple implementation of an actor library, aiming at letting developers easily create modular C projects in a way which is both simple and elegant.")
134-
set(CPACK_COMPONENT_DEVEL_DESCRIPTION "Development files for ${PROJECT_NAME}-${PROJECT_VERSION}")
135136

136137
#
137138
# RPM Specific configuration
138139
#
139-
set(CPACK_RPM_PACKAGE_LICENSE "GPL-3.0")
140+
set(CPACK_RPM_PACKAGE_LICENSE "MIT")
140141
set(CPACK_RPM_PACKAGE_URL "https://github.com/FedeDP/libmodule")
141-
142-
set(CPACK_RPM_MAIN_PACKAGE_GROUP "System Environment/Libraries")
143-
set(CPACK_RPM_MAIN_PACKAGE_DESCRIPTION ${CPACK_COMPONENT_MAIN_DESCRIPTION})
144-
145-
set(CPACK_RPM_DEVEL_PACKAGE_GROUP "Development/Libraries")
146-
set(CPACK_RPM_DEVEL_PACKAGE_SUMMARY ${CPACK_COMPONENT_DEVEL_DESCRIPTION})
147-
set(CPACK_RPM_DEVEL_PACKAGE_REQUIRES "${CPACK_PACKAGE_NAME} = %{version}-%{release}")
148-
149-
set(CPACK_RPM_COMPONENT_INSTALL OFF) # Enable component based packaging (generate multiple packages)
150-
set(CPACK_RPM_FILE_NAME RPM-DEFAULT) # Use rpmbuild's package naming scheme
142+
set(CPACK_RPM_PACKAGE_GROUP "System Environment/Libraries")
143+
set(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION})
144+
set(CPACK_RPM_FILE_NAME RPM-DEFAULT)
151145

152146
#
153147
# DEB Specific configuration
154148
#
155-
set(CPACK_DEBIAN_MAIN_PACKAGE_NAME "${CPACK_PACKAGE_NAME}")
156-
set(CPACK_DEBIAN_MAIN_PACKAGE_SECTION "libs")
157-
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Federico Di Pierro <[email protected]>")
158-
159-
set(CPACK_DEBIAN_DEVEL_PACKAGE_NAME "${CPACK_PACKAGE_NAME}-dev")
160-
set(CPACK_DEBIAN_DEVEL_PACKAGE_SECTION "libdevel")
161-
set(CPACK_DEBIAN_DEVEL_PACKAGE_DEPENDS "${CPACK_PACKAGE_NAME} (= ${PROJECT_VERSION})")
162-
163-
set(CPACK_DEB_COMPONENT_INSTALL OFF) # Enable component based packaging (generate multiple packages)
164-
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT) # Use default Debian package naming scheme
149+
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/FedeDP/libmodule")
150+
set(CPACK_DEBIAN_PACKAGE_SECTION "libs")
151+
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
165152

166153
include(CPack)

Extra/Arch/PKGBUILD

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ pkgname=libmodule
44
pkgver=3.2.0
55
pkgrel=1
66
pkgdesc="C linux library to build simple and modular projects"
7-
arch=(x86_64)
7+
arch=(any)
88
url="https://github.com/FedeDP/${pkgname}"
9-
license=(GPL)
9+
license=(MIT)
1010
depends=()
1111
makedepends=(git cmake)
1212
source=("${pkgname}-${pkgver}.tar.gz::${url}/archive/${pkgver}.tar.gz")

Lib/modules.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ static _ctor1_ void modules_init(void);
55
static _dtor0_ void modules_destroy(void);
66
static void evaluate_new_state(m_context *c);
77
static module_ret_code loop_start(m_context *c, const int max_events);
8-
static int recv_events(m_context *c);
8+
static int recv_events(m_context *c, int timeout);
99
static int loop_stop(m_context *c);
1010

1111
map_t *ctx;
@@ -39,8 +39,8 @@ static module_ret_code loop_start(m_context *c, const int max_events) {
3939
return MOD_ERR;
4040
}
4141

42-
static int recv_events(m_context *c) {
43-
int nfds = poll_wait(c->fd, c->max_events, c->pevents);
42+
static int recv_events(m_context *c, int timeout) {
43+
int nfds = poll_wait(c->fd, c->max_events, c->pevents, timeout);
4444
for (int i = 0; i < nfds; i++) {
4545
module_poll_t *p = poll_recv(i, c->pevents);
4646
if (p && p->self && p->self->mod) {
@@ -140,7 +140,7 @@ module_ret_code modules_ctx_loop_events(const char *ctx_name, const int max_even
140140

141141
if (loop_start(c, max_events) == MOD_OK) {
142142
while (!c->quit) {
143-
recv_events(c);
143+
recv_events(c, -1);
144144
}
145145
return loop_stop(c);
146146
}
@@ -184,7 +184,7 @@ module_ret_code modules_ctx_dispatch(const char *ctx_name, int *ret) {
184184
return MOD_ERR;
185185
}
186186

187-
/* Recv new events */
188-
*ret = recv_events(c);
187+
/* Recv new events, no timeout */
188+
*ret = recv_events(c, 0);
189189
return *ret >= 0 ? MOD_OK : MOD_ERR;
190190
}

Lib/poll_plugins/epoll_priv.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ int poll_init_pevents(void **pevents, int max_events) {
3030
return MOD_OK;
3131
}
3232

33-
int poll_wait(int fd, int max_events, void *pevents) {
34-
return epoll_wait(fd, (struct epoll_event *) pevents, max_events, -1);
33+
int poll_wait(int fd, int max_events, void *pevents, int timeout) {
34+
return epoll_wait(fd, (struct epoll_event *) pevents, max_events, timeout);
3535
}
3636

3737
module_poll_t *poll_recv(int idx, void *pevents) {

Lib/poll_plugins/kqueue_priv.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ int poll_init_pevents(void **pevents, int max_events) {
3333
return MOD_OK;
3434
}
3535

36-
int poll_wait(int fd, int max_events, void *pevents) {
37-
return kevent(fd, NULL, 0, (struct kevent *)pevents, max_events, NULL);
36+
int poll_wait(int fd, int max_events, void *pevents, int timeout) {
37+
struct timespec t = {0};
38+
t.tv_sec = timeout;
39+
return kevent(fd, NULL, 0, (struct kevent *)pevents, max_events, timeout >= 0 ? &t : NULL);
3840
}
3941

4042
module_poll_t *poll_recv(int idx, void *pevents) {

Lib/poll_priv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ int poll_create(void);
1212
int poll_set_data(void **_ev);
1313
int poll_set_new_evt(module_poll_t *tmp, m_context *c, enum op_type flag);
1414
int poll_init_pevents(void **pevents, int max_events);
15-
int poll_wait(int fd, int max_events, void *pevents);
15+
int poll_wait(int fd, int max_events, void *pevents, int timeout);
1616
module_poll_t *poll_recv(int idx, void *pevents);
1717
int poll_destroy_pevents(void **pevents, int *max_events);
1818
int poll_close(int fd, void **pevents, int *max_events);

TODO.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
- [x] modules_get_fd(const char *ctx)
66
- [x] modules_dispatch(ctx)
77
- [x] Update Doc
8-
- [ ] Add tests?
8+
- [x] Avoid waiting undefinitely when calling modules_dispatch if no POLLIN data is ready
99

1010
### Fixes
1111
- [x] In stack_clear and map_clear, avoid unsetting dtor

0 commit comments

Comments
 (0)