server.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: server.h,v 1.16 2006/01/09 12:38:38 tat Exp $
00009  */
00010 
00011 #ifndef _KLONE_SERVER_H_
00012 #define _KLONE_SERVER_H_
00013 
00014 #include "klone_conf.h"
00015 #include <klone/ppc.h>
00016 #include <klone/klog.h>
00017 
00018 #ifdef __cplusplus
00019 extern "C" {
00020 #endif
00021 
00022 struct u_config_s;
00023 struct server_s;
00024 typedef struct server_s server_t;
00025 
00026 enum { 
00027     SERVER_LOG_FLUSH_TIMEOUT = 5,   /* min # of seconds between two log flush */
00028 
00029     /* fork/prefork */
00030     SERVER_MAX_CHILD = 300,         /* total # of child process per-server    */
00031     SERVER_MAX_BACKEND_CHILD = 150, /* max # of child allowed to run at once 
00032                                        per-backend */
00033 
00034     /* prefork server model limits */
00035     SERVER_PREFORK_START_CHILD = 2, /* # of child to run on startup           */
00036     SERVER_PREFORK_MAX_RQ_CHILD = 10000 /* max # of rq a process can serve    */
00037 };
00038 
00039 enum { 
00040     SERVER_MODEL_UNSET,     /* uninitialized                                */
00041     SERVER_MODEL_FORK,      /* fork for each incoming connection            */
00042     SERVER_MODEL_ITERATIVE, /* serialize responses                          */
00043     SERVER_MODEL_PREFORK,   /* prefork a few child to serve more clients    */
00044     #ifdef OS_UNIX
00045     SERVER_MODEL_DEFAULT = SERVER_MODEL_PREFORK
00046     #else
00047     SERVER_MODEL_DEFAULT = SERVER_MODEL_ITERATIVE
00048     #endif
00049 };
00050 
00051 int server_create(struct u_config_s *config, int model, server_t **ps);
00052 int server_free(server_t *s);
00053 int server_loop(server_t *s);
00054 int server_cgi(server_t *s);
00055 int server_stop(server_t *s);
00056 ppc_t* server_get_ppc(server_t *s);
00057 
00058 int server_get_logger(server_t *s, klog_t **pkl);
00059 int server_foreach_memlog_line(server_t *s, int (*cb)(const char*, void*), 
00060     void *arg);
00061 
00062 #ifdef __cplusplus
00063 }
00064 #endif 
00065 
00066 #endif

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