3 * Copyright (C) 2008, Eduardo Silva P.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Library General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 #include "conn_switch.h"
26 int mk_conn_switch_read(int socket
)
30 ret
= mk_handler_read(socket
);
34 int mk_conn_switch_write(int socket
)
37 struct client_request
*cr
;
39 /* Get node from schedule list node which contains
40 * the information regarding to the current client/socket
42 cr
= mk_get_client_request_from_fd(socket
);
49 ret
= mk_handler_write(socket
, cr
);
50 ka
= mk_http_keepalive_check(socket
, cr
);
52 /* if ret < 0, means that some error
53 * happened in the writer call, in the
54 * other hand, 0 means a successful request
55 * processed, if ret > 0 means that some data
56 * still need to be send.
61 free_list_requests(cr
);
63 /* We need to ask to http_keepalive if this
64 * connection can continue working or we must
70 mk_remove_client_request(socket
);
74 memset(cr
->body
, '\0', sizeof(cr
->body
));
76 cr
->counter_connections
++;
77 efd
= mk_sched_get_thread_poll();
78 mk_epoll_socket_change_mode(efd
, socket
, MK_EPOLL_READ
);
87 /* avoid to make gcc cry :_( */
91 int mk_conn_switch(int action
, int socket
)
97 case MK_CONN_SWITCH_READ
:
98 status
= mk_conn_switch_read(socket
);
100 case MK_CONN_SWITCH_WRITE
:
101 status
= mk_conn_switch_write(socket
);