Change char *ipv4 for mk_pointer ipv4 in sched_connection. Fix all the code to use...
[MonkeyD.git] / src / include / scheduler.h
blobb193ceb77f2e7e13938430ec4d59b759b1ac155f
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 /* Monkey HTTP Daemon
4 * ------------------
5 * Copyright (C) 2008, Eduardo Silva P.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Library General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 #ifndef MK_SCHEDULER_H
23 #define MK_SCHEDULER_H
25 #define MK_SCHEDULER_ACTIVE_NONE 0
26 #define MK_SCHEDULER_ACTIVE_UP 1
27 #define MK_SCHEDULER_ACTIVE_DOWN -1
29 #define MK_SCHEDULER_CLOSED_NONE 0
30 #define MK_SCHEDULER_CLOSED_UP 1
31 #define MK_SCHEDULER_CLOSED_DOWN -1
33 #define MK_SCHEDULER_CONN_AVAILABLE -1
34 #define MK_SCHEDULER_CONN_PENDING 0
35 #define MK_SCHEDULER_CONN_PROCESS 1
38 struct sched_connection
40 int socket;
41 int status;
42 mk_pointer ipv4;
43 time_t arrive_time;
46 /* Global struct */
47 struct sched_list_node
49 short int idx;
50 pthread_t tid;
51 pid_t pid;
52 int epoll_fd;
53 int active_requests;
54 int closed_requests;
55 struct sched_connection *queue;
56 struct client_request *request_handler;
57 struct sched_list_node *next;
61 struct sched_list_node *sched_list;
63 /* Struct under thread context */
64 typedef struct
66 int epoll_fd;
67 int max_events;
68 } sched_thread_conf;
70 pthread_key_t epoll_fd;
72 int mk_sched_register_thread(pthread_t tid, int epoll_fd);
73 int mk_sched_launch_thread(int max_events);
74 void *mk_sched_launch_epoll_loop(void *thread_conf);
75 struct sched_list_node *mk_sched_get_handler_owner();
76 struct request_idx *mk_sched_get_request_index();
77 void mk_sched_set_request_index(struct request_idx *ri);
79 int mk_sched_get_thread_poll();
80 void mk_sched_set_thread_poll(int epoll);
82 struct sched_list_node *mk_sched_get_thread_conf();
83 void mk_sched_update_thread_status(struct sched_list_node *sched,
84 int active, int closed);
87 int mk_sched_check_timeouts(struct sched_list_node *sched);
88 int mk_sched_add_client(struct sched_list_node *sched, int remote_fd);
89 int mk_sched_remove_client(struct sched_list_node *sched, int remote_fd);
90 struct sched_connection *mk_sched_get_connection(struct sched_list_node
91 *sched, int remote_fd);
92 int mk_sched_update_conn_status(struct sched_list_node *sched, int remote_fd,
93 int status);
95 #endif