2 Unix SMB/Netbios implementation.
4 Copyright (C) Simo Sorce 2010
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "smbd/smbd.h"
24 #include "include/printing.h"
25 #include "printing/nt_printing_migrate_internal.h"
26 #include "printing/queue_process.h"
27 #include "printing/pcap.h"
29 #include "librpc/gen_ndr/srv_winreg.h"
30 #include "librpc/gen_ndr/srv_spoolss.h"
31 #include "rpc_server/rpc_server.h"
32 #include "rpc_server/rpc_ep_register.h"
33 #include "rpc_server/spoolss/srv_spoolss_nt.h"
34 #include "librpc/rpc/dcerpc_ep.h"
35 #include "lib/server_prefork.h"
37 #define SPOOLSS_PIPE_NAME "spoolss"
38 #define DAEMON_NAME "spoolssd"
40 #define SPOOLSS_MIN_CHILDREN 5
41 #define SPOOLSS_MAX_CHILDREN 25
42 #define SPOOLSS_SPAWN_RATE 5
43 #define SPOOLSS_MIN_LIFE 60 /* 1 minute minimum life time */
45 #define SPOOLSS_INIT 0x00
46 #define SPOOLSS_NEW_MAX 0x01
47 #define SPOLLSS_ENOSPC 0x02
49 static struct prefork_pool
*spoolss_pool
;
50 static int spoolss_min_children
;
51 static int spoolss_max_children
;
52 static int spoolss_spawn_rate
;
53 static int spoolss_prefork_status
;
54 static int spoolss_child_id
= 0;
56 static void spoolss_prefork_config(void)
58 static int spoolss_prefork_config_init
= false;
59 const char *prefork_str
;
61 bool use_defaults
= false;
64 if (!spoolss_prefork_config_init
) {
66 spoolss_prefork_status
= SPOOLSS_INIT
;
67 spoolss_min_children
= 0;
68 spoolss_max_children
= 0;
69 spoolss_spawn_rate
= 0;
70 spoolss_prefork_config_init
= true;
73 prefork_str
= lp_parm_const_string(GLOBAL_SECTION_SNUM
,
74 "spoolssd", "prefork", "none");
75 if (strcmp(prefork_str
, "none") == 0) {
78 ret
= sscanf(prefork_str
, "%d:%d:%d", &min
, &max
, &rate
);
80 DEBUG(0, ("invalid format for spoolssd:prefork!\n"));
86 min
= SPOOLSS_MIN_CHILDREN
;
87 max
= SPOOLSS_MAX_CHILDREN
;
88 rate
= SPOOLSS_SPAWN_RATE
;
91 if (max
> spoolss_max_children
&& spoolss_max_children
!= 0) {
92 spoolss_prefork_status
|= SPOOLSS_NEW_MAX
;
95 spoolss_min_children
= min
;
96 spoolss_max_children
= max
;
97 spoolss_spawn_rate
= rate
;
100 static void spoolss_reopen_logs(int child_id
)
102 char *lfile
= lp_logfile();
107 rc
= asprintf(&ext
, ".%s.%d", DAEMON_NAME
, child_id
);
109 rc
= asprintf(&ext
, ".%s", DAEMON_NAME
);
113 /* if we can't allocate, set it to NULL
114 * and logging will flow in the original file */
119 if (lfile
== NULL
|| lfile
[0] == '\0') {
120 rc
= asprintf(&lfile
, "%s/log%s",
121 get_dyn_LOGFILEBASE(), ext
?ext
:"");
123 if (ext
&& strstr(lfile
, ext
) == NULL
) {
124 if (strstr(lfile
, DAEMON_NAME
) == NULL
) {
125 rc
= asprintf(&lfile
, "%s%s",
126 lp_logfile(), ext
?ext
:"");
128 rc
= asprintf(&lfile
, "%s.%d",
129 lp_logfile(), child_id
);
135 lp_set_logfile(lfile
);
144 static void update_conf(struct tevent_context
*ev
,
145 struct messaging_context
*msg
)
147 change_to_root_user();
148 lp_load(get_dyn_CONFIGFILE(), true, false, false, true);
149 reload_printers(ev
, msg
);
151 spoolss_reopen_logs(spoolss_child_id
);
152 if (spoolss_child_id
== 0) {
153 spoolss_prefork_config();
157 static void smb_conf_updated(struct messaging_context
*msg
,
160 struct server_id server_id
,
163 struct tevent_context
*ev_ctx
= talloc_get_type_abort(private_data
,
164 struct tevent_context
);
166 DEBUG(10, ("Got message saying smb.conf was updated. Reloading.\n"));
167 update_conf(ev_ctx
, msg
);
170 static void update_pcap(struct tevent_context
*ev_ctx
,
171 struct messaging_context
*msg_ctx
)
173 change_to_root_user();
174 reload_printers(ev_ctx
, msg_ctx
);
177 static void pcap_updated(struct messaging_context
*msg
,
180 struct server_id server_id
,
183 struct tevent_context
*ev_ctx
;
185 ev_ctx
= talloc_get_type_abort(private_data
, struct tevent_context
);
187 DEBUG(10, ("Got message that pcap updated. Reloading.\n"));
188 update_pcap(ev_ctx
, msg
);
191 static void spoolss_sig_term_handler(struct tevent_context
*ev
,
192 struct tevent_signal
*se
,
198 exit_server_cleanly("termination signal");
201 static void spoolss_setup_sig_term_handler(struct tevent_context
*ev_ctx
)
203 struct tevent_signal
*se
;
205 se
= tevent_add_signal(ev_ctx
,
208 spoolss_sig_term_handler
,
211 exit_server("failed to setup SIGTERM handler");
215 static void spoolss_sig_hup_handler(struct tevent_context
*ev
,
216 struct tevent_signal
*se
,
222 struct messaging_context
*msg_ctx
;
224 msg_ctx
= talloc_get_type_abort(pvt
, struct messaging_context
);
226 DEBUG(1,("Reloading printers after SIGHUP\n"));
227 update_conf(ev
, msg_ctx
);
229 /* relay to all children */
231 prefork_send_signal_to_all(spoolss_pool
, SIGHUP
);
235 static void spoolss_setup_sig_hup_handler(struct tevent_context
*ev_ctx
,
236 struct messaging_context
*msg_ctx
)
238 struct tevent_signal
*se
;
240 se
= tevent_add_signal(ev_ctx
,
243 spoolss_sig_hup_handler
,
246 exit_server("failed to setup SIGHUP handler");
250 static bool spoolss_init_cb(void *ptr
)
252 struct messaging_context
*msg_ctx
= talloc_get_type_abort(
253 ptr
, struct messaging_context
);
255 return nt_printing_tdb_migrate(msg_ctx
);
258 static bool spoolss_shutdown_cb(void *ptr
)
260 srv_spoolss_cleanup();
267 struct spoolss_chld_sig_hup_ctx
{
268 struct messaging_context
*msg_ctx
;
269 struct pf_worker_data
*pf
;
272 static void spoolss_chld_sig_hup_handler(struct tevent_context
*ev
,
273 struct tevent_signal
*se
,
279 struct spoolss_chld_sig_hup_ctx
*shc
;
281 shc
= talloc_get_type_abort(pvt
, struct spoolss_chld_sig_hup_ctx
);
283 /* avoid wasting CPU cycles if we are going to exit soon anyways */
284 if (shc
->pf
!= NULL
&&
285 shc
->pf
->cmds
== PF_SRV_MSG_EXIT
) {
289 change_to_root_user();
290 DEBUG(1,("Reloading printers after SIGHUP\n"));
291 reload_printers(ev
, shc
->msg_ctx
);
292 spoolss_reopen_logs(spoolss_child_id
);
295 static bool spoolss_setup_chld_hup_handler(struct tevent_context
*ev_ctx
,
296 struct messaging_context
*msg_ctx
,
297 struct pf_worker_data
*pf
)
299 struct spoolss_chld_sig_hup_ctx
*shc
;
300 struct tevent_signal
*se
;
302 shc
= talloc(ev_ctx
, struct spoolss_chld_sig_hup_ctx
);
304 DEBUG(1, ("failed to setup SIGHUP handler"));
308 shc
->msg_ctx
= msg_ctx
;
310 se
= tevent_add_signal(ev_ctx
,
313 spoolss_chld_sig_hup_handler
,
316 DEBUG(1, ("failed to setup SIGHUP handler"));
323 static bool spoolss_child_init(struct tevent_context
*ev_ctx
,
324 int child_id
, struct pf_worker_data
*pf
)
327 struct rpc_srv_callbacks spoolss_cb
;
328 struct messaging_context
*msg_ctx
= server_messaging_context();
331 status
= reinit_after_fork(msg_ctx
, ev_ctx
,
332 procid_self(), true);
333 if (!NT_STATUS_IS_OK(status
)) {
334 DEBUG(0,("reinit_after_fork() failed\n"));
335 smb_panic("reinit_after_fork() failed");
338 spoolss_child_id
= child_id
;
339 spoolss_reopen_logs(child_id
);
341 ok
= spoolss_setup_chld_hup_handler(ev_ctx
, msg_ctx
, pf
);
346 if (!serverid_register(procid_self(),
348 FLAG_MSG_PRINT_NOTIFY
|
349 FLAG_MSG_PRINT_GENERAL
)) {
353 if (!locking_init()) {
357 messaging_register(msg_ctx
, ev_ctx
,
358 MSG_SMB_CONF_UPDATED
, smb_conf_updated
);
359 messaging_register(msg_ctx
, ev_ctx
, MSG_PRINTER_PCAP
,
362 /* try to reinit rpc queues */
363 spoolss_cb
.init
= spoolss_init_cb
;
364 spoolss_cb
.shutdown
= spoolss_shutdown_cb
;
365 spoolss_cb
.private_data
= msg_ctx
;
367 status
= rpc_winreg_init(NULL
);
368 if (!NT_STATUS_IS_OK(status
)) {
369 DEBUG(0, ("Failed to register winreg rpc inteface! (%s)\n",
374 status
= rpc_spoolss_init(&spoolss_cb
);
375 if (!NT_STATUS_IS_OK(status
)) {
376 DEBUG(0, ("Failed to register spoolss rpc inteface! (%s)\n",
381 pcap_cache_reload(ev_ctx
, msg_ctx
, &update_pcap
);
386 struct spoolss_children_data
{
387 struct tevent_context
*ev_ctx
;
388 struct messaging_context
*msg_ctx
;
389 struct pf_worker_data
*pf
;
397 static void spoolss_next_client(void *pvt
);
399 static int spoolss_children_main(struct tevent_context
*ev_ctx
,
400 struct messaging_context
*msg_ctx
,
401 struct pf_worker_data
*pf
,
408 struct spoolss_children_data
*data
;
412 ok
= spoolss_child_init(ev_ctx
, child_id
, pf
);
417 data
= talloc(ev_ctx
, struct spoolss_children_data
);
422 data
->ev_ctx
= ev_ctx
;
423 data
->msg_ctx
= msg_ctx
;
424 data
->lock_fd
= lock_fd
;
425 data
->listen_fd_size
= listen_fd_size
;
426 data
->listen_fds
= listen_fds
;
427 data
->listening
= false;
429 /* loop until it is time to exit */
430 while (pf
->status
!= PF_WORKER_EXITING
) {
431 /* try to see if it is time to schedule the next client */
432 spoolss_next_client(data
);
434 ret
= tevent_loop_once(ev_ctx
);
436 DEBUG(0, ("tevent_loop_once() exited with %d: %s\n",
437 ret
, strerror(errno
)));
438 pf
->status
= PF_WORKER_EXITING
;
445 static void spoolss_client_terminated(void *pvt
)
447 struct spoolss_children_data
*data
;
449 data
= talloc_get_type_abort(pvt
, struct spoolss_children_data
);
451 if (data
->pf
->num_clients
) {
452 data
->pf
->num_clients
--;
454 DEBUG(2, ("Invalid num clients, aborting!\n"));
455 data
->pf
->status
= PF_WORKER_EXITING
;
459 spoolss_next_client(pvt
);
462 struct spoolss_new_client
{
463 struct spoolss_children_data
*data
;
464 struct tsocket_address
*srv_addr
;
465 struct tsocket_address
*cli_addr
;
468 static void spoolss_handle_client(struct tevent_req
*req
);
470 static void spoolss_next_client(void *pvt
)
472 struct tevent_req
*req
;
473 struct spoolss_children_data
*data
;
474 struct spoolss_new_client
*next
;
476 data
= talloc_get_type_abort(pvt
, struct spoolss_children_data
);
478 if (data
->pf
->num_clients
== 0) {
479 data
->pf
->status
= PF_WORKER_IDLE
;
482 if (data
->pf
->cmds
== PF_SRV_MSG_EXIT
) {
483 DEBUG(2, ("Parent process commands we terminate!\n"));
487 if (data
->listening
||
488 data
->pf
->num_clients
>= data
->pf
->allowed_clients
) {
489 /* nothing to do for now we are already listening
490 * or reached the number of clients we are allowed
491 * to handle in parallel */
495 next
= talloc_zero(data
, struct spoolss_new_client
);
497 DEBUG(1, ("Out of memory!?\n"));
502 req
= prefork_listen_send(next
, data
->ev_ctx
, data
->pf
,
503 data
->listen_fd_size
,
507 DEBUG(1, ("Failed to make listening request!?\n"));
511 tevent_req_set_callback(req
, spoolss_handle_client
, next
);
513 data
->listening
= true;
516 static void spoolss_handle_client(struct tevent_req
*req
)
518 struct spoolss_children_data
*data
;
519 struct spoolss_new_client
*client
;
523 client
= tevent_req_callback_data(req
, struct spoolss_new_client
);
526 ret
= prefork_listen_recv(req
, client
, &sd
,
527 &client
->srv_addr
, &client
->cli_addr
);
529 /* this will free the request too */
531 /* we are done listening */
532 data
->listening
= false;
535 DEBUG(1, ("Failed to accept client connection!\n"));
536 /* bail out if we are not serving any other client */
537 if (data
->pf
->num_clients
== 0) {
538 data
->pf
->status
= PF_WORKER_EXITING
;
544 DEBUG(1, ("Server asks us to die!\n"));
545 data
->pf
->status
= PF_WORKER_EXITING
;
549 DEBUG(2, ("Spoolss preforked child %d got client connection!\n",
550 (int)(data
->pf
->pid
)));
552 named_pipe_accept_function(data
->ev_ctx
, data
->msg_ctx
,
553 SPOOLSS_PIPE_NAME
, sd
,
554 spoolss_client_terminated
, data
);
557 /* ==== Main Process Functions ==== */
559 extern pid_t background_lpq_updater_pid
;
560 static char *bq_logfile
;
562 static void check_updater_child(void)
567 if (background_lpq_updater_pid
== -1) {
571 pid
= sys_waitpid(background_lpq_updater_pid
, &status
, WNOHANG
);
573 DEBUG(2, ("The background queue child died... Restarting!\n"));
574 pid
= start_background_queue(server_event_context(),
575 server_messaging_context(),
577 background_lpq_updater_pid
= pid
;
581 static bool spoolssd_schedule_check(struct tevent_context
*ev_ctx
,
582 struct messaging_context
*msg_ctx
,
583 struct timeval current_time
);
584 static void spoolssd_check_children(struct tevent_context
*ev_ctx
,
585 struct tevent_timer
*te
,
586 struct timeval current_time
,
589 static void spoolssd_sigchld_handler(struct tevent_context
*ev_ctx
,
590 struct prefork_pool
*pfp
,
593 struct messaging_context
*msg_ctx
;
597 msg_ctx
= talloc_get_type_abort(pvt
, struct messaging_context
);
599 /* now check we do not descend below the minimum */
600 active
= prefork_count_active_children(pfp
, &total
);
603 if (total
< spoolss_min_children
) {
604 n
= total
- spoolss_min_children
;
605 } else if (total
- active
< (total
/ 4)) {
606 n
= spoolss_min_children
;
610 r
= prefork_add_children(ev_ctx
, msg_ctx
, pfp
, n
);
612 DEBUG(10, ("Tried to start %d children but only,"
613 "%d were actually started.!\n", n
, r
));
617 /* also check if the updater child is alive and well */
618 check_updater_child();
621 static bool spoolssd_setup_children_monitor(struct tevent_context
*ev_ctx
,
622 struct messaging_context
*msg_ctx
)
626 /* add our oun sigchld callback */
627 prefork_set_sigchld_callback(spoolss_pool
,
628 spoolssd_sigchld_handler
, msg_ctx
);
630 ok
= spoolssd_schedule_check(ev_ctx
, msg_ctx
,
631 tevent_timeval_current());
635 static bool spoolssd_schedule_check(struct tevent_context
*ev_ctx
,
636 struct messaging_context
*msg_ctx
,
637 struct timeval current_time
)
639 struct tevent_timer
*te
;
640 struct timeval next_event
;
642 /* check situation again in 10 seconds */
643 next_event
= tevent_timeval_current_ofs(10, 0);
645 /* TODO: check when the socket becomes readable, so that children
646 * are checked only when there is some activity ? */
647 te
= tevent_add_timer(ev_ctx
, spoolss_pool
, next_event
,
648 spoolssd_check_children
, msg_ctx
);
650 DEBUG(2, ("Failed to set up children monitoring!\n"));
657 static void spoolssd_check_children(struct tevent_context
*ev_ctx
,
658 struct tevent_timer
*te
,
659 struct timeval current_time
,
662 struct messaging_context
*msg_ctx
;
663 time_t now
= time(NULL
);
667 msg_ctx
= talloc_get_type_abort(pvt
, struct messaging_context
);
669 if ((spoolss_prefork_status
& SPOOLSS_NEW_MAX
) &&
670 !(spoolss_prefork_status
& SPOLLSS_ENOSPC
)) {
671 ret
= prefork_expand_pool(spoolss_pool
, spoolss_max_children
);
673 spoolss_prefork_status
|= SPOLLSS_ENOSPC
;
675 spoolss_prefork_status
&= ~SPOOLSS_NEW_MAX
;
678 active
= prefork_count_active_children(spoolss_pool
, &total
);
680 if (total
- active
< spoolss_spawn_rate
) {
681 n
= prefork_add_children(ev_ctx
, msg_ctx
,
682 spoolss_pool
, spoolss_spawn_rate
);
683 if (n
< spoolss_spawn_rate
) {
684 DEBUG(10, ("Tried to start 5 children but only,"
685 "%d were actually started.!\n", n
));
689 if (total
- active
> spoolss_min_children
) {
690 if ((total
- spoolss_min_children
) >= spoolss_spawn_rate
) {
691 prefork_retire_children(spoolss_pool
,
693 now
- SPOOLSS_MIN_LIFE
);
697 ret
= spoolssd_schedule_check(ev_ctx
, msg_ctx
, current_time
);
700 static void print_queue_forward(struct messaging_context
*msg
,
703 struct server_id server_id
,
706 messaging_send_buf(msg
, pid_to_procid(background_lpq_updater_pid
),
707 MSG_PRINTER_UPDATE
, data
->data
, data
->length
);
710 char *get_bq_logfile(void)
712 char *lfile
= lp_logfile();
715 if (lfile
== NULL
|| lfile
[0] == '\0') {
716 rc
= asprintf(&lfile
, "%s/log.%s.bq",
717 get_dyn_LOGFILEBASE(), DAEMON_NAME
);
719 rc
= asprintf(&lfile
, "%s.bq", lp_logfile());
727 pid_t
start_spoolssd(struct tevent_context
*ev_ctx
,
728 struct messaging_context
*msg_ctx
)
730 struct rpc_srv_callbacks spoolss_cb
;
731 struct dcerpc_binding_vector
*v
;
739 DEBUG(1, ("Forking SPOOLSS Daemon\n"));
742 * Block signals before forking child as it will have to
743 * set its own handlers. Child will re-enable SIGHUP as
744 * soon as the handlers are set up.
746 BlockSignals(true, SIGTERM
);
747 BlockSignals(true, SIGHUP
);
752 DEBUG(0, ("Failed to fork SPOOLSS [%s]\n",
756 /* parent or error */
759 /* Re-enable SIGHUP before returnig */
760 BlockSignals(false, SIGTERM
);
761 BlockSignals(false, SIGHUP
);
766 close_low_fds(false);
768 status
= reinit_after_fork(msg_ctx
,
770 procid_self(), true);
771 if (!NT_STATUS_IS_OK(status
)) {
772 DEBUG(0,("reinit_after_fork() failed\n"));
773 smb_panic("reinit_after_fork() failed");
776 spoolss_reopen_logs(0);
777 spoolss_prefork_config();
779 spoolss_setup_sig_term_handler(ev_ctx
);
780 spoolss_setup_sig_hup_handler(ev_ctx
, msg_ctx
);
782 BlockSignals(false, SIGTERM
);
783 BlockSignals(false, SIGHUP
);
785 /* Publish nt printers, this requires a working winreg pipe */
786 pcap_cache_reload(ev_ctx
, msg_ctx
, &reload_printers
);
788 /* always start the backgroundqueue listner in spoolssd */
789 bq_logfile
= get_bq_logfile();
790 pid
= start_background_queue(ev_ctx
, msg_ctx
, bq_logfile
);
792 background_lpq_updater_pid
= pid
;
795 /* the listening fd must be created before the children are actually
797 listen_fd
= create_named_pipe_socket(SPOOLSS_PIPE_NAME
);
798 if (listen_fd
== -1) {
802 ret
= listen(listen_fd
, spoolss_max_children
);
804 DEBUG(0, ("Failed to listen on spoolss pipe - %s\n",
809 /* start children before any more initialization is done */
810 ok
= prefork_create_pool(ev_ctx
, /* mem_ctx */
813 spoolss_min_children
,
814 spoolss_max_children
,
815 &spoolss_children_main
, NULL
,
818 if (!serverid_register(procid_self(),
821 FLAG_MSG_PRINT_NOTIFY
|
822 FLAG_MSG_PRINT_GENERAL
)) {
826 if (!locking_init()) {
830 messaging_register(msg_ctx
, ev_ctx
,
831 MSG_SMB_CONF_UPDATED
, smb_conf_updated
);
832 messaging_register(msg_ctx
, NULL
, MSG_PRINTER_UPDATE
,
833 print_queue_forward
);
834 messaging_register(msg_ctx
, ev_ctx
, MSG_PRINTER_PCAP
,
837 mem_ctx
= talloc_new(NULL
);
838 if (mem_ctx
== NULL
) {
843 * Initialize spoolss with an init function to convert printers first.
844 * static_init_rpc will try to initialize the spoolss server too but you
845 * can't register it twice.
847 spoolss_cb
.init
= spoolss_init_cb
;
848 spoolss_cb
.shutdown
= spoolss_shutdown_cb
;
849 spoolss_cb
.private_data
= msg_ctx
;
851 status
= rpc_winreg_init(NULL
);
852 if (!NT_STATUS_IS_OK(status
)) {
853 DEBUG(0, ("Failed to register winreg rpc inteface! (%s)\n",
858 status
= rpc_spoolss_init(&spoolss_cb
);
859 if (!NT_STATUS_IS_OK(status
)) {
860 DEBUG(0, ("Failed to register spoolss rpc inteface! (%s)\n",
865 status
= dcerpc_binding_vector_new(mem_ctx
, &v
);
866 if (!NT_STATUS_IS_OK(status
)) {
867 DEBUG(0, ("Failed to create binding vector (%s)\n",
872 status
= dcerpc_binding_vector_add_np_default(&ndr_table_spoolss
, v
);
873 if (!NT_STATUS_IS_OK(status
)) {
874 DEBUG(0, ("Failed to add np to binding vector (%s)\n",
879 status
= rpc_ep_register(ev_ctx
, msg_ctx
, &ndr_table_spoolss
, v
);
880 if (!NT_STATUS_IS_OK(status
)) {
881 DEBUG(0, ("Failed to register spoolss endpoint! (%s)\n",
886 talloc_free(mem_ctx
);
888 ok
= spoolssd_setup_children_monitor(ev_ctx
, msg_ctx
);
890 DEBUG(0, ("Failed to setup children monitoring!\n"));
894 DEBUG(1, ("SPOOLSS Daemon Started (%d)\n", getpid()));
897 ret
= tevent_loop_wait(ev_ctx
);
899 /* should not be reached */
900 DEBUG(0,("background_queue: tevent_loop_wait() exited with %d - %s\n",
901 ret
, (ret
== 0) ? "out of events" : strerror(errno
)));