00001 00007 /* {{{ Initial headers */ 00008 /* 00009 * $LastChangedDate: 2003-11-27 01:55:17 +0100 (Thu, 27 Nov 2003) $ 00010 * $LastChangedRevision: 5 $ 00011 * $LastChangedBy: ckruse $ 00012 * 00013 */ 00014 /* }}} */ 00015 00016 #ifndef __FO_SERVER_H 00017 #define __FO_SERVER_H 00018 00022 #define SCHEDULING SCHED_OTHER 00023 00027 typedef struct s_posting { 00028 u_int64_t mid; 00030 u_char *unid; 00031 u_int32_t unid_len; 00033 u_char *subject; 00034 u_int32_t subject_len; 00036 u_char *category; 00037 u_int32_t category_len; 00039 u_char *content; 00040 u_int32_t content_len; 00042 time_t date; 00044 u_int16_t level; 00045 u_int16_t invisible; 00048 struct { 00049 u_char *name; 00050 u_char *email; 00051 u_char *hp; 00052 u_char *img; 00053 u_char *ip; 00054 u_int32_t name_len; 00055 u_int32_t email_len; 00056 u_int32_t hp_len; 00057 u_int32_t img_len; 00058 u_int32_t ip_len; 00059 } user; 00060 00061 struct s_posting *next; 00062 struct s_posting *prev; 00063 } t_posting; 00064 00065 00067 typedef struct s_thread { 00068 u_int64_t tid; 00071 t_cf_rwlock lock; 00072 00073 t_posting *postings; 00074 t_posting *newest; 00075 t_posting *oldest; 00076 t_posting *last; 00078 int32_t posts; 00080 struct s_thread *next; 00081 struct s_thread *prev; 00082 } t_thread; 00083 00084 typedef void (*t_worker)(int); 00087 typedef struct s_client { 00088 int sock; 00089 t_worker worker; 00090 struct s_client *next; 00091 } t_client; 00092 00093 #define INITIAL_WORKERS_NUM 40 00094 #define MAX_WORKERS_NUM 45 00095 #define CLIENT_PRIORITY_NUM 43 00096 #define MAX_CLIENT_NUM 45 00099 typedef struct s_client_queque { 00100 t_cf_mutex lock; 00101 t_cf_mutex cond_lock; 00102 pthread_cond_t cond; 00104 u_int32_t workers; 00105 u_int32_t clientnum; 00106 int down; 00108 t_client *clients; 00109 t_client *last; 00110 } t_client_queque; 00111 00113 typedef struct s_server { 00114 int sock; 00115 u_int32_t size; 00116 t_worker worker; 00117 struct sockaddr *addr; 00118 struct s_server *next; 00119 } t_server; 00120 00122 typedef struct s_head { 00124 t_cf_rwlock lock; 00125 00127 pthread_t workers[MAX_WORKERS_NUM]; 00128 00130 int fresh; 00131 00133 t_string cache_visible; 00134 00136 t_string cache_invisible; 00137 00139 time_t date_visible; 00140 00142 time_t date_invisible; 00143 00145 t_thread *thread,*last; 00146 00148 u_int64_t tid; 00149 00151 u_int64_t mid; 00152 00154 int locked; 00155 00157 pthread_mutex_t log_lock; 00158 00160 FILE *std; 00161 00163 FILE *err; 00164 00169 t_client_queque clients; 00170 00174 t_cf_mutex server_lock; 00175 00177 t_server *servers; 00178 00179 #ifdef CF_SHARED_MEM 00180 00181 #define CF_SHARED_MODE (SHM_R|SHM_W|(SHM_R>>3)|(SHM_R>>6)) 00182 00183 int shm_ids[2]; 00184 int shm_sem; 00185 void *shm_ptrs[2]; 00186 t_cf_mutex shm_lock; 00187 #endif 00188 00190 t_cf_hash *protocol_handlers; 00191 00193 t_cf_hash *threads; 00194 00196 t_cf_rwlock threads_lock; 00197 } t_head; 00198 00199 extern int RUN; 00200 extern t_head head; 00206 void terminate(int n); 00207 00208 typedef int (*t_server_protocol_handler)(int,const u_char **,int,rline_t *); 00209 typedef int (*t_server_init_filter)(int); 00211 #endif 00212 00213 /* eof */
1.3.5