- if ((child = dsi_start(&obj, (DSI *)polldata[i].data, server_children))) {
- /* Add IPC fd to select fd set */
- fdset_add_fd(obj.options.connections + AFP_LISTENERS + FDSET_SAFETY,
- &fdset,
- &polldata,
- &fdset_used,
- &fdset_size,
- child->afpch_ipc_fd,
- IPC_FD,
- child);
+ if ((child = dsi_start(&obj, (DSI *)(asev->data[i].private), server_children))) {
+ if (!(asev_add_fd(asev, child->afpch_ipc_fd, IPC_FD, child))) {
+ LOG(log_error, logtype_afpd, "out of asev slots");
+
+ /*
+ * Close IPC fd here and mark it as unused
+ */
+ close(child->afpch_ipc_fd);
+ child->afpch_ipc_fd = -1;
+
+ /*
+ * Being unfriendly here, but we really
+ * want to get rid of it. The 'child'
+ * handle gets cleaned up in the SIGCLD
+ * handler.
+ */
+ kill(child->afpch_pid, SIGKILL);
+ }