summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd/queue.c
AgeCommit message (Collapse)Author
2015-10-16Implement real "flock" request and add it to userland programs thatTodd C. Miller
use pledge and file locking. OK deraadt@
2015-10-14whitespacesGilles Chehade
2015-10-13pledge() queue processGilles Chehade
ok deraadt@
2015-01-20use <limits.h> comprehensively. For now try to push <> includes toTheo de Raadt
each .c file, and out of the .h files. To avoid overinclude. ok gilles, in principle. If this has been done right, -portable should become easier to maintain.
2014-07-10make the control process broadcast verbose/profile admin requests directly,Eric Faurot
rather than going through the parent process. simplify code in the meantime.
2014-07-10Improve the scheduler, better and simpler.Eric Faurot
- Get rid of the scheduler_batch structure. The scheduler can now return envelopes of different types in a single run, interlacing them to avoid batch effects. - Ask for an acknowledgement from the queue when removing or expiring an envelope to benefit from the inflight envelope limitation mechanism. This ensures that the scheduler always keeps sending envelopes at a rate that the queue can sustain in all cases. - Limit the number of envelopes in a holdq. When a holdq is full, new envelopes are put back in the pending queue instead, with a shorter retry time. - Plumbing for proc-ified schedulers. imsg version bump. smtpctl stop before updating. ok gilles@
2014-07-08various queue improvements:Eric Faurot
- add a "close" hook to the backend API. - improve the sync() pattern in queue_fs: only sync at commit time and not for every envelope creation - various fixes to the experimental external queue API.
2014-04-19(void) cast strlcpy() and snprintf() that cannot truncateGilles Chehade
2014-04-08use correct imsgEric Faurot
ok gilles@
2014-04-04Merge the mda, mta and smtp processes into a single unprivilegedEric Faurot
process managing message reception, delivery and transfer. Mostly mechanical, but very intrusive as it required to rewamp all IMSG to fix ambiguities. with and ok gilles@
2014-02-04Add support for DSN and Enhanced Status CodeEric Faurot
2014-02-04internal improvements and cleanupsEric Faurot
- get rid of the whole penalty thing for failed envelopes in the mta and scheduler. - do not disable routes on smtp errors - try to schedule all types of envelopes on each scheduler frame.
2014-02-04get rid of fdlimit()Eric Faurot
2013-11-20Rework the mda and scheduler to use the holdq mechanism instead ofEric Faurot
tempfail for limiting the number of pending deliveries to the same user. This allows to reach optimal delivery time even in case of burst, while keeping the number of inflight envelopes low.
2013-10-27Implement a feedback mechanism which allows the mta to "hold" envelopesEric Faurot
in the scheduler when it has too many tasks for a given relay. The envelopes are put on a wait queue, and are not scheduled again until the mta "releases" some envelopes from that queue. It prevents from having too many inflight envelopes, which are out of reach for the admin.
2013-10-27Create the control socket in the parent process to abort early ifEric Faurot
another smtpd instance is running. Close the inherited socket in every forked process but control.
2013-07-19Many MTA improvements:Eric Faurot
- Better transient error handling logic: failing destinations are automatically disabled for a while. When a destination is active again, ask the scheduler to retry previous envelopes immediatly. - More informative error report when all routes fail for a mail. - Implement a "smtpctl show hoststats" command to get the latest stat message per MX domain. - Implement a "smtpctl show routes" command to show the state the currently known routes to remote MXs. - Implement a "smtpctl resume route" command to re-enable a route that has been disabled. - Do not hardcode limits - Minor code improvements
2013-07-19Assorted queue improvements:Eric Faurot
- cleanup the internal queue backend API and get rid of the QOP_* thing. - implement a queue_proc backend - rename queue_fsqueue.c to queue_fs - enable support for queue encryption - add an envelope cache - better logging and error reporting
2013-07-19scheduler improvements:Eric Faurot
- implement suspend/resume scheduling for individual envelopes or message, with the associated smtpctl commands. - allow the mta to request immediate scheduling of an envelope. - on temporary failures a penalty can be given to further delay the next try.
2013-07-19Get rid of env->sc_pw and env->sc_pwqueue. Early queue initializationEric Faurot
now happens in queue_init(), and backends take the queue passwd as parameter in their init function. Remove useless SMTPD_FILTER_USER while there.
2013-07-19Remove useless sc_pid from struct smtpd.Eric Faurot
2013-05-24sync with OpenSMTPD 5.3.2Eric Faurot
ok gilles@
2013-04-12replace MAX_LINE_SIZE and SMTP_LINE_MAX with SMTPD_MAXLINESIZE forEric Faurot
consistency and clarity. Remove useless and confusing extra byte in a few arrays based on this define. ok gilles@
2013-01-31do not need to tweak the socket sndbuf, now that the envelopes are passedEric Faurot
in compressed form. reduce the default size for envelope messages. ok gilles@
2013-01-26Sync with our smtpd repo:Gilles Chehade
* first bricks of ldap and sqlite support (not finished but both working) * new table API to replace map API, all lookups are done through tables * improved handling of temporary errors throughout the daemon * improved scheduler and mta logic: connection reuse, optimizes batches * improved queue: more tolerant to admin errors, new layout, less disk-IO * improved memory usage under high load * SSL certs/keys isolated to lookup process to avoid facing network * VIRTUAL support improved, fully virtual setups possible now * runtime tracing of processes through smtpctl trace * ssl_privsep.c sync-ed with relayd * ssl.c no longer contains smtpd specific interfaces * smtpd-specific ssl bits moved to ssl_smtpd.c * update mail address in copyright FLUSH YOUR QUEUE. FLUSH YOUR QUEUE. FLUSH YOUR QUEUE. FLUSH YOUR QUEUE. smtpd.conf(5) simplified, it will require adaptations ok eric@
2012-11-23Replace the qwalk API (to retreive on disk envelopes at runtime) withEric Faurot
a simple QOP_WALK queue operation. Some knf and formating fixes while there. ok gilles@
2012-11-20Allow "smtpctl show queue" to run in "online" mode if the smtpd serverEric Faurot
is running. The scheduler sends the runtime state of each envelope to the queue process which loads the envelope, fills the runtime bits and sends the envelope back to the client. Iteration over the envelope set happens in small chunks to make the request interruptible and to allow the server to keep doing its job in the meantime. Adpat "smtpctl schedule-all" to schedule the messages one by one using the same iteration mechanism. Document "smtpctl monitor" and "smtpctl show queue". ok gilles@
2012-11-13do not miss the last envelopeEric Faurot
ok gilles@
2012-11-12Cleanups and improvements:Eric Faurot
* Log more events (especially client session) and use a better scheme for that: each messages is prefixed with a token to easily identify its class: - info/warn/debug: general server messages - smtp-in: smtp client connections - relay: status update for relayed messages - delivery: status update for local deliveries * Implement "smtpctl monitor" to display updates of selected internal counters. * When reloading the on-disk queue at startup do not commit a message if no envelope was submitted for that message. * Remove unused stuff in the config parser. ok gilles@
2012-10-25Make the mda request the message fd from the queue when needed, instead ofEric Faurot
pushing the fd with the envelope. This allows the mda to deal itself with session limits. Envelopes are sent at full rate to the mda, which buffers them on per-user queues, or sends them back for rescheduling if it already has too many pending envelopes. Delivery sessions are created (within per- user and global limits) to drain the queues. This makes the server handle envelope bursts more efficiently. ok gilles@
2012-10-14When pushing too many envelopes to the mda at once, we can hit a filedescEric Faurot
exhaustion situation that kills the server. For now, put a safe limit on the number of envelopes sent by the queue process to the mda. ok gilles@ chl@
2012-10-14substitute wrong comas into semicolonsCharles Longeau
ok gilles@ eric@
2012-09-21Add a log_envelope() function that log envelope status in a uniform way.Eric Faurot
It automagically adds an rcpt=<user@domain> field if "dest" differs from the original "rcpt". The function takes an "extra" parameter that allows to add some specific info depending on the context. ok gilles@
2012-09-19Remove DF_ENQUEUE flag. It is mostly unused and logically broken.Eric Faurot
Ignore it in existing envelopes until it gets completely dropped. Change "smtpctl show queue" to display the address family of the envelope source instead of the ENQUEUE flag. ok gilles@
2012-09-16Factorize log_imsg() in imsg_dispatch() instead of in each imsg_callback()'sCharles Longeau
and put it out of profiling, so it's not accounted. While there, for PROC_PARENT: - set smtpd_process for PROC_PARENT - use setproctitle() like other processes ok gilles@
2012-09-10nasty typo.Eric Faurot
ok gilles@
2012-08-25- add myself to the copyright in control.c, i've done quite a few changesGilles Chehade
there in the last few years ;-) - get rid of availdesc(): getdtablecount() is so much more reliable - get rid of env->sc_maxconn, we can be much smarter with getdtablecount() and getdtablesize() - disable accept when we hit the control process fd reserve - disable accept when we fail - enable accept when we're back below the limit this is not the full fd exhaustion diff, i'll merge changes from relayd tomorrow, this was only required to get rid of the env->sc_maxconn and availdesc() mess "reads alright" eric@
2012-08-25- introduce struct stat_valueGilles Chehade
- statistics can now have a type (counter, timestamp, timeval, timespec and possibly others in the future) - stat_increment() / stat_decrement() now take an increment/decrement value and are at the moment only of type counter - stat_set() now takes a stat_value - provide helpers to convert raw values to stat_value ok eric@, ok chl@ while at it fix a rq_queue_dump() call using a bogus timestamp in scheduler ramqueue.
2012-08-24log forced removal and expiration of envelopes to maillog.Eric Faurot
suggested by Jan Stary. move queue loading notification to log_debug() while there. ok gilles@
2012-08-24When an smtp session fails and IMSG_QUEUE_REMOVE_MESSAGE is sent to theEric Faurot
queue, also notify the scheduler so it can rollback the current update. Send only the msgid while there. ok gilles@
2012-08-24Error out if queue_envelope_load() failed, rather than sending crap toEric Faurot
the mta/mda. ok gilles@
2012-08-21Re-enable loop detection, but in mta and mda this time.Eric Faurot
ok gilles@
2012-08-18zap struct mta_batch. Only pass ids where needed.Eric Faurot
ok gilles@
2012-08-18- introduce stat_backend, an API for pluggable statistic backendsGilles Chehade
> statistics are no longer static structures in shared memory > statistics are only set, smtpd never uses them in its logic > each statistic is a key/value where key can be any (dynamic) string - convert all uses of the former API to use the new one - implement stat_ramstat that keeps non-persistent stats in ram structure ok eric@, ok chl@
2012-08-11Add missing header needed by PRI format stringCharles Longeau
Add missing header needed by time() ok eric@
2012-08-09Allow failure reports for different recipients of the same messageEric Faurot
to be grouped into a single bounce message. The bounce structure keeps a list of envelopes. For now, the list is constructed by delaying the re-enqueuing of a bounce envelope a bit, to wait for other bounces from the same message to be part of the same report.
2012-08-09Improve the message flows to completely isolate operations on theEric Faurot
queue backend within the queue process. The scheduler sends envelope ids to the queue process which loads the envelope and forward the request to the agent responsible for the delivery. The result is sent by the agent to the queue which updates the storage before notifying the scheduler. Bounces are created and enqueued (from the client side) by the queue process, rather than the scheduler. ok gilles@
2012-08-08Improve the scheduler backend API.Eric Faurot
New envelopes are pushed into the scheduler through the insert() commit() rollback() transactional interface functions. Worklists are pulled from the scheduler through a single batch() interface function, which returns a list of envelope ids and the type of processing. Envelopes returned in this batch are said to be "in-flight", as opposed to "pending". They are supposed to be processed in some way, and either updated() or deleted() at some point. The schedule()/remove() functions are used to alter the internal state of "pending" envelopes to make them schedulable. The enve- lopes will be part of a worklist on the next call to batch(). Rewrite the scheduler_ramqueue backend. The initial queue loading in now done by the queue. ok gilles@
2012-07-09- runner is the terminology we used back when we had runqueues, we noGilles Chehade
longer have them and runner is actually a scheduler so rename. - introduce scheduler_backend which does the same to scheduler than queue_backend does to queue and map_backend does to maps - remove all occurences of RUNNER and runner, replace them with SCHEDULER and scheduler ok eric@, ok chl@
2012-07-08remove enum queue_kind from queue_fsqueue.c.Charles Longeau
incoming messages are now always stored in /incoming, whatever the queue_backend is. remove QOP_FD_RW and fsqueue_message_fd_rw(). while there check return value of generated paths before calling rmtree() with advice from gilles@ and eric@ ok gilles@ eric@