webroar 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG ADDED
@@ -0,0 +1,25 @@
1
+ v0.2.4 - 01-Dec-2009
2
+ --------------------
3
+
4
+ * Fixed intermittent crash issue in head while closing client connections
5
+ by calling close_connection() directly rather than running it through
6
+ goodbye_watcher in libebb.
7
+ * Renamed on_error callback (introduced by us in libebb) to the more
8
+ appropriate on_request_parse_error.
9
+ * Fixed install issue on ruby 1.9 caused due to invalid multibyte char.
10
+ * Fixed the incorrect month value in the file name format for gcore dumps.
11
+ * Initialized logging for the worker right as it is instantiated before
12
+ it connects to head process.
13
+ * Cleaned up wr_wkr_create() method in head/wr_worker.c.
14
+ * Print logging level as a string in the log files.
15
+ * Fixed invalid pointer being used in 'wr_req_resolve_http_req' function.
16
+ * Fixed creation of rack.input stream object. Resolves Ticket #2 related to
17
+ error seen on posting form with enctype="multipart/form-data".
18
+ * Ensured 'starling-starling' gem is used by WebROaR even is 'starling' is
19
+ present on the system.
20
+
21
+ v0.2.3 - 25-Nov-2009
22
+ ---------------------
23
+
24
+ * First cut for public.
25
+
@@ -46,7 +46,7 @@ module Webroar
46
46
  puts "found."
47
47
  gem_name = "WebROaR-" + gem_list[gem_list.length - 1].to_s
48
48
  require File.join(WEBROAR_ROOT, 'src', 'ruby_lib', 'ruby_interface','version.rb')
49
- choice_list = [ "Import configuration, logs and admin panel data from the previous installation #{gem_name}.",
49
+ choice_list = ["Import configuration, logs and admin panel data from the previous installation - #{gem_name}.",
50
50
  "No import required, install #{Webroar::SERVER} afresh."]
51
51
 
52
52
  puts ""
@@ -260,13 +260,18 @@ void wr_app_print(wr_app_t*app) {
260
260
  /** Create worker for application */
261
261
  int wr_app_wkr_add(wr_app_t *app) {
262
262
  if(app->pending_wkr < WR_MAX_PENDING_WKR) {
263
- app->pending_wkr++;
264
- app->high_ratio = TOTAL_WORKER_COUNT(app) * WR_MAX_REQ_RATIO;
265
- app->last_wkr_pid[app->pending_wkr-1] = wr_wkr_create(app->svr, app->conf);
266
- ev_timer_again(app->svr->ebb_svr.loop, &app->t_add_timeout);
267
- LOG_INFO("PID of created worker = %d, Rails application=%s, ",
263
+ int retval = wr_wkr_create(app->svr, app->conf);
264
+ if(retval > 0){
265
+ app->pending_wkr++;
266
+ app->high_ratio = TOTAL_WORKER_COUNT(app) * WR_MAX_REQ_RATIO;
267
+ app->last_wkr_pid[app->pending_wkr-1] = retval;
268
+ ev_timer_again(app->svr->ebb_svr.loop, &app->t_add_timeout);
269
+ LOG_INFO("PID of created worker = %d, Rails application=%s, ",
268
270
  app->last_wkr_pid[app->pending_wkr-1],app->conf->path.str);
269
- return 0;
271
+ return 0;
272
+ }else{
273
+ LOG_ERROR(SEVERE,"Could not fork process to start new worker.");
274
+ }
270
275
  }
271
276
  return -1;
272
277
  }
data/src/head/wr_config.h CHANGED
@@ -81,7 +81,7 @@
81
81
  // File to store Server process id
82
82
  #define WR_PID_FILE "/var/run/webroar.pid"
83
83
  #define WR_SERVER "WebROaR"
84
- #define WR_VERSION "0.2.3"
84
+ #define WR_VERSION "0.2.4"
85
85
  #define WR_MIME_TYPE_PATH "/conf/mime_type.yml"
86
86
  #define WR_CONF_PATH "/conf/config.yml"
87
87
  #define WR_SERVER_INTERNAL_CONF_PATH "/conf/server_internal_config.yml"
@@ -101,7 +101,7 @@ void wr_conn_after_write_cb(ebb_connection *connection) {
101
101
  }
102
102
 
103
103
  /** The connection got parser error */
104
- void wr_conn_err_cb(ebb_connection* connection) {
104
+ void wr_req_parse_err_cb(ebb_connection* connection) {
105
105
  LOG_FUNCTION
106
106
 
107
107
  wr_conn_t* conn = (wr_conn_t*)connection->data;
@@ -183,7 +183,7 @@ wr_conn_t* wr_conn_new(wr_svr_t *server) {
183
183
  connection->new_request = wr_new_req_cb;
184
184
  connection->on_close = wr_conn_close_cb;
185
185
  connection->on_timeout = wr_conn_timeout_cb;
186
- connection->on_error = wr_conn_err_cb;
186
+ connection->on_request_parse_error = wr_req_parse_err_cb;
187
187
 
188
188
  return a_connection;
189
189
  }
data/src/head/wr_main.c CHANGED
@@ -222,7 +222,6 @@ int main(int argc, char *argv[]) {
222
222
  #ifdef L_DEBUG
223
223
  set_log_severity(DEBUG);
224
224
  #else
225
-
226
225
  set_log_severity(conf->server->log_level);
227
226
  #endif
228
227
  // Add Admin Panel
@@ -244,7 +244,7 @@ int wr_req_resolve_http_req(wr_svr_t *server, wr_req_t *req) {
244
244
  }
245
245
  }
246
246
  /* resolve host name */
247
- if(app == NULL) {
247
+ if(app == NULL && server->resolver->hosts) {
248
248
  scgi_header_t *http_host = scgi_header_get(req->scgi, "HTTP_HOST");
249
249
  if(http_host) {
250
250
  wr_str_t host_str;
@@ -252,7 +252,7 @@ int wr_req_resolve_http_req(wr_svr_t *server, wr_req_t *req) {
252
252
  char *value = req->scgi->header + http_host->value_offset;
253
253
 
254
254
  //removing port
255
- char *ptr = memchr(http_host, ':', http_host->value_length);
255
+ char *ptr = memchr(value, ':', http_host->value_length);
256
256
  if(ptr) {
257
257
  wr_string_new(host_str, value, ptr - value);
258
258
  } else {
data/src/head/wr_worker.c CHANGED
@@ -561,7 +561,6 @@ int wr_wkr_create(wr_svr_t *server, wr_app_conf_t *app_conf) {
561
561
  pid = fork();
562
562
  LOG_DEBUG(DEBUG,"Forked PID is %i, uid = %s, gid =%s, app = %s",pid, cuid_s, cgid_s, app_conf->name.str) ;
563
563
  if (pid == 0) {
564
- if (pid == 0) {
565
564
  LOG_DEBUG(3,"Child is continuing %i",pid);
566
565
  setsid();
567
566
  int i = 0;
@@ -605,17 +604,6 @@ int wr_wkr_create(wr_svr_t *server, wr_app_conf_t *app_conf) {
605
604
  fflush(stderr);
606
605
  _exit(1);
607
606
  }
608
-
609
- } else if (pid == -1) {
610
- wr_string_free(baseuri);
611
- perror("Cannot fork a new process");
612
- LOG_ERROR(5,"Cannot fork a new process");
613
- fflush(stderr);
614
- _exit(1);
615
- } else {
616
- wr_string_free(baseuri);
617
- _exit(0);
618
- }
619
607
  } else if (pid == -1) {
620
608
  wr_string_free(baseuri);
621
609
  LOG_ERROR(5,"Cannot fork a new process %i", errno);
@@ -624,7 +612,7 @@ int wr_wkr_create(wr_svr_t *server, wr_app_conf_t *app_conf) {
624
612
  //Temporary Hack
625
613
  return pid;
626
614
  }
627
- return 0;
615
+ return -1;
628
616
  }
629
617
 
630
618
  /** Request callback called by ebb Request*/
@@ -137,6 +137,18 @@ void a_error(LOG_SEVERITY level, const char *file_name, int line_no, const char
137
137
  }
138
138
  }
139
139
 
140
+ /** Get log level string */
141
+ char* get_log_level_string(LOG_SEVERITY level){
142
+ switch(level){
143
+ case DEBUG: return "DEBUG";
144
+ case INFO: return "INFO";
145
+ case WARN: return "WARN";
146
+ case SEVERE: return "SEVERE";
147
+ case FATAL: return "FATAL";
148
+ default: "Unknown";
149
+ }
150
+ }
151
+
140
152
  /** Get logging severity */
141
153
  LOG_SEVERITY get_log_severity(const char*str) {
142
154
  if(strcmp(str,"DEBUG") == 0) {
@@ -163,6 +175,6 @@ int change_log_file_owner(int user_id, int group_id) {
163
175
 
164
176
  /** Set logging level */
165
177
  int set_log_severity(int severity) {
166
- LOG_INFO("setting log level to %d",severity);
178
+ LOG_INFO("setting log level to %s", get_log_level_string(severity));
167
179
  logging_level = severity;
168
180
  }
data/src/helper/wr_util.c CHANGED
@@ -158,6 +158,6 @@ int get_timestamp(char *str) {
158
158
  LOG_ERROR(SEVERE, "Error detected in localtime()");
159
159
  return -1;
160
160
  }
161
- sprintf(str, "%d-%d-%d-%d-%d-%d", tm_struct->tm_year + 1900, tm_struct->tm_mon, tm_struct->tm_mday, tm_struct->tm_hour, tm_struct->tm_min, tm_struct->tm_sec);
161
+ sprintf(str, "%d-%d-%d-%d-%d-%d", tm_struct->tm_year + 1900, tm_struct->tm_mon + 1, tm_struct->tm_mday, tm_struct->tm_hour, tm_struct->tm_min, tm_struct->tm_sec);
162
162
  return 0;
163
163
  }
@@ -16,6 +16,7 @@
16
16
  # You should have received a copy of the GNU General Public License
17
17
  # along with WebROaR. If not, see <http://www.gnu.org/licenses/>.
18
18
 
19
+ gem 'starling-starling', '>=0.10.0'
19
20
  require 'starling'
20
21
 
21
22
  module Webroar
@@ -17,6 +17,7 @@
17
17
  # along with WebROaR. If not, see <http://www.gnu.org/licenses/>.
18
18
 
19
19
  require 'singleton'
20
+ gem 'starling-starling', '>=0.10.0'
20
21
  require 'starling'
21
22
  require 'yaml'
22
23
  module Webroar
@@ -24,18 +24,17 @@ module Webroar
24
24
  @client = client
25
25
  end
26
26
 
27
- def read(len = nil)
27
+ def read(len = nil, s = '')
28
28
  if @io
29
29
  @io.read(len)
30
30
  else
31
- if len.nil?
32
- s = ''
31
+ if len.nil?
33
32
  while(chunk = read(10*1024))
34
33
  s << chunk
35
34
  end
36
35
  s
37
36
  else
38
- Webroar::read_request(@client, len)
37
+ s = Webroar::read_request(@client, len)
39
38
  end
40
39
  end
41
40
  end
@@ -21,7 +21,7 @@ module Webroar
21
21
  module VERSION #:nodoc:
22
22
  MAJOR = "0"
23
23
  MINOR = "2"
24
- TINY = "3"
24
+ TINY = "4"
25
25
 
26
26
  STRING = [MAJOR, MINOR, TINY].join('.')
27
27
  end
@@ -322,8 +322,8 @@ on_readable(struct ev_loop *loop, ev_io *watcher, int revents)
322
322
  /* parse error? just drop the client. screw the 400 response */
323
323
  // if(ebb_request_parser_has_error(&connection->parser)) goto error;
324
324
  if(ebb_request_parser_has_error(&connection->parser)){
325
- if(connection->on_error){
326
- connection->on_error(connection);
325
+ if(connection->on_request_parse_error){
326
+ connection->on_request_parse_error(connection);
327
327
  }else{
328
328
  ebb_connection_schedule_close(connection);
329
329
  }
@@ -756,7 +756,7 @@ ebb_connection_init(ebb_connection *connection)
756
756
  connection->new_request = NULL;
757
757
  connection->on_timeout = NULL;
758
758
  connection->on_close = NULL;
759
- connection->on_error = NULL;
759
+ connection->on_request_parse_error = NULL;
760
760
  connection->data = NULL;
761
761
  }
762
762
 
@@ -770,7 +770,11 @@ ebb_connection_schedule_close (ebb_connection *connection)
770
770
  return;
771
771
  }
772
772
  #endif
773
- ev_timer_start(connection->server->loop, &connection->goodbye_watcher);
773
+ //ev_timer_start(connection->server->loop, &connection->goodbye_watcher);
774
+ // Why do we need to start a timer which would to execute after 0. second?
775
+ // Looks timer is creating problem(not able to reproduce it on development machine) like
776
+ // few time its giving on_goodbye callback twice and causing server crash
777
+ close_connection(connection);
774
778
  }
775
779
 
776
780
  /*
@@ -100,7 +100,7 @@ struct ebb_connection {
100
100
 
101
101
  void (*on_close) (ebb_connection*);
102
102
 
103
- void (*on_error) (ebb_connection*);
103
+ void (*on_request_parse_error) (ebb_connection*);
104
104
 
105
105
  void *data;
106
106
  };
@@ -148,7 +148,7 @@ static inline wkr_tmp_t* parse_args(int argc, char **argv) {
148
148
  extern char *optarg;
149
149
  size_t len;
150
150
  char *str;
151
- int invalid_arg_flag = 0, app_path_flag = 0;
151
+ int invalid_arg_flag = 0, app_path_flag = 0, log_level = INFO;
152
152
  wkr_tmp_t *tmp = wkr_tmp_new();
153
153
 
154
154
  if(tmp == NULL)
@@ -171,14 +171,7 @@ static inline wkr_tmp_t* parse_args(int argc, char **argv) {
171
171
  wr_string_new(tmp->env, str, len);
172
172
  break;
173
173
  case 'l': // Logging level
174
- #ifdef L_DEBUG
175
-
176
- set_log_severity(DEBUG);
177
- #else
178
-
179
- set_log_severity(atoi(optarg));
180
- #endif
181
-
174
+ log_level = atoi(optarg);
182
175
  break;
183
176
  case 'f': // Log file name
184
177
  wr_string_free(tmp->log_file);
@@ -227,8 +220,21 @@ static inline wkr_tmp_t* parse_args(int argc, char **argv) {
227
220
  invalid_arg_flag++;
228
221
  }
229
222
  }
230
- if (invalid_arg_flag>0 || app_path_flag == 0) {
223
+
224
+ if(tmp->log_file.str){
225
+ initialize_logger(tmp->log_file.str);
226
+ #ifdef L_DEBUG
227
+ set_log_severity(DEBUG);
228
+ #else
229
+ set_log_severity(log_level);
230
+ #endif
231
+ }else{
232
+ perror("Log file is not specified.");
233
+ }
234
+
235
+ if (invalid_arg_flag > 0 || app_path_flag == 0) {
231
236
  print_usage(argv[0]);
237
+ LOG_ERROR(SEVERE, "Either argument is invalid or application path is not passed.");
232
238
  wkr_tmp_free(&tmp);
233
239
  return NULL;
234
240
  }
@@ -277,7 +283,7 @@ int main(int argc, char **argv) {
277
283
  int port, retval = 0;
278
284
  wkr_t* w = NULL;
279
285
 
280
- if(argc==1) {
286
+ if(argc == 1) {
281
287
  print_usage(argv[0]);
282
288
  return -1;
283
289
  }
@@ -289,18 +295,15 @@ int main(int argc, char **argv) {
289
295
  // signal(SIGFPE, crash_handler);
290
296
 
291
297
  wkr_tmp_t *tmp = parse_args(argc, argv);
292
-
293
298
  if(tmp == NULL)
294
299
  return -1;
295
-
300
+
296
301
  loop = ev_default_loop (0);
302
+
297
303
  w = worker_new(loop, tmp);
298
304
  if(w==NULL)
299
305
  goto err;
300
306
  worker = w;
301
- // assert(w!=NULL);
302
-
303
- initialize_logger(w->tmp->log_file.str);
304
307
  redirect_standard_io();
305
308
 
306
309
  LOG_DEBUG(DEBUG,"control path = %s, Application baseuri = %s",
data/tasks/gem.rake CHANGED
@@ -54,7 +54,7 @@ spec = Gem::Specification.new do |s|
54
54
  s.add_dependency 'starling-starling', '>=0.10.0'
55
55
 
56
56
  s.files = FileList['Rakefile',
57
- # 'CHANGELOG',
57
+ 'CHANGELOG',
58
58
  'COPYING',
59
59
  File.join('bin', 'webroar'),
60
60
  File.join('bin', 'webroar-analyzer'),