Commit 0841b654 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Move vca_return_session() to Pool_Wait()

parent c1059952
......@@ -645,7 +645,6 @@ struct vbc {
/* Prototypes etc ----------------------------------------------------*/
/* cache_acceptor.c */
void vca_return_session(struct sess *sp);
void VCA_Prep(struct sess *sp);
void VCA_Init(void);
void VCA_Shutdown(void);
......@@ -840,6 +839,7 @@ void PipeSession(struct sess *sp);
void Pool_Init(void);
int Pool_QueueSession(struct sess *sp);
void Pool_Work_Thread(void *priv, struct worker *w);
void Pool_Wait(struct sess *sp);
#define WRW_IsReleased(w) ((w)->wrw.wfd == NULL)
int WRW_Error(const struct worker *w);
......
......@@ -40,9 +40,6 @@
#include "vcli.h"
#include "cli_priv.h"
#include "cache.h"
#include "cache_waiter.h"
static void *waiter_priv;
pthread_t VCA_thread;
static struct timeval tv_sndtimeo;
......@@ -296,25 +293,6 @@ vca_acct(void *arg)
}
/*--------------------------------------------------------------------*/
void
vca_return_session(struct sess *sp)
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
AZ(sp->obj);
AZ(sp->vcl);
assert(sp->fd >= 0);
/*
* Set nonblocking in the worker-thread, before passing to the
* acceptor thread, to reduce syscall density of the latter.
*/
if (VTCP_nonblocking(sp->fd))
SES_Close(sp, "remote closed");
waiter->pass(waiter_priv, sp);
}
/*--------------------------------------------------------------------*/
static void
......@@ -325,14 +303,7 @@ ccf_start(struct cli *cli, const char * const *av, void *priv)
(void)av;
(void)priv;
AN(waiter);
AN(waiter->name);
AN(waiter->init);
AN(waiter->pass);
waiter_priv = waiter->init();
AZ(pthread_create(&VCA_thread, NULL, vca_acct, NULL));
VSL(SLT_Debug, 0, "Acceptor is %s", waiter->name);
}
/*--------------------------------------------------------------------*/
......
......@@ -108,7 +108,7 @@ cnt_wait(struct sess *sp)
sp->wrk->stats.sess_herd++;
SES_Charge(sp);
sp->wrk = NULL;
vca_return_session(sp);
Pool_Wait(sp);
return (1);
}
if (i == 1) {
......@@ -398,7 +398,7 @@ cnt_done(struct sess *sp)
}
sp->wrk->stats.sess_herd++;
sp->wrk = NULL;
vca_return_session(sp);
Pool_Wait(sp);
return (1);
}
......
......@@ -54,9 +54,12 @@
#include "vcl.h"
#include "cli_priv.h"
#include "cache.h"
#include "cache_waiter.h"
#include "stevedore.h"
#include "hash_slinger.h"
static void *waiter_priv;
VTAILQ_HEAD(workerhead, worker);
/* Number of work requests queued in excess of worker threads available */
......@@ -454,6 +457,27 @@ wrk_herder_thread(void *priv)
NEEDLESS_RETURN(NULL);
}
/*--------------------------------------------------------------------
* Wait for another request
*/
void
Pool_Wait(struct sess *sp)
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
AZ(sp->obj);
AZ(sp->vcl);
assert(sp->fd >= 0);
/*
* Set nonblocking in the worker-thread, before passing to the
* acceptor thread, to reduce syscall density of the latter.
*/
if (VTCP_nonblocking(sp->fd))
SES_Close(sp, "remote closed");
waiter->pass(waiter_priv, sp);
}
/*--------------------------------------------------------------------*/
void
......@@ -464,6 +488,8 @@ Pool_Init(void)
AZ(pthread_cond_init(&herder_cond, NULL));
Lck_New(&herder_mtx, lck_herder);
waiter_priv = waiter->init();
wrk_addpools(params->wthread_pools);
AZ(pthread_create(&tp, NULL, wrk_herdtimer_thread, NULL));
AZ(pthread_detach(tp));
......
......@@ -53,11 +53,12 @@ extern const struct waiter waiter_kqueue;
extern const struct waiter waiter_ports;
#endif
extern const struct waiter waiter_poll;
/* cache_session.c */
void SES_Handle(struct sess *sp, int status);
/* cache_waiter.c */
extern const struct waiter waiter_poll;
const char *WAIT_GetName(void);
void WAIT_tweak_waiter(struct cli *cli, const char *arg);
void WAIT_Init(void);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment