~clint-fewbar/ubuntu/precise/squid3/ignore-sighup-early

« back to all changes in this revision

Viewing changes to src/clientStream.cc

  • Committer: Bazaar Package Importer
  • Author(s): Luigi Gangitano
  • Date: 2009-09-24 14:51:06 UTC
  • mfrom: (1.1.12 upstream)
  • mto: (20.2.1 sid)
  • mto: This revision was merged to the branch mainline in revision 21.
  • Revision ID: james.westby@ubuntu.com-20090924145106-38jgrzmj0d73pha5
Tags: 3.1.0.13-1
* Upload to experimental

* New upstream release
  - Fixes Follow-X-Forwarded-For support (Closes: #523943)
  - Adds IPv6 support (Closes: #432351)

* debian/rules
  - Removed obsolete configuration options
  - Enable db and radius basic authentication modules

* debian/patches/01-cf.data.debian
  - Adapted to new upstream version

* debian/patches/02-makefile-defaults
  - Adapted to new upstream version

* debian/{squid.postinst,squid.rc,README.Debian,watch}
  - Updated references to squid 3.1

* debian/squid3.install
  - Install CSS file for error pages
  - Install manual pages for new authentication modules

* debian/squid3-common.install
  - Install documented version of configuration file in /usr/share/doc/squid3

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
 
2
2
/*
3
 
 * $Id: clientStream.cc,v 1.13 2007/04/28 22:26:37 hno Exp $
 
3
 * $Id$
4
4
 *
5
5
 * DEBUG: section 87    Client-side Stream routines.
6
6
 * AUTHOR: Robert Collins
21
21
 *  it under the terms of the GNU General Public License as published by
22
22
 *  the Free Software Foundation; either version 2 of the License, or
23
23
 *  (at your option) any later version.
24
 
 *  
 
24
 *
25
25
 *  This program is distributed in the hope that it will be useful,
26
26
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
27
27
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28
28
 *  GNU General Public License for more details.
29
 
 *  
 
29
 *
30
30
 *  You should have received a copy of the GNU General Public License
31
31
 *  along with thisObject program; if not, write to the Free Software
32
32
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
33
33
 *
34
34
 */
35
35
 
36
 
/*
 
36
#include "squid.h"
 
37
#include "clientStream.h"
 
38
#include "HttpReply.h"
 
39
#include "HttpRequest.h"
 
40
#include "client_side_request.h"
 
41
 
 
42
/**
 
43
 \defgroup ClientStreamInternal Client Streams Internals
 
44
 \ingroup ClientStreamAPI
 
45
 \par
37
46
 * A client Stream is a uni directional pipe, with the usual non-blocking
38
47
 * asynchronous approach present elsewhere in squid.
39
48
 *
 
49
 \par
40
50
 * Each pipe node has a data push function, and a data request function.
41
51
 * This limits flexability - the data flow is no longer assembled at each
42
 
 * step. 
 
52
 * step.
43
53
 *
 
54
 \par
44
55
 * An alternative approach is to pass each node in the pipe the call-
45
 
 * back to use on each IO call. This allows the callbacks to be changed 
46
 
 * very easily by a participating node, but requires more maintenance 
47
 
 * in each node (store the call  back to the msot recent IO request in 
48
 
 * the nodes context.) Such an approach also prevents dynamically 
 
56
 * back to use on each IO call. This allows the callbacks to be changed
 
57
 * very easily by a participating node, but requires more maintenance
 
58
 * in each node (store the callback to the most recent IO request in
 
59
 * the nodes context.) Such an approach also prevents dynamically
49
60
 * changing the pipeline from outside without an additional interface
50
61
 * method to extract the callback and context from the next node.
51
62
 *
 
63
 \par
52
64
 * One important characteristic of the stream is that the readfunc
53
65
 * on the terminating node, and the callback on the first node
54
66
 * will be NULL, and never used.
55
 
 */
56
 
 
57
 
#include "squid.h"
58
 
#include "clientStream.h"
59
 
#include "HttpReply.h"
60
 
#include "HttpRequest.h"
61
 
#include "client_side_request.h"
62
 
 
63
 
CBDATA_TYPE(clientStreamNode);
64
 
 
65
 
/*
66
 
 * TODO: rather than each node undeleting the next, have a clientStreamDelete
67
 
 * that walks the list
68
 
 */
69
 
 
70
 
/*
71
 
 * clientStream quick notes:
72
67
 *
 
68
 \section QuickNotes Quick Notes
 
69
 \par
73
70
 * Each node including the HEAD of the clientStream has a cbdataReference
74
71
 * held by the stream. Freeing the stream then removes that reference
75
 
 * and cbdataFrees every node.
76
 
 * Any node with other References, and all nodes downstream will only 
 
72
 * and cbdataFree()'s every node.
 
73
 * Any node with other References, and all nodes downstream will only
77
74
 * free when those references are released.
78
 
 * Stream nodes MAY hold references to the data member of the node. 
 
75
 * Stream nodes MAY hold references to the data member of the node.
79
76
 *
80
 
 * Specifically - on creation no reference is made. 
 
77
 \par
 
78
 * Specifically - on creation no reference is made.
81
79
 * If you pass a data variable to a node, give it an initial reference.
82
80
 * If the data member is non-null on FREE, cbdataFree WILL be called.
83
81
 * This you must never call cbdataFree on your own context without
84
82
 * explicitly setting the stream node data member to NULL and
85
83
 * cbdataReferenceDone'ing it.
86
84
 *
 
85
 \par
87
86
 * No data member may hold a reference to it's stream node.
88
87
 * The stream guarantees that DETACH will be called before
89
88
 * freeing the node, alowing data members to cleanup.
90
 
 * 
 
89
 *
 
90
 \par
91
91
 * If a node's data holds a reference to something that needs to
92
92
 * free the stream a circular reference list will occur.
93
93
 * This results no data being freed until that reference is removed.
94
94
 * One way to accomplish thisObject is to explicitly remove the
95
95
 * data from your own node before freeing the stream.
96
96
 *
97
 
 * (i.e. 
98
 
 * mycontext = thisObject->data;
99
 
 * thisObject->data = NULL;
100
 
 * clientStreamFree (thisObject->head);
101
 
 * mycontext = NULL;
102
 
 * return;
 
97
 \code
 
98
   mycontext = thisObject->data;
 
99
   thisObject->data = NULL;
 
100
   clientStreamFree (thisObject->head);
 
101
   mycontext = NULL;
 
102
   return;
 
103
 \endcode
 
104
 *
 
105
 \todo rather than each node undeleting the next, have a clientStreamDelete that walks the list.
103
106
 */
104
107
 
 
108
/// \ingroup ClientStreamInternal
 
109
CBDATA_TYPE(clientStreamNode);
 
110
 
 
111
 
105
112
/* Local functions */
106
113
static FREE clientStreamFree;
107
114
 
 
115
/// \ingroup ClientStreamInternal
108
116
clientStreamNode *
109
117
clientStreamNew(CSR * readfunc, CSCB * callback, CSD * detach, CSS * status,
110
118
                ClientStreamData data)
120
128
    return temp;
121
129
}
122
130
 
123
 
/*
 
131
/**
 
132
 \ingroup ClientStreamInternal
124
133
 * Initialise a client Stream.
125
134
 * list is the stream
126
135
 * func is the read function for the head
141
150
    temp->readBuffer = tailBuffer;
142
151
}
143
152
 
144
 
/*
 
153
/**
 
154
 \ingroup ClientStreamInternal
145
155
 * Doesn't actually insert at head. Instead it inserts one *after*
146
156
 * head. This is because HEAD is a special node, as is tail
147
157
 * This function is not suitable for inserting the real HEAD.
165
175
    dlinkAddAfter(cbdataReference(temp), &temp->node, list->head, list);
166
176
}
167
177
 
168
 
/*
169
 
 * Callback the next node the in chain with it's requested data
170
 
 */
 
178
// API
171
179
void
172
180
clientStreamCallback(clientStreamNode * thisObject, ClientHttpRequest * http,
173
181
                     HttpReply * rep, StoreIOBuffer replyBuffer)
176
184
    assert(thisObject && http && thisObject->node.next);
177
185
    next = thisObject->next();
178
186
 
179
 
    debugs(87, 3, "clientStreamCallback: Calling " << next->callback << " with cbdata " << 
 
187
    debugs(87, 3, "clientStreamCallback: Calling " << next->callback << " with cbdata " <<
180
188
           next->data.getRaw() << " from node " << thisObject);
181
189
    next->callback(next, http, rep, replyBuffer);
182
190
}
183
191
 
184
 
/*
 
192
/**
 
193
 \ingroup ClientStreamInternal
185
194
 * Call the previous node in the chain to read some data
 
195
 *
 
196
 \param thisObject      ??
 
197
 \param http            ??
 
198
 \param readBuffer      ??
186
199
 */
187
200
void
188
201
clientStreamRead(clientStreamNode * thisObject, ClientHttpRequest * http,
199
212
    prev->readfunc(prev, http);
200
213
}
201
214
 
202
 
/*
 
215
/**
 
216
 \ingroup ClientStreamInternal
203
217
 * Detach from the stream - only allowed for terminal members
 
218
 *
 
219
 \param thisObject      ??
 
220
 \param http            ??
204
221
 */
205
222
void
206
223
clientStreamDetach(clientStreamNode * thisObject, ClientHttpRequest * http)
238
255
    }
239
256
}
240
257
 
241
 
/*
 
258
/**
 
259
 \ingroup ClientStreamInternal
242
260
 * Abort the stream - detach every node in the pipeline.
 
261
 *
 
262
 \param thisObject      ??
 
263
 \param http            ??
243
264
 */
244
265
void
245
266
clientStreamAbort(clientStreamNode * thisObject, ClientHttpRequest * http)
256
277
    }
257
278
}
258
279
 
259
 
/*
260
 
 * Call the upstream node to find it's status 
 
280
/**
 
281
 \ingroup ClientStreamInternal
 
282
 * Call the upstream node to find it's status
 
283
 *
 
284
 \param thisObject      ??
 
285
 \param http            ??
261
286
 */
262
287
clientStream_status_t
263
288
clientStreamStatus(clientStreamNode * thisObject, ClientHttpRequest * http)
269
294
}
270
295
 
271
296
/* Local function bodies */
 
297
 
272
298
void
273
299
clientStreamNode::removeFromStream()
274
300
{
278
304
    head = NULL;
279
305
}
280
306
 
 
307
/// \ingroup ClientStreamInternal
281
308
void
282
309
clientStreamFree(void *foo)
283
310
{