mirror of
https://github.com/graygnuorg/pound.git
synced 2026-10-25 10:19:36 +03:00
The timer thread is rewritten completely in order to do periodic operations (such as backend probing and session expiration) precisely when needed and lower the incurred CPU usage. Timer thread now supports scheduling of arbitrary periodic jobs and schedule editing. Whenever a backend is marked as dead, a periodic job is scheduled for "alive_to" seconds from the current time, which will probe the backend and either mark it as alive (if it responds) or reschedule itself for a later time (if it does not). Thus, no unnecessary iterations over listeners/servers/backends occur. The "haport" feature has been removed, as I see no much use in it now. Sessions are kept on per-service basis in a combined structure consisting of a hash table (to quickly look-up a session) and a doubly-linked list (to provide for session expiration). Sessions within the latter are sorted by their expiration time. A periodic job is scheduled to the expiration time of the first session in the list, i.e. the least recently used one. When the job has removed the expired session, it reschedules itself to the expiration time of the next session (which becomes first in the list), if any. * src/list.h: Bugfixes. * src/pound.h (struct session): Replace last access time with expiration time (struct timespec). (EXPIRE_TO, HOST_TO): Remove. (job_enqueue_unlocked, job_enqueue_after_unlocked) (job_enqueue, job_enqueue_after) (job_rearm_unlocked,job_rearm): New protos. (BACKEND): New field: service. Remove field: resurrect, ha_addr. * src/svc.c: Revamp session support. Remove do_expire. Sessions are stored in per-service session tables and are ordered by their expiration time. The expire_sessions periodic job is scheduled to the expiration time of the first session in the list, i.e. the least recently used one. (touch_be): New function. (kill_be): Enqueue the touch_be job if the backend went offline. (do_resurrect): Remove. (job_head, job_mutex, job_cond): New static. (job_enqueue_unlocked, job_enqueue_after_unlocked) (job_enqueue, job_enqueue_after): New functions. (thr_timer): Rewrite. * src/config.c (parse_service): Set pointer to the owner service for each backend. * tests/config.at: Remove the haport check.