csd = cs->pfd.desc.s;
ptrans = cs->p;
}
- rc = ap_queue_push(worker_queue, csd, cs, ptrans);
+ rc = ap_queue_push_socket(worker_queue, csd, cs, ptrans);
if (rc != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_CRIT, rc, ap_server_conf, APLOGNO(00471)
- "push2worker: ap_queue_push failed");
+ "push2worker: ap_queue_push_socket failed");
/* trash the connection; we couldn't queue the connected
* socket to a worker
*/
if (APR_STATUS_IS_EOF(rv)) {
break;
}
- /* We get APR_EINTR whenever ap_queue_pop() has been interrupted
+ /* We get APR_EINTR whenever ap_queue_pop_*() has been interrupted
* from an explicit call to ap_queue_interrupt_all(). This allows
- * us to unblock threads stuck in ap_queue_pop() when a shutdown
+ * us to unblock threads stuck in ap_queue_pop_*() when a shutdown
* is pending.
*
* If workers_may_exit is set and this is ungraceful termination/
/* We got some other error. */
else if (!workers_may_exit) {
ap_log_error(APLOG_MARK, APLOG_CRIT, rv, ap_server_conf,
- APLOGNO(03099) "ap_queue_pop failed");
+ APLOGNO(03099) "ap_queue_pop_socket failed");
}
continue;
}
accept_mutex_error("unlock", rv, process_slot);
}
if (csd != NULL) {
- rv = ap_queue_push(worker_queue, csd, NULL, ptrans);
+ rv = ap_queue_push_socket(worker_queue, csd, NULL, ptrans);
if (rv) {
/* trash the connection; we couldn't queue the connected
* socket to a worker
*/
apr_socket_close(csd);
ap_log_error(APLOG_MARK, APLOG_CRIT, rv, ap_server_conf, APLOGNO(03138)
- "ap_queue_push failed");
+ "ap_queue_push_socket failed");
}
else {
have_idle_worker = 0;
if (workers_may_exit) {
break;
}
- rv = ap_queue_pop(worker_queue, &csd, &ptrans);
+ rv = ap_queue_pop_socket(worker_queue, &csd, &ptrans);
if (rv != APR_SUCCESS) {
/* We get APR_EOF during a graceful shutdown once all the connections
if (APR_STATUS_IS_EOF(rv)) {
break;
}
- /* We get APR_EINTR whenever ap_queue_pop() has been interrupted
+ /* We get APR_EINTR whenever ap_queue_pop_*() has been interrupted
* from an explicit call to ap_queue_interrupt_all(). This allows
- * us to unblock threads stuck in ap_queue_pop() when a shutdown
+ * us to unblock threads stuck in ap_queue_pop_*() when a shutdown
* is pending.
*
* If workers_may_exit is set and this is ungraceful termination/
/* We got some other error. */
else if (!workers_may_exit) {
ap_log_error(APLOG_MARK, APLOG_CRIT, rv, ap_server_conf, APLOGNO(03139)
- "ap_queue_pop failed");
+ "ap_queue_pop_socket failed");
}
continue;
}
{
apr_uint32_t val;
val = apr_atomic_read32(&queue_info->idlers);
- if (val <= zero_pt)
- return 0;
- return val - zero_pt;
+ return (val > zero_pt) ? val - zero_pt : 0;
}
void ap_push_pool(fd_queue_info_t *queue_info, apr_pool_t *pool_to_recycle)
/**
* Initialize the fd_queue_t.
*/
-apr_status_t ap_queue_init(fd_queue_t *queue, int queue_capacity,
- apr_pool_t *a)
+apr_status_t ap_queue_init(fd_queue_t *queue, int capacity, apr_pool_t *p)
{
int i;
apr_status_t rv;
if ((rv = apr_thread_mutex_create(&queue->one_big_mutex,
APR_THREAD_MUTEX_DEFAULT,
- a)) != APR_SUCCESS) {
+ p)) != APR_SUCCESS) {
return rv;
}
- if ((rv = apr_thread_cond_create(&queue->not_empty, a)) != APR_SUCCESS) {
+ if ((rv = apr_thread_cond_create(&queue->not_empty, p)) != APR_SUCCESS) {
return rv;
}
APR_RING_INIT(&queue->timers, timer_event_t, link);
- queue->data = apr_palloc(a, queue_capacity * sizeof(fd_queue_elem_t));
- queue->bounds = queue_capacity;
+ queue->data = apr_palloc(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 < queue_capacity; ++i)
+ for (i = 0; i < capacity; ++i)
queue->data[i].sd = NULL;
- apr_pool_cleanup_register(a, queue, ap_queue_destroy,
+ apr_pool_cleanup_register(p, queue, ap_queue_destroy,
apr_pool_cleanup_null);
return APR_SUCCESS;
* precondition: ap_queue_info_wait_for_idler has already been called
* to reserve an idle worker thread
*/
-apr_status_t ap_queue_push(fd_queue_t *queue, apr_socket_t *sd,
- void *sd_baton, 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)
{
fd_queue_elem_t *elem;
apr_status_t rv;
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 queue_capacity,
- apr_pool_t *a);
-apr_status_t ap_queue_push(fd_queue_t *queue, apr_socket_t *sd,
- void *baton, apr_pool_t *p);
+apr_status_t ap_queue_init(fd_queue_t *queue, 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);
apr_status_t ap_queue_push_timer(fd_queue_t *queue, timer_event_t *te);
-apr_status_t ap_queue_pop_something(fd_queue_t *queue, apr_socket_t **sd,
- void **baton, apr_pool_t **p,
- timer_event_t **te);
-#define ap_queue_pop(q_, s_, p_) \
+apr_status_t ap_queue_pop_something(fd_queue_t *queue,
+ apr_socket_t **sd, void **sd_baton,
+ apr_pool_t **p, timer_event_t **te);
+#define ap_queue_pop_socket(q_, s_, p_) \
ap_queue_pop_something((q_), (s_), NULL, (p_), NULL)
apr_status_t ap_queue_interrupt_all(fd_queue_t *queue);
apr_status_t ap_queue_interrupt_one(fd_queue_t *queue);