backend.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef _KLONE_BACKEND_H_
00012 #define _KLONE_BACKEND_H_
00013
00014 #include <u/libu.h>
00015 #include <klone/klog.h>
00016
00017 #ifdef __cplusplus
00018 extern "C" {
00019 #endif
00020
00021 struct server_s;
00022
00023
00024 LIST_HEAD(backends_s, backend_s);
00025
00026 struct backend_s
00027 {
00028
00029 const char *proto;
00030 int (*cb_init)(struct backend_s *);
00031 int (*cb_serve)(struct backend_s *, int);
00032 int (*cb_term)(struct backend_s *);
00033
00034
00035 struct server_s *server;
00036 u_config_t *config;
00037 u_net_addr_t *na;
00038 int model;
00039 int ld;
00040 void *arg;
00041 klog_t *klog;
00042 int id;
00043 size_t nchild;
00044 size_t max_child;
00045 size_t start_child;
00046 size_t max_rq_xchild;
00047 size_t fork_child;
00048 pid_t *child_pid;
00049 LIST_ENTRY(backend_s) np;
00050 };
00051
00052 typedef struct backend_s backend_t;
00053 typedef struct backends_s backends_t;
00054
00055 #define BACKEND_STATIC_INITIALIZER(proto, init, connect, term) \
00056 { \
00057 proto, \
00058 init, \
00059 connect, \
00060 term, \
00061 NULL, \
00062 NULL, \
00063 NULL, \
00064 0, \
00065 -1, \
00066 NULL, \
00067 NULL, \
00068 -1, \
00069 0, \
00070 0, \
00071 0, \
00072 0, \
00073 0, \
00074 NULL, \
00075 LIST_ENTRY_NULL \
00076 }
00077
00078
00079 extern backend_t *backend_list[];
00080
00081 int backend_create(const char *name, u_config_t *, backend_t **);
00082 int backend_serve(backend_t *, int fd);
00083 int backend_free(backend_t *);
00084
00085 #ifdef __cplusplus
00086 }
00087 #endif
00088
00089 #endif