Create a CGI bucket using pipes from script stdout 'out' * and stderr 'err', for request 'r'. */
| 235 | /* Create a CGI bucket using pipes from script stdout 'out' |
| 236 | * and stderr 'err', for request 'r'. */ |
| 237 | static apr_bucket *cgi_bucket_create(request_rec *r, |
| 238 | apr_interval_time_t timeout, |
| 239 | apr_file_t *out, apr_file_t *err, |
| 240 | apr_bucket_alloc_t *list) |
| 241 | { |
| 242 | apr_bucket *b = apr_bucket_alloc(sizeof(*b), list); |
| 243 | apr_status_t rv; |
| 244 | apr_pollfd_t fd; |
| 245 | struct cgi_bucket_data *data = apr_palloc(r->pool, sizeof *data); |
| 246 | |
| 247 | /* Disable APR timeout handling since we'll use poll() entirely. */ |
| 248 | apr_file_pipe_timeout_set(out, 0); |
| 249 | apr_file_pipe_timeout_set(err, 0); |
| 250 | |
| 251 | APR_BUCKET_INIT(b); |
| 252 | b->free = apr_bucket_free; |
| 253 | b->list = list; |
| 254 | b->type = &bucket_type_cgi; |
| 255 | b->length = (apr_size_t)(-1); |
| 256 | b->start = -1; |
| 257 | |
| 258 | /* Create the pollset */ |
| 259 | rv = apr_pollset_create(&data->pollset, 2, r->pool, 0); |
| 260 | if (rv != APR_SUCCESS) { |
| 261 | ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01217) |
| 262 | "apr_pollset_create(); check system or user limits"); |
| 263 | return NULL; |
| 264 | } |
| 265 | |
| 266 | fd.desc_type = APR_POLL_FILE; |
| 267 | fd.reqevents = APR_POLLIN; |
| 268 | fd.p = r->pool; |
| 269 | fd.desc.f = out; /* script's stdout */ |
| 270 | fd.client_data = (void *)1; |
| 271 | rv = apr_pollset_add(data->pollset, &fd); |
| 272 | if (rv != APR_SUCCESS) { |
| 273 | ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01218) |
| 274 | "apr_pollset_add(); check system or user limits"); |
| 275 | return NULL; |
| 276 | } |
| 277 | |
| 278 | fd.desc.f = err; /* script's stderr */ |
| 279 | fd.client_data = (void *)2; |
| 280 | rv = apr_pollset_add(data->pollset, &fd); |
| 281 | if (rv != APR_SUCCESS) { |
| 282 | ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01219) |
| 283 | "apr_pollset_add(); check system or user limits"); |
| 284 | return NULL; |
| 285 | } |
| 286 | |
| 287 | data->r = r; |
| 288 | data->timeout = timeout; |
| 289 | b->data = data; |
| 290 | return b; |
| 291 | } |
| 292 | |
| 293 | /* Create a duplicate CGI bucket using given bucket data */ |
| 294 | static apr_bucket *cgi_bucket_dup(struct cgi_bucket_data *data, |
no outgoing calls
no test coverage detected