We got nominated! Help us out and vote for GitHub as Best Bootstrapped Startup of 2008. (You can vote once a day.) [ hide ]

public
Description: Phusion Passenger (mod_rails)
Homepage: http://www.modrails.com/
Clone URL: git://github.com/FooBarWidget/passenger.git
Click here to lend your support to: passenger and make a donation at www.pledgie.com !
Fix line terminators.
Hongli Lai (Phusion) (author)
Wed Sep 24 10:18:43 -0700 2008
commit  a9db36774fd478b0540693c64749e3531d777734
tree    7648562eb124eec9e73427b67fcb0f3a3262ae8a
parent  5bd3feb01e1ba43a479d4e3d4895b00e16b44e91
...
19
20
21
22
 
23
24
 
25
26
27
28
29
30
31
32
33
 
 
 
 
 
 
 
34
35
36
37
38
39
40
 
 
 
 
 
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
79
80
81
82
83
84
 
 
 
 
 
85
86
87
88
89
90
91
92
93
 
 
 
 
 
 
 
 
94
95
 
96
97
98
99
100
101
102
103
 
 
 
 
 
 
104
...
19
20
21
 
22
23
 
24
25
26
 
 
 
 
 
 
 
27
28
29
30
31
32
33
34
35
 
 
 
 
 
36
37
38
39
40
41
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
 
 
 
 
 
80
81
82
83
84
85
 
 
 
 
 
 
 
 
86
87
88
89
90
91
92
93
94
 
95
96
97
 
 
 
 
 
 
98
99
100
101
102
103
104
0
@@ -19,86 +19,86 @@
0
  */
0
 #include "Bucket.h"
0
 
0
-static apr_status_t bucket_read(apr_bucket *a, const char **str, apr_size_t *len, apr_read_type_e block);
0
+static apr_status_t bucket_read(apr_bucket *a, const char **str, apr_size_t *len, apr_read_type_e block);
0
 
0
-static const apr_bucket_type_t apr_bucket_type_passenger_pipe = {
0
+static const apr_bucket_type_t apr_bucket_type_passenger_pipe = {
0
   "PASSENGER_PIPE",
0
   5,
0
- apr_bucket_type_t::APR_BUCKET_DATA,
0
- apr_bucket_destroy_noop,
0
- bucket_read,
0
- apr_bucket_setaside_notimpl,
0
- apr_bucket_split_notimpl,
0
- apr_bucket_copy_notimpl
0
-};
0
+ apr_bucket_type_t::APR_BUCKET_DATA,
0
+ apr_bucket_destroy_noop,
0
+ bucket_read,
0
+ apr_bucket_setaside_notimpl,
0
+ apr_bucket_split_notimpl,
0
+ apr_bucket_copy_notimpl
0
+};
0
 
0
 static apr_status_t
0
-bucket_read(apr_bucket *bucket, const char **str, apr_size_t *len, apr_read_type_e block) {
0
- apr_file_t *pipe;
0
- char *buf;
0
- apr_status_t ret;
0
- apr_interval_time_t timeout;
0
+bucket_read(apr_bucket *bucket, const char **str, apr_size_t *len, apr_read_type_e block) {
0
+ apr_file_t *pipe;
0
+ char *buf;
0
+ apr_status_t ret;
0
+ apr_interval_time_t timeout;
0
 
0
- pipe = (apr_file_t *) bucket->data;
0
- if (block == APR_NONBLOCK_READ) {
0
- apr_file_pipe_timeout_get(pipe, &timeout);
0
- apr_file_pipe_timeout_set(pipe, 0);
0
- }
0
-
0
- *str = NULL;
0
- *len = APR_BUCKET_BUFF_SIZE;
0
- buf = (char *) apr_bucket_alloc(*len, bucket->list); // TODO: check for failure?
0
-
0
- ret = apr_file_read(pipe, buf, len);
0
- if (block == APR_NONBLOCK_READ) {
0
- apr_file_pipe_timeout_set(pipe, timeout);
0
- }
0
-
0
- if (ret != APR_SUCCESS && ret != APR_EOF) {
0
+ pipe = (apr_file_t *) bucket->data;
0
+ if (block == APR_NONBLOCK_READ) {
0
+ apr_file_pipe_timeout_get(pipe, &timeout);
0
+ apr_file_pipe_timeout_set(pipe, 0);
0
+ }
0
+
0
+ *str = NULL;
0
+ *len = APR_BUCKET_BUFF_SIZE;
0
+ buf = (char *) apr_bucket_alloc(*len, bucket->list); // TODO: check for failure?
0
+
0
+ ret = apr_file_read(pipe, buf, len);
0
+ if (block == APR_NONBLOCK_READ) {
0
+ apr_file_pipe_timeout_set(pipe, timeout);
0
+ }
0
+
0
+ if (ret != APR_SUCCESS && ret != APR_EOF) {
0
     // ... we might want to set an error flag here ...
0
- apr_bucket_free(buf);
0
- return ret;
0
- }
0
- /*
0
- * If there's more to read we have to keep the rest of the pipe
0
- * for later.
0
- */
0
- if (*len > 0) {
0
- apr_bucket_heap *h;
0
- /* Change the current bucket to refer to what we read */
0
- bucket = apr_bucket_heap_make(bucket, buf, *len, apr_bucket_free);
0
- h = (apr_bucket_heap *) bucket->data;
0
- h->alloc_len = APR_BUCKET_BUFF_SIZE; /* note the real buffer size */
0
- *str = buf;
0
- APR_BUCKET_INSERT_AFTER(bucket, passenger_bucket_create(pipe, bucket->list));
0
- } else {
0
- apr_bucket_free(buf);
0
- bucket = apr_bucket_immortal_make(bucket, "", 0);
0
- *str = (const char *) bucket->data;
0
+ apr_bucket_free(buf);
0
+ return ret;
0
+ }
0
+ /*
0
+ * If there's more to read we have to keep the rest of the pipe
0
+ * for later.
0
+ */
0
+ if (*len > 0) {
0
+ apr_bucket_heap *h;
0
+ /* Change the current bucket to refer to what we read */
0
+ bucket = apr_bucket_heap_make(bucket, buf, *len, apr_bucket_free);
0
+ h = (apr_bucket_heap *) bucket->data;
0
+ h->alloc_len = APR_BUCKET_BUFF_SIZE; /* note the real buffer size */
0
+ *str = buf;
0
+ APR_BUCKET_INSERT_AFTER(bucket, passenger_bucket_create(pipe, bucket->list));
0
+ } else {
0
+ apr_bucket_free(buf);
0
+ bucket = apr_bucket_immortal_make(bucket, "", 0);
0
+ *str = (const char *) bucket->data;
0
     // if (rv != APR_EOF) {
0
     // ... we might want to set an error flag here ...
0
- // }
0
- }
0
- return APR_SUCCESS;
0
-}
0
-
0
+ // }
0
+ }
0
+ return APR_SUCCESS;
0
+}
0
+
0
 apr_bucket *
0
-passenger_bucket_make(apr_bucket *bucket, apr_file_t *pipe) {
0
- bucket->type = &apr_bucket_type_passenger_pipe;
0
- bucket->length = (apr_size_t)(-1);
0
- bucket->start = -1;
0
- bucket->data = pipe;
0
- return bucket;
0
-}
0
-
0
+passenger_bucket_make(apr_bucket *bucket, apr_file_t *pipe) {
0
+ bucket->type = &apr_bucket_type_passenger_pipe;
0
+ bucket->length = (apr_size_t)(-1);
0
+ bucket->start = -1;
0
+ bucket->data = pipe;
0
+ return bucket;
0
+}
0
+
0
 apr_bucket *
0
-passenger_bucket_create(apr_file_t *pipe, apr_bucket_alloc_t *list) {
0
+passenger_bucket_create(apr_file_t *pipe, apr_bucket_alloc_t *list) {
0
   apr_bucket *bucket;
0
   
0
- bucket = (apr_bucket *) apr_bucket_alloc(sizeof(*bucket), list);
0
- APR_BUCKET_INIT(bucket);
0
- bucket->free = apr_bucket_free;
0
- bucket->list = list;
0
- return passenger_bucket_make(bucket, pipe);
0
-}
0
+ bucket = (apr_bucket *) apr_bucket_alloc(sizeof(*bucket), list);
0
+ APR_BUCKET_INIT(bucket);
0
+ bucket->free = apr_bucket_free;
0
+ bucket->list = list;
0
+ return passenger_bucket_make(bucket, pipe);
0
+}
0
 

Comments

    No one has commented yet.