v0.4.0: ipc_wait_event* functions now receive a timeout value
parent
c879d49c31
commit
ef2c05fc25
24
Makefile
24
Makefile
|
@ -1,5 +1,5 @@
|
||||||
PACKAGE = 'ipc'
|
PACKAGE = 'ipc'
|
||||||
VERSION = '0.1.0'
|
VERSION = '0.4.0'
|
||||||
|
|
||||||
PREFIX := /usr/local
|
PREFIX := /usr/local
|
||||||
BINDIR := $(PREFIX)/bin
|
BINDIR := $(PREFIX)/bin
|
||||||
|
@ -62,25 +62,25 @@ libipc.so: src/communication.o src/error.o src/logger.o src/message.o src/networ
|
||||||
$(Q)$(CC) -o libipc.so -shared $(LDFLAGS) src/communication.o src/error.o src/logger.o src/message.o src/network.o src/usocket.o src/utils.o
|
$(Q)$(CC) -o libipc.so -shared $(LDFLAGS) src/communication.o src/error.o src/logger.o src/message.o src/network.o src/usocket.o src/utils.o
|
||||||
|
|
||||||
libipc.so.install: libipc.so
|
libipc.so.install: libipc.so
|
||||||
@echo '[01;31m IN > [01;37m$(LIBDIR)/libipc.so.0.1.0[00m'
|
@echo '[01;31m IN > [01;37m$(LIBDIR)/libipc.so.0.4.0[00m'
|
||||||
$(Q)mkdir -p '$(DESTDIR)$(LIBDIR)'
|
$(Q)mkdir -p '$(DESTDIR)$(LIBDIR)'
|
||||||
$(Q)install -m0755 libipc.so $(DESTDIR)$(LIBDIR)/libipc.so.0.1.0
|
$(Q)install -m0755 libipc.so $(DESTDIR)$(LIBDIR)/libipc.so.0.4.0
|
||||||
@echo '[01;33m LN > [01;37m$(LIBDIR)/libipc.so.0.1[00m'
|
@echo '[01;33m LN > [01;37m$(LIBDIR)/libipc.so.0.4[00m'
|
||||||
$(Q)ln -sf '$(LIBDIR)/libipc.so.0.1.0' '$(DESTDIR)/$(LIBDIR)/libipc.so.0.1'
|
$(Q)ln -sf '$(LIBDIR)/libipc.so.0.4.0' '$(DESTDIR)/$(LIBDIR)/libipc.so.0.4'
|
||||||
@echo '[01;33m LN > [01;37m$(LIBDIR)/libipc.so.0[00m'
|
@echo '[01;33m LN > [01;37m$(LIBDIR)/libipc.so.0[00m'
|
||||||
$(Q)ln -sf '$(LIBDIR)/libipc.so.0.1.0' '$(DESTDIR)/$(LIBDIR)/libipc.so.0'
|
$(Q)ln -sf '$(LIBDIR)/libipc.so.0.4.0' '$(DESTDIR)/$(LIBDIR)/libipc.so.0'
|
||||||
@echo '[01;33m LN > [01;37m$(LIBDIR)/libipc.so[00m'
|
@echo '[01;33m LN > [01;37m$(LIBDIR)/libipc.so[00m'
|
||||||
$(Q)ln -sf '$(LIBDIR)/libipc.so.0.1.0' '$(DESTDIR)/$(LIBDIR)/libipc.so'
|
$(Q)ln -sf '$(LIBDIR)/libipc.so.0.4.0' '$(DESTDIR)/$(LIBDIR)/libipc.so'
|
||||||
|
|
||||||
libipc.so.clean:
|
libipc.so.clean:
|
||||||
@echo '[01;37m RM > [01;37mlibipc.so[00m'
|
@echo '[01;37m RM > [01;37mlibipc.so[00m'
|
||||||
$(Q)rm -f libipc.so
|
$(Q)rm -f libipc.so
|
||||||
|
|
||||||
libipc.so.uninstall:
|
libipc.so.uninstall:
|
||||||
@echo '[01;37m RM > [01;37m$(LIBDIR)/libipc.so.0.1.0[00m'
|
@echo '[01;37m RM > [01;37m$(LIBDIR)/libipc.so.0.4.0[00m'
|
||||||
$(Q)rm -f '$(DESTDIR)$(LIBDIR)/libipc.so.0.1.0'
|
$(Q)rm -f '$(DESTDIR)$(LIBDIR)/libipc.so.0.4.0'
|
||||||
@echo '[01;37m RM > [01;37m$(LIBDIR)/libipc.so.0.1[00m'
|
@echo '[01;37m RM > [01;37m$(LIBDIR)/libipc.so.0.4[00m'
|
||||||
$(Q)rm -f '$(DESTDIR)$(LIBDIR)/libipc.so.0.1'
|
$(Q)rm -f '$(DESTDIR)$(LIBDIR)/libipc.so.0.4'
|
||||||
@echo '[01;37m RM > [01;37m$(LIBDIR)/libipc.so.0[00m'
|
@echo '[01;37m RM > [01;37m$(LIBDIR)/libipc.so.0[00m'
|
||||||
$(Q)rm -f '$(DESTDIR)$(LIBDIR)/libipc.so.0'
|
$(Q)rm -f '$(DESTDIR)$(LIBDIR)/libipc.so.0'
|
||||||
@echo '[01;37m RM > [01;37m$(LIBDIR)/libipc.so[00m'
|
@echo '[01;37m RM > [01;37m$(LIBDIR)/libipc.so[00m'
|
||||||
|
@ -296,7 +296,7 @@ $(PACKAGE)-$(VERSION).tar.bz2: distdir
|
||||||
$(PACKAGE)-$(VERSION)/src/utils.h
|
$(PACKAGE)-$(VERSION)/src/utils.h
|
||||||
|
|
||||||
help:
|
help:
|
||||||
@echo '[01;37m :: ipc-0.1.0[00m'
|
@echo '[01;37m :: ipc-0.4.0[00m'
|
||||||
@echo ''
|
@echo ''
|
||||||
@echo '[01;37mGeneric targets:[00m'
|
@echo '[01;37mGeneric targets:[00m'
|
||||||
@echo '[00m - [01;32mhelp [37m Prints this help message.[00m'
|
@echo '[00m - [01;32mhelp [37m Prints this help message.[00m'
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
package=ipc
|
package=ipc
|
||||||
version=0.3.0
|
version=0.4.0
|
||||||
|
|
||||||
CFLAGS="-Wall -Wextra -g"
|
CFLAGS="-Wall -Wextra -g"
|
||||||
|
|
||||||
|
|
|
@ -381,7 +381,8 @@ enum ipc_errors handle_message (struct ipc_event *event
|
||||||
enum ipc_errors ipc_wait_event_networkd (struct ipc_connection_infos *cinfos
|
enum ipc_errors ipc_wait_event_networkd (struct ipc_connection_infos *cinfos
|
||||||
, struct ipc_connection_info *cinfo // NULL for clients
|
, struct ipc_connection_info *cinfo // NULL for clients
|
||||||
, struct ipc_event *event
|
, struct ipc_event *event
|
||||||
, struct ipc_switchings *switchdb)
|
, struct ipc_switchings *switchdb
|
||||||
|
, long *timer /** TODO: timers */)
|
||||||
{
|
{
|
||||||
T_R ((cinfos == NULL), IPC_ERROR_WAIT_EVENT__NO_CLIENTS_PARAM);
|
T_R ((cinfos == NULL), IPC_ERROR_WAIT_EVENT__NO_CLIENTS_PARAM);
|
||||||
T_R ((event == NULL), IPC_ERROR_WAIT_EVENT__NO_EVENT_PARAM);
|
T_R ((event == NULL), IPC_ERROR_WAIT_EVENT__NO_EVENT_PARAM);
|
||||||
|
@ -419,7 +420,24 @@ enum ipc_errors ipc_wait_event_networkd (struct ipc_connection_infos *cinfos
|
||||||
}
|
}
|
||||||
|
|
||||||
readf = master;
|
readf = master;
|
||||||
T_PERROR_R ((select(fdmax+1, &readf, NULL, NULL, NULL) == -1), "select", IPC_ERROR_WAIT_EVENT__SELECT);
|
|
||||||
|
struct timeval *ptimeout = NULL;
|
||||||
|
SECURE_DECLARATION (struct timeval, timeout);
|
||||||
|
|
||||||
|
if (timer != NULL && *timer > 0) {
|
||||||
|
timeout.tv_sec = *timer;
|
||||||
|
ptimeout = &timeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
T_PERROR_R ((select(fdmax+1, &readf, NULL, NULL, ptimeout) == -1), "select", IPC_ERROR_WAIT_EVENT__SELECT);
|
||||||
|
|
||||||
|
if (ptimeout != NULL) {
|
||||||
|
*timer = timeout.tv_sec;
|
||||||
|
if (*timer == 0) {
|
||||||
|
IPC_EVENT_SET(event, IPC_EVENT_TYPE_TIMER, NULL, NULL);
|
||||||
|
return IPC_ERROR_NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i <= (size_t) fdmax; i++) {
|
for (i = 0; i <= (size_t) fdmax; i++) {
|
||||||
if (FD_ISSET(i, &readf)) {
|
if (FD_ISSET(i, &readf)) {
|
||||||
|
@ -440,9 +458,10 @@ enum ipc_errors ipc_wait_event_networkd (struct ipc_connection_infos *cinfos
|
||||||
|
|
||||||
enum ipc_errors ipc_wait_event (struct ipc_connection_infos *cinfos
|
enum ipc_errors ipc_wait_event (struct ipc_connection_infos *cinfos
|
||||||
, struct ipc_connection_info *cinfo // NULL for clients
|
, struct ipc_connection_info *cinfo // NULL for clients
|
||||||
, struct ipc_event *event)
|
, struct ipc_event *event
|
||||||
|
, long *timer)
|
||||||
{
|
{
|
||||||
return ipc_wait_event_networkd (cinfos, cinfo, event, NULL);
|
return ipc_wait_event_networkd (cinfos, cinfo, event, NULL, timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// store and remove only pointers on allocated structures
|
// store and remove only pointers on allocated structures
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#define IPC_HEADER_SIZE 6
|
#define IPC_HEADER_SIZE 6
|
||||||
#define IPC_MAX_MESSAGE_SIZE 8000000-IPC_HEADER_SIZE
|
#define IPC_MAX_MESSAGE_SIZE 8000000-IPC_HEADER_SIZE
|
||||||
|
|
||||||
#define IPC_VERSION 3
|
#define IPC_VERSION 4
|
||||||
|
|
||||||
#if ! defined(IPC_WITHOUT_ERRORS) && ! defined(IPC_WITH_ERRORS)
|
#if ! defined(IPC_WITHOUT_ERRORS) && ! defined(IPC_WITH_ERRORS)
|
||||||
#define IPC_WITH_ERRORS 2
|
#define IPC_WITH_ERRORS 2
|
||||||
|
@ -123,6 +123,7 @@ enum ipc_event_type {
|
||||||
, IPC_EVENT_TYPE_DISCONNECTION = 5
|
, IPC_EVENT_TYPE_DISCONNECTION = 5
|
||||||
, IPC_EVENT_TYPE_MESSAGE = 6
|
, IPC_EVENT_TYPE_MESSAGE = 6
|
||||||
, IPC_EVENT_TYPE_LOOKUP = 7
|
, IPC_EVENT_TYPE_LOOKUP = 7
|
||||||
|
, IPC_EVENT_TYPE_TIMER = 8
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ipc_errors {
|
enum ipc_errors {
|
||||||
|
@ -310,7 +311,8 @@ enum ipc_errors ipc_write (const struct ipc_connection_info *, const struct ipc_
|
||||||
|
|
||||||
enum ipc_errors ipc_wait_event (struct ipc_connection_infos *clients
|
enum ipc_errors ipc_wait_event (struct ipc_connection_infos *clients
|
||||||
, struct ipc_connection_info *srv
|
, struct ipc_connection_info *srv
|
||||||
, struct ipc_event *event);
|
, struct ipc_event *event
|
||||||
|
, long *timer);
|
||||||
|
|
||||||
// store and remove only pointers on allocated structures
|
// store and remove only pointers on allocated structures
|
||||||
enum ipc_errors ipc_add (struct ipc_connection_infos *, struct ipc_connection_info *);
|
enum ipc_errors ipc_add (struct ipc_connection_infos *, struct ipc_connection_info *);
|
||||||
|
@ -390,7 +392,8 @@ struct networkd {
|
||||||
enum ipc_errors ipc_wait_event_networkd (struct ipc_connection_infos *cinfos
|
enum ipc_errors ipc_wait_event_networkd (struct ipc_connection_infos *cinfos
|
||||||
, struct ipc_connection_info *cinfo // NULL for clients
|
, struct ipc_connection_info *cinfo // NULL for clients
|
||||||
, struct ipc_event *event
|
, struct ipc_event *event
|
||||||
, struct ipc_switchings *switchdb);
|
, struct ipc_switchings *switchdb
|
||||||
|
, long *timer);
|
||||||
|
|
||||||
|
|
||||||
void ipc_switching_add (struct ipc_switchings *is, int orig, int dest);
|
void ipc_switching_add (struct ipc_switchings *is, int orig, int dest);
|
||||||
|
|
Reference in New Issue