/* We must create the fd queues before we start up the listener
* and worker threads. */
- worker_queue = apr_pcalloc(pchild, sizeof(*worker_queue));
- rv = ap_queue_init(worker_queue, threads_per_child, pchild);
+ rv = ap_queue_create(&worker_queue, threads_per_child, pchild);
if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_ALERT, rv, ap_server_conf, APLOGNO(03100)
- "ap_queue_init() failed");
+ "ap_queue_create() failed");
clean_child_exit(APEXIT_CHILDFATAL);
}
/* We must create the fd queues before we start up the listener
* and worker threads. */
- worker_queue = apr_pcalloc(pchild, sizeof(*worker_queue));
- rv = ap_queue_init(worker_queue, threads_per_child, pchild);
+ rv = ap_queue_create(&worker_queue, threads_per_child, pchild);
if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_ALERT, rv, ap_server_conf, APLOGNO(03140)
- "ap_queue_init() failed");
+ "ap_queue_create() failed");
clean_child_exit(APEXIT_CHILDFATAL);
}
/**
* Initialize the fd_queue_t.
*/
-apr_status_t ap_queue_init(fd_queue_t *queue, int capacity, apr_pool_t *p)
+apr_status_t ap_queue_create(fd_queue_t **pqueue, int capacity, apr_pool_t *p)
{
- int i;
apr_status_t rv;
+ fd_queue_t *queue;
+
+ queue = apr_pcalloc(p, sizeof *queue);
if ((rv = apr_thread_mutex_create(&queue->one_big_mutex,
APR_THREAD_MUTEX_DEFAULT,
APR_RING_INIT(&queue->timers, timer_event_t, link);
- queue->data = apr_palloc(p, capacity * sizeof(fd_queue_elem_t));
+ queue->data = apr_pcalloc(p, capacity * sizeof(fd_queue_elem_t));
queue->bounds = capacity;
- queue->nelts = 0;
- queue->in = 0;
- queue->out = 0;
-
- /* Set all the sockets in the queue to NULL */
- for (i = 0; i < capacity; ++i)
- queue->data[i].sd = NULL;
apr_pool_cleanup_register(p, queue, ap_queue_destroy,
apr_pool_cleanup_null);
+ *pqueue = queue;
return APR_SUCCESS;
}
apr_thread_cond_signal(queue->not_empty);
- if ((rv = apr_thread_mutex_unlock(queue->one_big_mutex)) != APR_SUCCESS) {
- return rv;
- }
-
- return APR_SUCCESS;
+ return apr_thread_mutex_unlock(queue->one_big_mutex);
}
/**
void ap_push_pool(fd_queue_info_t *queue_info, apr_pool_t *pool_to_recycle);
void ap_free_idle_pools(fd_queue_info_t *queue_info);
-apr_status_t ap_queue_init(fd_queue_t *queue, int capacity, apr_pool_t *p);
+apr_status_t ap_queue_create(fd_queue_t **pqueue, int capacity, apr_pool_t *p);
apr_status_t ap_queue_push_socket(fd_queue_t *queue,
apr_socket_t *sd, void *sd_baton,
apr_pool_t *p);