20 Commits

Author SHA1 Message Date
Justin Maggard
347aafa6d7 Fix some build warnings when building with musl 2020-11-18 14:45:11 -08:00
Gleb Smirnoff
5e320f2798 Add monitoring support via kqueue(2). Based on patch from FreeBSD ports, authored by wg@FreeBSD.org and se@FreeBSD.org. However, this version doesn't create any thread, it uses main event dispatcher.
Some effort was made to unify monitoring via kqueue and via inotify
APIs. Now both provide their implementation of add_watch() function.

I guess there are some logical bugs in vnode_process(). With this commit
it would be better provide code as is, and resolve bugs separately.
2018-01-16 17:01:43 -08:00
Gleb Smirnoff
7ba9e52fc8 Add kqueue event module. Code inspired by nginx. There are a lot of room for optimization here, this is just first working version. 2018-01-16 16:55:23 -08:00
Gleb Smirnoff
f9a78d598e Support for pluggable event modules, stage 1. Take out select() loop and associated code into a separate module select.c. Detailed list of changes down below.
The idea is taken from the nginx web server, but much simplified and
almost no copypaste left. This will allow minidlna to use different
event dispatcher APIs, which would be defined at compile time.

My personal goal is to convert minidlna to kqueue(2) on FreeBSD. This
would later allow for kqueue based directory change notification, which
won't conflict with select(2) like the current patch does.
Other platforms will also benefit from the pluggability of the event
system, Linux can switch to epoll(2) or at least to poll(2).

Detailed list of changes:

* event.h [New]
  Our internal API to unify different event dispatch systems.
* select.c [New]
  Much simplified version of nginx's ngx_select_module.c.
* minidlna.c
  - Split out listen socket event processing into separate function
    ProcessListen(), which matches event_process_t type.
  - Create and initialize struct event for the monitor socket, SSDP
    socket, HTTP socket and beacon socket.
  - Simplify and make more precise timeout calculation using
    helper timeval functions from utils.c. Treat gettimeofday() error
    as a fatal event.
  - Rip out all stuff related to select(2). Just call event_module.process().
* upnpevents.c
  - Embed struct event into upnp_event_notify.
  - Merge upnp_event_create_notify() with upnp_event_notify_connect().
    Start connecting immediately after socket creation. Garbage collect
    now useless ECreated state.
  - Make upnp_event_process_notify() of event_process_t type, and use it
    as process callback for upnp_event_notify event.
  - Looks like we always create upnp_event_notify with existing subscriber,
    and never clear it later. Remove checks for obj->sub and assert that it
    is never NULL. Simplifies things.
  - When switching obj state, add/del it to event dispatcher accrodingly.
  - Garbage collect upnpevents_selectfds().
  - Garbage collect select(2) related stuff from upnpevents_processfds().
    Rename function to upnpevents_gc(), since the remaining functionality
    is garbage collecting, not file descriptor processing.
    Actually, this can be simplified even more. We can safely close sockets
    and free objects immediately, eliminating need for upnpevents_gc(). But
    this change would be beyond scope of this commit.
* upnphttp.c, upnphttp.h
  Embed struct event into struct upnphttp. Adjust Process_upnphttp() to match
  event_process_t type. Add/del to event dispatcher once creating/closing a
  socket.
* minissdp.c, minissdp.h
  Make ProcessSSDPRequest() of event_process_t type.
* getifaddr.c, getifaddr.h
  Make ProcessMonitorEvent() of event_process_t type.
2018-01-16 16:53:08 -08:00
Justin Maggard
49aa42d893 scanner: Add non-destructive update rescan
New functionality, based on Shrimpkin's patch #145 on SF.
2017-05-04 23:29:59 -07:00
Justin Maggard
da7d868c4b build: Fix up some conditional code
Avahi and Ogg/Vorbis library conditional enablement wasn't working as
intended.
2017-05-01 15:04:44 -07:00
Justin Maggard
0575299a87 tivo: Add Avahi support
TiVo Bolt doesn't support the old TiVo Beacon discovery mechanism, so
we need to support Bonjour discovery now.  Use Avahi if it's available.
2017-04-28 01:18:53 -07:00
Justin Maggard
8029921884 containers: add magic container infrastructure
Add support for dynamic containers, with enough flexibility to also
replace our existing container ID replacement functionality.
2014-07-01 17:08:18 -07:00
Justin Maggard
b9404d1847 cleanup: remove unused tagutils code, and switch to standard int types 2014-03-06 17:08:21 -08:00
Justin Maggard
9312583101 Clarify license terms on new files. 2013-11-01 18:05:31 -07:00
Justin Maggard
622b0b7411 Merge branch 'for-justin' of git://github.com/BenoitKnecht/minidlna 2013-11-01 17:57:00 -07:00
Justin Maggard
0cc4fd980d Generate the generic Linux init script with the configured sbin path. 2013-11-01 17:44:41 -07:00
Benoît Knecht
3995cbdac4 Limit the number of simultanious children
Make sure minidlna cannot fork more than 5 children, to avoid becoming a
fork bomb.

Reported-by: Rinat Ibragimov <ibragimovrinat@mail.ru>
2013-06-20 19:31:34 +02:00
Justin Maggard
1c748c1d5a * Consolidate client detection code.
* Add forced sorting support for Panasonic devices.
2013-03-18 05:37:46 +00:00
Justin Maggard
bc33a34331 * Applying various OpenBSD-related changes. (Thanks SF user sthen23934) 2013-03-13 07:44:54 +00:00
Justin Maggard
de15926f76 * Rename minidlna to minidlnad, and install it in /usr/sbin like a proper system daemon. 2012-10-04 21:03:41 +00:00
Justin Maggard
61fbce18ba * Replace sqlite_int64 with int64_t in many places, to better allow for the possibility of other databases. (Thanks Douglas Carmichael) 2012-06-29 23:14:27 +00:00
Justin Maggard
2c7a3bfc06 * Add support for the latest ffmpeg/libav library versions. 2012-06-29 21:06:23 +00:00
Justin Maggard
d42f8fc193 * Fix configure issues with (at least) OSX and Fedora + RPM Fusion. 2011-11-10 06:56:02 +00:00
Justin Maggard
773e1f6566 * Add support for other operating systems (kFreeBSD, FreeBSD, and OSX for now).
* Switch to autoconf from genconfig.sh.
2011-09-16 23:39:58 +00:00