s3-prefork: Improve heuristics
[ab/samba.git/.git] / source3 / lib / server_prefork.h
index 4874359e0b2a3ed1962881f96ec01fac6f13c9e8..d240641a39325d211cedd4d13e6fcfb5ffad1e05 100644 (file)
@@ -26,9 +26,8 @@ struct prefork_pool;
 
 enum pf_worker_status {
        PF_WORKER_NONE = 0,
-       PF_WORKER_IDLE,
+       PF_WORKER_ALIVE,
        PF_WORKER_ACCEPTING,
-       PF_WORKER_BUSY,
        PF_WORKER_EXITING
 };
 
@@ -67,7 +66,6 @@ struct pf_worker_data {
 * @param pf            The mmaped area used to communicate with parent
 * @param listen_fd_size The number of file descriptors to monitor
 * @param listen_fds    The array of file descriptors
-* @param lock_fd       The locking file descriptor
 * @param private_data  Private data that needs to be passed to the main
 *                      function from the calling parent.
 *
@@ -79,7 +77,6 @@ typedef int (prefork_main_fn_t)(struct tevent_context *ev,
                                int child_id,
                                int listen_fd_size,
                                int *listen_fds,
-                               int lock_fd,
                                void *private_data);
 
 /**
@@ -171,26 +168,43 @@ int prefork_add_children(struct tevent_context *ev_ctx,
 int prefork_retire_children(struct prefork_pool *pfp,
                            int num_children, time_t age_limit);
 /**
-* @brief Count the number of active children
+* @brief Count the number of children
 *
 * @param pfp   The pool.
-* @param total Returns the number of children currently alive
+* @param active        Number of children currently active if not NULL
 *
-* @return The number of children actually serving clients
+* @return The total number of children.
 */
-int prefork_count_active_children(struct prefork_pool *pfp, int *total);
+int prefork_count_children(struct prefork_pool *pfp, int *active);
 
 /**
-* @brief Inform all children that they are allowed to accept 'max' clients
-*       now. Use this when all children are already busy and more clients
-*       are trying to connect. It will allow each child to handle more than
-*       one client at a time, up to 'max'.
+* @brief Count the number of actual connections currently allowed
+*
+* @param pfp           The pool.
+*
+* @return The number of connections that can still be opened by clients
+*        with the current pool of children.
+*/
+int prefork_count_allowed_connections(struct prefork_pool *pfp);
+
+/**
+* @brief Increase the amount of clients each child is allowed to handle
+*       simultaneaously. It will allow each child to handle more than
+*       one client at a time, up to 'max' (currently set to 100).
 *
 * @param pfp   The pool.
-* @param max   Max number of clients per child.
+* @param max   Max number of allowed connections per child
 */
 void prefork_increase_allowed_clients(struct prefork_pool *pfp, int max);
 
+/**
+* @brief Decrease the amount of clients each child is allowed to handle.
+*       Min is 1.
+*
+* @param pfp   The pool.
+*/
+void prefork_decrease_allowed_clients(struct prefork_pool *pfp);
+
 /**
 * @brief Reset the maximum allowd clients per child to 1.
 *       Does not reduce the number of clients actually beeing served by
@@ -239,7 +253,6 @@ void prefork_set_sigchld_callback(struct prefork_pool *pfp,
 * @param pf            The child/parent shared structure
 * @param listen_fd_size        The number of listening file descriptors
 * @param listen_fds    The array of listening file descriptors
-* @param lock_fd       The locking file descriptor
 *
 * @return The tevent request pointer or NULL on allocation errors.
 */
@@ -247,8 +260,7 @@ struct tevent_req *prefork_listen_send(TALLOC_CTX *mem_ctx,
                                        struct tevent_context *ev,
                                        struct pf_worker_data *pf,
                                        int listen_fd_size,
-                                       int *listen_fds,
-                                       int lock_fd);
+                                       int *listen_fds);
 /**
 * @brief Returns the file descriptor after the new client connection has
 *       been accepted.