Files
libcoap/man/Makefile.am
T
Jon Shallow 0e02d751da Add in internal epoll support to expose a monitor-able file descriptor
If epoll is available, use it within libcoap to speed things up, as well as
present to applications a file descriptor that can be used in a select() or
returned as an event in a epoll_wait() call.

Whenever coap_new_context() is called. set up a new epoll infrastructure with
epoll_create() and destroy it with coap_free_context().

For each new endpoint or session, add the socket fd to epoll.  When the socket
is closed, remove the socket fd from epoll.

Whenever a socket wants a write, the appropriate epoll event gets EPOLLOUT
added and when the write happens reset the event back to just EPOLLIN.

As there may be a packet retry event sometime in the future, a timerfd is
created and added to the epoll structure (done in coap_new_context) which gets
freed off in coap_free_context. If coap_run_once() determines that there is
a future retry, timerfd is informed of when the event is to occur.  When
timerfd times out, the application file descriptor will indicate a read is
available.

A new function coap_context_get_coap_fd(ctx) returns the application file
descriptor.  The only other API change is that if wait_ms is set to 1 for
coap_run_once(ctx, wait_ms), there is no waiting for a new packet to arrive.

coap_run_once() is called, whether epoll support is available or not, to
process all the underlying required i/o.

If there is no epoll support, coap_run_once() continues to use the old
select() method, otherwise it will use epoll_wait(). If there is epoll
support, a modified version of coap_read() (coap_io_do_events()) is
used instead.

Makefile.am:

Do not expose coap_epoll_ctl_mod() and coap_io_do_events() to applications.

configure.ac:

Test for the presence of sys/epoll.h and sys/timerfd.h and if so setup
COAP_EPOLL_SUPPORT to be used for #ifdef testing.
Include new man page coap_io.txt.

examples/coap-server.c:

Include support for using this new exposed file descriptor.

include/coap2/coap_io.h:

Define COAP_MAX_EPOLL_EVENTS (to limit the number of events processed at once)
and include coap_endpoint_t and coap_session_t in coap_socket_t.
Include (internal) definition for coap_epoll_ctl_mod()

include/coap2/net.h:

Add epfd and eptimerfd to coap_context_t.
Define coap_context_get_coap_fd() for applications to use.
Include (internal) definition for coap_io_do_events().
Define COAP_RUN_BLOCK and COAP_RUN_NONBLOCK.

libcoap-2.map:
libcoap-2.sym:

Include coap_context_get_coap_fd.

configure.ac:
man/Makefile.am:
man/coap.txt.in:
man/coap_io.txt.in: (New)

Include the new coap_in(3) man page that documents coap_run_once() and
coap_context_get_coap_fd().

src/coap_io.c:
src/coap_openssl.c:
src/coap_session.c:
src/net.c:

Add in the epoll support.

src/net.c:

Add in coap_context_get_coap_fd() function.
2019-08-30 11:51:15 +01:00

101 lines
3.0 KiB
Makefile

# man/Makefile.am
#
# Copyright (C) 2018 Jon Shallow <supjps-libcoap@jpshallow.com>
#
# This file is part of the CoAP C library libcoap. Please see README and
# COPYING for terms of use.
# build manuals only if 'BUILD_MANPAGES' is defined
if BUILD_MANPAGES
# building the manpages
TXT3 = coap_attribute.txt \
coap_context.txt \
coap_encryption.txt \
coap_handler.txt \
coap_io.txt \
coap_keepalive.txt \
coap_logging.txt \
coap_observe.txt \
coap_pdu_setup.txt \
coap_recovery.txt \
coap_resource.txt \
coap_session.txt \
coap_tls_library.txt
MAN3 = $(TXT3:%.txt=%.3)
man3_MANS = $(MAN3)
TXT5 = coap-client.txt \
coap-rd.txt \
coap-server.txt
MAN5 = $(TXT5:%.txt=%.5)
man5_MANS = $(MAN5)
TXT7 = coap.txt
MAN7 = $(TXT7:%.txt=%.7)
man7_MANS = $(MAN7)
.txt.3:
$(A2X) --doctype manpage --format manpage $<
$(A2X) --doctype manpage --format xhtml $<
.txt.5:
$(A2X) --doctype manpage --format manpage $<
$(A2X) --doctype manpage --format xhtml $<
.txt.7:
$(A2X) --doctype manpage --format manpage $<
$(A2X) --doctype manpage --format xhtml $<
# Man pages built byt a2x based on the NAMES section of the .txt file
A2X_EXTRA_PAGES = @DOLLAR_SIGN@(shell for fil in $(TXT3) ; do sed -ne '/^NAME/,/^SYNOPSIS/p;/^SYNOPSIS/q' $${fil} | \
sed -ne '/coap_/{ s/ *, */\n/g; p }' | sed -ne 's/^\(coap_[a-zA-Z_]\+\).*$$/\1.3/p' ; done)
# Extra man pages that need to be installed due to limit of 10
# names built by a2x
# These files are created in install-man
EXTRA_PAGES = \
coap_context_set_pki_root_cas.3 \
coap_add_data_blocked_response.3 \
coap_encode_var_bytes.3 \
coap_split_path.3 \
coap_split_query.3 \
coap_session_get_app_data.3 \
coap_session_set_app_data.3 \
coap_endpoint_str.3
# a2x builds alternative .3 files up to a limit of 10 names from the
# NAME section, so that 'man' works against the alternative different
# function names.
# However, if there are more alternative names, they need to be defined
# as per below.
# Then all the alternative names as well as the extras defined below need
# to be cleaned up in a 'make unistall'.
install-man: install-man3 install-man5 install-man7
@echo ".so man3/coap_context.3" > coap_context_set_pki_root_cas.3
@echo ".so man3/coap_pdu_setup.3" > coap_add_data_blocked_response.3
@echo ".so man3/coap_pdu_setup.3" > coap_encode_var_bytes.3
@echo ".so man3/coap_pdu_setup.3" > coap_split_path.3
@echo ".so man3/coap_pdu_setup.3" > coap_split_query.3
@echo ".so man3/coap_session.3" > coap_session_get_app_data.3
@echo ".so man3/coap_session.3" > coap_session_set_app_data.3
@echo ".so man3/coap_logging.3" > coap_endpoint_str.3
@echo ".so man3/coap_logging.3" > coap_session_str.3
$(INSTALL_DATA) $(EXTRA_PAGES) $(A2X_EXTRA_PAGES) "$(DESTDIR)$(man3dir)"
# As well as removing the base 'man' pages, remove other .3 files built by
# a2x, as well as build by install-man specials.
uninstall-man: uninstall-man3 uninstall-man5 uninstall-man7
-(cd $(DESTDIR)$(man3dir) ; rm -f $(EXTRA_PAGES) $(A2X_EXTRA_PAGES) )
CLEANFILES = *.3 *.5 *.7 *.xml *.html docbook-xsl.css
endif # BUILD_MANPAGES