backend.h

00001 /*
00002  * Copyright (c) 2005-2012 by KoanLogic s.r.l. <http://www.koanlogic.com>
00003  * All rights reserved.
00004  *
00005  * This file is part of KLone, and as such it is subject to the license stated
00006  * in the LICENSE file which you have received as part of this distribution.
00007  *
00008  * $Id: backend.h,v 1.17 2008/06/04 17:48:01 tat Exp $
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 /* define page list */
00024 LIST_HEAD(backends_s, backend_s);
00025 
00026 struct backend_s
00027 {
00028     /* statically initialized values */
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     /* runtime values */
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;           /* pid of children              */
00049     LIST_ENTRY(backend_s) np;   /* next & prev pointers         */
00050 };
00051 
00052 typedef struct backend_s backend_t;
00053 typedef struct backends_s backends_t; /* backend_t list        */
00054 
00055 #define BACKEND_STATIC_INITIALIZER(proto, init, connect, term)  \
00056     {                                                           \
00057         proto,                                                  \
00058         init,                                                   \
00059         connect,                                                \
00060         term,                                                   \
00061         NULL,   /* server       */                              \
00062         NULL,   /* config       */                              \
00063         NULL,   /* addr         */                              \
00064         0,      /* model        */                              \
00065         -1,     /* ld           */                              \
00066         NULL,   /* arg          */                              \
00067         NULL,   /* klog         */                              \
00068         -1,     /* id           */                              \
00069         0,      /* nchild       */                              \
00070         0,      /* max_child    */                              \
00071         0,      /* start_child  */                              \
00072         0,      /* max_rq_xchild*/                              \
00073         0,      /* fork_child   */                              \
00074         NULL,   /* children pids*/                              \
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

←Products
Copyright © 2005-2012 - KoanLogic S.r.l. - All rights reserved