/[hydra]/hydra/src/queue.c
ViewVC logotype

Contents of /hydra/src/queue.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (show annotations)
Sat Oct 26 20:58:48 2002 UTC (21 years, 5 months ago) by nmav
Branch: MAIN
CVS Tags: hydra_0_1_6_without_hic, hydra_0_0_10, hydra_0_0_9, hydra_0_1_3, hydra_0_1_2, hydra_0_1_1, hydra_0_1_0, hydra_0_1_7, hydra_0_1_6, hydra_0_1_4, hydra_0_1_8, HEAD
Branch point for: hydra_0_1_0_patches
Changes since 1.5: +3 -3 lines
File MIME type: text/plain
Long offsets are not used by default.
Use of pipes instead of temporary files, if the post data sent
are less than PIPE_BUF.

1 /*
2 * Hydra, an http server
3 * Copyright (C) 1995 Paul Phillips <paulp@go2net.com>
4 * Some changes Copyright (C) 1997 Jon Nelson <jnelson@boa.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 1, or (at your option)
9 * any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 */
21
22 /* $Id: queue.c,v 1.5 2002/10/21 19:10:31 nmav Exp $*/
23
24 #include "boa.h"
25 #include "queue.h"
26
27 /*
28 * Name: block_request
29 *
30 * Description: Moves a request from the ready queue to the blocked queue
31 */
32
33 void block_request(server_params* params, request * req)
34 {
35 dequeue(&params->request_ready, req);
36 enqueue(&params->request_block, req);
37
38 if (req->buffer_end) {
39 BOA_FD_SET( req, req->fd, BOA_WRITE);
40 } else {
41 switch (req->status) {
42 case IOSHUFFLE:
43 #ifndef HAVE_SENDFILE
44 if (req->buffer_end - req->buffer_start == 0) {
45 BOA_FD_SET(req, req->data_fd, BOA_READ);
46 break;
47 }
48 #endif
49 case WRITE:
50 case PIPE_WRITE:
51 case DONE:
52 BOA_FD_SET( req, req->fd, BOA_WRITE);
53 break;
54 case PIPE_READ:
55 BOA_FD_SET( req, req->data_fd, BOA_READ);
56 break;
57 case BODY_WRITE:
58 BOA_FD_SET( req, req->post_data_fd.fds[1], BOA_WRITE);
59 break;
60 default:
61 BOA_FD_SET( req, req->fd, BOA_READ);
62 break;
63 }
64 }
65 }
66
67 /*
68 * Name: ready_request
69 *
70 * Description: Moves a request from the blocked queue to the ready queue
71 */
72
73 void ready_request(server_params* params, request * req)
74 {
75 dequeue(&params->request_block, req);
76 enqueue(&params->request_ready, req);
77
78 if (req->buffer_end) {
79 BOA_FD_CLR(req, req->fd, BOA_WRITE);
80 } else {
81 switch (req->status) {
82 case IOSHUFFLE:
83 #ifndef HAVE_SENDFILE
84 if (req->buffer_end - req->buffer_start == 0) {
85 BOA_FD_CLR(req, req->data_fd, BOA_READ);
86 break;
87 }
88 #endif
89 case WRITE:
90 case PIPE_WRITE:
91 case DONE:
92 BOA_FD_CLR(req, req->fd, BOA_WRITE);
93 break;
94 case PIPE_READ:
95 BOA_FD_CLR(req, req->data_fd, BOA_READ);
96 break;
97 case BODY_WRITE:
98 BOA_FD_CLR(req, req->post_data_fd.fds[1], BOA_WRITE);
99 break;
100 default:
101 BOA_FD_CLR(req, req->fd, BOA_READ);
102 }
103 }
104 }
105
106
107 /*
108 * Name: dequeue
109 *
110 * Description: Removes a request from its current queue
111 */
112
113 DEQUEUE_FUNCTION( dequeue, request)
114
115 /*
116 * Name: enqueue
117 *
118 * Description: Adds a request to the head of a queue
119 */
120
121 ENQUEUE_FUNCTION( enqueue, request)
122

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26