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 !
The Apache module is taking form.
FooBarWidget (author)
Sat Jan 26 11:13:01 -0800 2008
commit  3d4034b5ae8071b4894008f5c83e0ef8f4c90191
tree    46d76192b7f6c7690c26589b8bb197e59babb043
parent  8e71f9628e877c84c4c0c741c97b3d7a79261633
...
4
5
6
7
8
9
10
...
4
5
6
 
7
8
9
0
@@ -4,7 +4,6 @@ APACHECTL=apache2ctl
0
 all:
0
   $(APXS) -c mod_rails.c
0
 
0
-# XXX should not need the -c option but for some reason it's required :-(
0
 install:
0
   $(APXS) -i -c mod_rails.c
0
 
...
9
10
11
12
13
14
15
16
17
18
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
 
 
 
 
 
 
124
125
126
...
9
10
11
 
 
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
14
15
16
17
18
19
20
21
0
@@ -9,118 +9,13 @@
0
 #include "http_protocol.h"
0
 #include "mpm_common.h"
0
 
0
-#define MOD_RAILS_VERSION "1.0.0"
0
-
0
 module AP_MODULE_DECLARE_DATA rails_module;
0
-
0
-typedef enum {
0
- UNSET,
0
- ENABLED,
0
- DISABLED
0
-} Threeway;
0
-
0
-typedef struct {
0
- Threeway state;
0
-} RailsConfig;
0
-
0
-
0
-static void
0
-log_err(const char *file, int line, request_rec *r,
0
- apr_status_t status, const char *msg)
0
-{
0
- char buf[256] = "";
0
- apr_strerror(status, buf, sizeof(buf));
0
- ap_log_rerror(file, line, APLOG_ERR, status, r, "rails: %s: %s", buf, msg);
0
-}
0
-
0
-static void
0
-log_debug(const char *file, int line, request_rec *r, const
0
- char *msg)
0
-{
0
- ap_log_rerror(file, line, APLOG_ERR, APR_SUCCESS, r, msg);
0
-}
0
-
0
-static RailsConfig *
0
-get_config(request_rec *r) {
0
- return (RailsConfig *) ap_get_module_config(r->per_dir_config, &rails_module);
0
-}
0
-
0
-static int
0
-file_exists(apr_pool_t *pool, const char *filename) {
0
- apr_finfo_t info;
0
- return apr_stat(&info, filename, APR_FINFO_NORM, pool) == APR_SUCCESS;
0
-}
0
-
0
-static int
0
-mod_rails_init(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *base_server) {
0
- ap_add_version_component(p, "mod_rails/" MOD_RAILS_VERSION);
0
- return OK;
0
-}
0
-
0
-/* The main request handler hook function. */
0
-static int
0
-mod_rails_handler(request_rec *r) {
0
- RailsConfig *config = get_config(r);
0
- if (config->state != ENABLED || file_exists(r->pool, r->filename)) {
0
- return DECLINED;
0
- }
0
-
0
- char message[1024];
0
- apr_snprintf(message, sizeof(message), "mod_rails %s, %s, %s", r->uri, r->filename, r->path_info);
0
- log_debug(APLOG_MARK, r, message);
0
- /* TODO */
0
- return DECLINED;
0
-}
0
-
0
-static void *
0
-create_dir_config(apr_pool_t *p, char *dirspec) {
0
- RailsConfig *config = apr_palloc(p, sizeof(RailsConfig));
0
- config->state = UNSET;
0
- return config;
0
-}
0
-
0
-static void *
0
-merge_dir_config(apr_pool_t *p, void *basev, void *newv) {
0
- RailsConfig *config = apr_palloc(p, sizeof(RailsConfig));
0
- RailsConfig *base_config = (RailsConfig *) basev;
0
- RailsConfig *new_config = (RailsConfig *) newv;
0
-
0
- #define MERGE(b, n, a) (n->a == UNSET ? b->a : n->a)
0
- config->state = MERGE(base_config, new_config, state);
0
- return config;
0
-}
0
-
0
-static void *
0
-create_server_config(apr_pool_t *p, server_rec *s) {
0
- return create_dir_config(p, NULL);
0
-}
0
-
0
-static void *
0
-merge_server_config(apr_pool_t *p, void *basev, void *overridesv) {
0
- return merge_dir_config(p, basev, overridesv);
0
-}
0
-
0
-static const char *
0
-cmd_rails_app(cmd_parms* cmd, void* pcfg, int flag) {
0
- RailsConfig *config = (RailsConfig *) pcfg;
0
- if (flag) {
0
- config->state = ENABLED;
0
- } else {
0
- config->state = DISABLED;
0
- }
0
- return NULL;
0
-}
0
-
0
-static const command_rec mod_rails_cmds[] = {
0
- AP_INIT_FLAG("RailsApp", cmd_rails_app, NULL, ACCESS_CONF,
0
- "Set to On to indicate that the DocumentRoot is a Rails application."),
0
- {NULL}
0
-};
0
-
0
-static void mod_rails_register_hooks(apr_pool_t *p) {
0
- ap_hook_post_config(mod_rails_init, NULL, NULL, APR_HOOK_MIDDLE);
0
- ap_hook_handler(mod_rails_handler, NULL, NULL, APR_HOOK_MIDDLE);
0
-}
0
+#define MOD_RAILS_VERSION "1.0.0"
0
+#define INSIDE_MOD_RAILS
0
+#include "types.h"
0
+#include "utils.c"
0
+#include "config.c"
0
+#include "hooks.c"
0
 
0
 /* Dispatch list for API hooks */
0
 module AP_MODULE_DECLARE_DATA rails_module = {
...
116
117
118
119
 
 
120
121
122
123
 
 
 
124
125
126
...
166
167
168
169
170
 
...
116
117
118
 
119
120
121
122
 
 
123
124
125
126
127
128
...
168
169
170
 
171
172
0
@@ -116,11 +116,13 @@ private
0
     @previous_signal_handlers = {}
0
   end
0
 
0
- def handle_spawn_application(app_root, username)
0
+ def handle_spawn_application(app_root, username = nil)
0
+ username = nil if username && username.empty?
0
     app = spawn_application(app_root, username)
0
     @channel.write(app.pid)
0
- @channel.send_io(app.socket)
0
- app.socket.close
0
+ @channel.send_io(app.reader)
0
+ @channel.send_io(app.writer)
0
+ app.close
0
   end
0
   
0
   def cleaner_thread_main
0
@@ -166,4 +168,4 @@ if __FILE__ == $0
0
   spawn_manager.cleanup
0
 end
0
 
0
-end # module ModRails
0
\ No newline at end of file
0
+end # module ModRails

Comments

    No one has commented yet.