Skip to content

Commit

Permalink
Got JRuby parser compiling. Still not parsing request...
Browse files Browse the repository at this point in the history
  • Loading branch information
macournoyer committed May 6, 2009
1 parent cf117fd commit fd7b949
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ ext/thin_parser/*.obj
ext/thin_parser/*mswin32*
ext/thin_parser/vc60.pdb
ext/thin_parser/*.so
ext/thin_parser_jruby/classes
lib/*.bundle
lib/*.so
lib/*.jar
log
spec/rails_app/log
doc/rdoc/*
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Dir['tasks/**/*.rake'].each { |rake| load rake }
task :default => :spec

if JRUBY
jruby_ext_task :thin_parser_jruby
jruby_ext_task :thin_parser_jruby, "lib/thin_parser.jar"
else
ext_task :thin_parser
end
Expand Down
4 changes: 2 additions & 2 deletions ext/thin_parser_jruby/ThinParserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import org.jruby.Ruby;
import org.jruby.runtime.load.BasicLibraryService;

import org.thin.HttpParser;
import org.thin.Http;

public class ThinParserService implements BasicLibraryService {
public boolean basicLoad(final Ruby runtime) throws IOException {
HttpParser.createHttp(runtime);
Http.createHttp(runtime);
return true;
}
}
5 changes: 1 addition & 4 deletions ext/thin_parser_jruby/org/thin/HttpParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public void init() {
}
}

public final HttpParser parser = new HttpParserMachine();
public final HttpParserMachine parser = new HttpParserMachine();

public int execute(ByteList buffer, int off) {
int p, pe;
Expand Down Expand Up @@ -456,7 +456,6 @@ else if ( data[p] > _http_parser_trans_keys[_mid+1] )

if(parser.body_start>0) {
/* final \r\n combo encountered so stop right here */
parser.eof = p;
parser.nread++;
}

Expand All @@ -466,8 +465,6 @@ else if ( data[p] > _http_parser_trans_keys[_mid+1] )
public int finish() {
int cs = parser.cs;

parser.eof = p;

parser.cs = cs;

if(has_error()) {
Expand Down
7 changes: 2 additions & 5 deletions ext/thin_parser_jruby/parser.java.rl
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public class HttpParser {
public void call(Object data, int field, int flen, int value, int vlen);
}

public static class HttpParser {
public static class HttpParserMachine {
int cs;
int body_start;
int content_len;
Expand Down Expand Up @@ -115,7 +115,7 @@ public class HttpParser {
}
}

public final HttpParser parser = new HttpParser();
public final HttpParserMachine parser = new HttpParserMachine();

public int execute(ByteList buffer, int off) {
int p, pe;
Expand All @@ -142,7 +142,6 @@ public class HttpParser {

if(parser.body_start>0) {
/* final \r\n combo encountered so stop right here */
parser.eof = p;
parser.nread++;
}

Expand All @@ -152,8 +151,6 @@ public class HttpParser {
public int finish() {
int cs = parser.cs;

parser.eof = p;

parser.cs = cs;

if(has_error()) {
Expand Down
4 changes: 4 additions & 0 deletions lib/thin/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@ def self.linux?
def self.ruby_18?
RUBY_VERSION =~ /^1\.8/
end

def self.jruby?
RUBY_PLATFORM =~ /java/
end
end
3 changes: 1 addition & 2 deletions tasks/ext.rake
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ def ext_task(name)
end
end

def jruby_ext_task(name)
def jruby_ext_task(name, jar_file)
ext_dir = "ext/#{name}"
build_dir = "ext/#{name}/classes"
jar_file = "lib/#{name}.jar"

# Avoid JRuby in-process launching problem
require 'jruby'
Expand Down

0 comments on commit fd7b949

Please sign in to comment.