Commit f1da3c43 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Implement "struct waiter" for a waiter instance

parent a0e052c1
......@@ -60,7 +60,7 @@ struct sesspool {
struct mempool *mpl_req;
struct mempool *mpl_sess;
void *http1_waiter;
struct waiter *http1_waiter;
};
/*--------------------------------------------------------------------
......
......@@ -30,6 +30,7 @@
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <math.h>
......@@ -38,6 +39,13 @@
#include "waiter/waiter.h"
struct waiter {
unsigned magic;
#define WAITER_MAGIC 0x17c399db
const struct waiter_impl *impl;
void *priv;
};
const char *
WAIT_GetName(void)
{
......@@ -48,25 +56,32 @@ WAIT_GetName(void)
return ("no_waiter");
}
void *
struct waiter *
WAIT_Init(waiter_handle_f *func)
{
struct waiter *w;
ALLOC_OBJ(w, WAITER_MAGIC);
AN(w);
AN(waiter);
AN(waiter->name);
AN(waiter->init);
AN(waiter->pass);
return (waiter->init(func));
w->impl = waiter;
w->priv = w->impl->init(func);
return (w);
}
int
WAIT_Enter(void *waiter_priv, struct sess *sp)
WAIT_Enter(const struct waiter *w, struct sess *sp)
{
CHECK_OBJ_NOTNULL(w, WAITER_MAGIC);
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
assert(sp->fd >= 0);
return (waiter->pass(waiter_priv, sp));
return (w->impl->pass(w->priv, sp));
}
/*
......
......@@ -29,6 +29,7 @@
*/
struct sess;
struct waiter;
enum wait_event {
WAITER_REMCLOSE,
......@@ -49,8 +50,8 @@ struct waiter_impl {
};
/* cache_waiter.c */
int WAIT_Enter(void *waiter_priv, struct sess *sp);
void *WAIT_Init(waiter_handle_f *);
int WAIT_Enter(const struct waiter *, struct sess *sp);
struct waiter *WAIT_Init(waiter_handle_f *);
const char *WAIT_GetName(void);
int WAIT_Write_Session(struct sess *sp, int fd);
......
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