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.2 2002/09/28 10:05:00 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(¶ms->request_ready, req); |
36 |
enqueue(¶ms->request_block, req); |
37 |
|
38 |
if (req->buffer_end) { |
39 |
BOA_FD_SET(req->fd, ¶ms->block_write_fdset); |
40 |
} else { |
41 |
switch (req->status) { |
42 |
case WRITE: |
43 |
case PIPE_WRITE: |
44 |
case DONE: |
45 |
BOA_FD_SET(req->fd, ¶ms->block_write_fdset); |
46 |
break; |
47 |
case PIPE_READ: |
48 |
BOA_FD_SET(req->data_fd, ¶ms->block_read_fdset); |
49 |
break; |
50 |
case BODY_WRITE: |
51 |
BOA_FD_SET(req->post_data_fd, ¶ms->block_write_fdset); |
52 |
break; |
53 |
default: |
54 |
BOA_FD_SET(req->fd, ¶ms->block_read_fdset); |
55 |
break; |
56 |
} |
57 |
} |
58 |
} |
59 |
|
60 |
/* |
61 |
* Name: ready_request |
62 |
* |
63 |
* Description: Moves a request from the blocked queue to the ready queue |
64 |
*/ |
65 |
|
66 |
void ready_request(server_params* params, request * req) |
67 |
{ |
68 |
dequeue(¶ms->request_block, req); |
69 |
enqueue(¶ms->request_ready, req); |
70 |
|
71 |
if (req->buffer_end) { |
72 |
FD_CLR(req->fd, ¶ms->block_write_fdset); |
73 |
} else { |
74 |
switch (req->status) { |
75 |
case WRITE: |
76 |
case PIPE_WRITE: |
77 |
case DONE: |
78 |
FD_CLR(req->fd, ¶ms->block_write_fdset); |
79 |
break; |
80 |
case PIPE_READ: |
81 |
FD_CLR(req->data_fd, ¶ms->block_read_fdset); |
82 |
break; |
83 |
case BODY_WRITE: |
84 |
FD_CLR(req->post_data_fd, ¶ms->block_write_fdset); |
85 |
break; |
86 |
default: |
87 |
FD_CLR(req->fd, ¶ms->block_read_fdset); |
88 |
} |
89 |
} |
90 |
} |
91 |
|
92 |
|
93 |
/* |
94 |
* Name: dequeue |
95 |
* |
96 |
* Description: Removes a request from its current queue |
97 |
*/ |
98 |
|
99 |
DEQUEUE_FUNCTION( dequeue, request) |
100 |
|
101 |
/* |
102 |
* Name: enqueue |
103 |
* |
104 |
* Description: Adds a request to the head of a queue |
105 |
*/ |
106 |
|
107 |
ENQUEUE_FUNCTION( enqueue, request) |
108 |
|