ruby-fcgi patches

Discussion in 'Ruby' started by Brad Hilton, Sep 25, 2003.

  1. Brad Hilton

    Brad Hilton Guest

    This is a multi-part message in MIME format.
    --------------010607080103020505010803
    Content-Type: multipart/alternative;
    boundary="------------010501090207000102020901"


    --------------010501090207000102020901
    Content-Type: text/plain; charset=utf-8; format=flowed
    Content-Transfer-Encoding: 7bit

    Hello,

    I have two patches that fix / enhance the C version of ruby-fcgi. This
    message was sent to the maintainer several days ago, but I haven't
    received a response. I'm hoping perhaps he reads this list.

    The fix:
    fcgi_stream_read() does not free the buff variable, which results in
    memory leakage that is most noticeable when handling large file
    uploads. Simply doing a:

    ------------------------
    FCGI::each { |request|
    until request.in.eof?
    request.in.read(1024)
    end
    }
    ------------------------

    exposes the problem, as the application grows in size with each new
    client POST. Calling GC.start does nothing to decrease the size. The
    first patch appears to solve this problem.

    The second patch adds a new method FCGI::eek:pen_socket(socket_path,
    tcp_backlog) which allows the library to be used with the
    FastCgiExternalServer option of mod_fastcgi for Apache. FCGI::accept()
    and FCGI::each() had to be patched to optionally take this new socket
    argument. Example usage would be:

    sock = FCGI.open_socket('localhost:23443', 10)

    FCGI::each(sock) { |request|
    ...
    }

    Thank you for considering these patches.

    Regards,
    -Brad Hilton

    --------------010501090207000102020901
    Content-Type: text/html; charset=utf-8
    Content-Transfer-Encoding: 8bit

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
    <title></title>
    </head>
    <body>
    <meta content="text/html; CHARSET=UTF-8" http-equiv="Content-Type">
    <meta content="GtkHTML/3.0.8" name="GENERATOR">
    Hello,<br>
    <br>
    I have two patches that fix / enhance the C version of ruby-fcgi.  This
    message was sent to the maintainer several days ago, but I haven't
    received a response.  I'm hoping perhaps he reads this list.<br>
    <br>
    The fix:<br>
    fcgi_stream_read() does not free the buff variable, which results in
    memory leakage that is most noticeable when handling large file
    uploads.  Simply doing a:<br>
    <br>
    ------------------------<br>
    FCGI::each { |request|<br>
      until request.in.eof?<br>
        request.in.read(1024)<br>
      end<br>
    }<br>
    ------------------------<br>
    <br>
    exposes the problem, as the application grows in size with each new
    client POST.  Calling GC.start does nothing to decrease the size.  The
    first patch appears to solve this problem.<br>
    <br>
    The second patch adds a new method FCGI::eek:pen_socket(socket_path,
    tcp_backlog) which allows the library to be used with the
    FastCgiExternalServer option of mod_fastcgi for Apache.  FCGI::accept()
    and FCGI::each() had to be patched to optionally take this new socket
    argument.  Example usage would be:<br>
    <br>
    sock = FCGI.open_socket('localhost:23443', 10)<br>
    <br>
    FCGI::each(sock) { |request|<br>
        ...<br>
    }<br>
    <br>
    Thank you for considering these patches.<br>
    <br>
    Regards,<br>
    -Brad Hilton
    </body>
    </html>

    --------------010501090207000102020901--

    --------------010607080103020505010803
    Content-Type: text/plain;
    name="patch-fcgi-xfree"
    Content-Transfer-Encoding: base64
    Content-Disposition: inline;
    filename="patch-fcgi-xfree"

    LS0tIGZjZ2kuYy5vcmlnCTIwMDMtMDktMjMgMTE6MjA6MDEuMDAwMDAwMDAwIC0wNzAwCisr
    KyBmY2dpLmMJMjAwMy0wOS0yMyAxMToyMDoyOS4wMDAwMDAwMDAgLTA3MDAKQEAgLTM4OSw5
    ICszODksMTEgQEAgc3RhdGljIFZBTFVFIGZjZ2lfc3RyZWFtX3JlYWQoaW50IGFyZ2MsIAog
    ICAgICAgaWYgKG4gPiAwKSB7CiAgICAgICAgIHJiX3N0cl9jYXQoc3RyLCBidWZmLCBuKTsK
    ICAgICAgIH0gZWxzZSB7CisgICAgICAgIHhmcmVlKGJ1ZmYpOwogICAgICAgICByZXR1cm4g
    UW5pbDsKICAgICAgIH0KICAgICB9CisgICAgeGZyZWUoYnVmZik7CiAgICAgcmV0dXJuIHN0
    cjsKICAgfQogCkBAIC00MDQsOSArNDA2LDExIEBAIHN0YXRpYyBWQUxVRSBmY2dpX3N0cmVh
    bV9yZWFkKGludCBhcmdjLCAKICAgaWYgKG4gPiAwKSB7CiAgICAgc3RyID0gcmJfc3RyX25l
    dyhidWZmLCBuKTsKICAgICBPQkpfVEFJTlQoc3RyKTsKKyAgICB4ZnJlZShidWZmKTsKICAg
    ICByZXR1cm4gc3RyOwogICB9CiAgIGVsc2UgeworICAgIHhmcmVlKGJ1ZmYpOwogICAgIHJl
    dHVybiBRbmlsOwogICB9CiB9Cgo=
    --------------010607080103020505010803
    Content-Type: text/plain;
    name="patch-ruby-fcgi2"
    Content-Transfer-Encoding: base64
    Content-Disposition: inline;
    filename="patch-ruby-fcgi2"

    LS0tIGZjZ2kuYwkyMDAzLTA5LTIzIDExOjIwOjI5LjAwMDAwMDAwMCAtMDcwMAorKysgL2hv
    bWUvYmhpbHRvbi9mY2dpLmMucGF0Y2hlZAkyMDAzLTA5LTIzIDExOjIwOjUwLjAwMDAwMDAw
    MCAtMDcwMApAQCAtMzcsMTUgKzM3LDM3IEBAIHN0YXRpYyB2b2lkIGZjZ2lfbWFyayhmY2dp
    X2RhdGEgKmRhdGEpCiAgIHJiX2djX21hcmsoZGF0YS0+ZW52KTsKIH0KIAotc3RhdGljIFZB
    TFVFIGZjZ2lfc19hY2NlcHQoVkFMVUUgc2VsZikKK3N0YXRpYyBWQUxVRSBmY2dpX3Nfb3Bl
    bl9zb2NrZXQoVkFMVUUgc2VsZiwgVkFMVUUgcGF0aCwgVkFMVUUgYmFja2xvZykKK3sKKyAg
    VkFMVUUgZmlsZW5vOworCisgIGZpbGVubyA9IElOVDJOVU0oRkNHWF9PcGVuU29ja2V0KCBT
    VFIyQ1NUUihwYXRoKSwgTlVNMklOVChiYWNrbG9nKSApKTsKKyAgcmV0dXJuIHJiX2Z1bmNh
    bGwocmJfY0lPLCByYl9pbnRlcm4oIm5ldyIpLCAxLCBmaWxlbm8pOworfQorCitzdGF0aWMg
    VkFMVUUgZmNnaV9zX2FjY2VwdChpbnQgYXJnYywgVkFMVUUgKmFyZ3YsIFZBTFVFIHNlbGYp
    CiB7CiAgIGludCBzdGF0dXM7CiAgIEZDR1hfUmVxdWVzdCAqcmVxOwogICBmZF9zZXQgcmVh
    ZGZkczsKKyAgaW50IGZpbGVubzsKKworICBzd2l0Y2ggKGFyZ2MpCisgIHsKKyAgICBjYXNl
    IDE6CisgICAgICBmaWxlbm8gPSBOVU0ySU5UKHJiX2Z1bmNhbGwoYXJndlswXSwgcmJfaW50
    ZXJuKCJmaWxlbm8iKSwgMCkpOworICAgICAgYnJlYWs7CisgICAgY2FzZSAwOgorICAgICAg
    ZmlsZW5vID0gMDsKKyAgICAgIGJyZWFrOworICAgIGRlZmF1bHQ6CisgICAgICByYl9yYWlz
    ZShyYl9lQXJnRXJyb3IsICJ3cm9uZyBudW1iZXIgb2YgYXJndW1lbnRzICgwIG9yIDEpIik7
    CisgICAgICBicmVhazsKKyAgfQogICAKICAgcmVxID0gQUxMT0MoRkNHWF9SZXF1ZXN0KTsK
    ICAgCi0gIHN0YXR1cyA9IEZDR1hfSW5pdFJlcXVlc3QocmVxLDAsMCk7CisgIHN0YXR1cyA9
    IEZDR1hfSW5pdFJlcXVlc3QocmVxLGZpbGVubywwKTsKICAgaWYgKHN0YXR1cyAhPSAwKSB7
    CiAgICAgcmJfcmFpc2UoZUZDR0lFcnJvciwgIkZDR1hfSW5pdCgpIGZhaWxlZCIpOwogICAg
    IHJldHVybiBRbmlsOwpAQCAtODksMTEgKzExMSwyOCBAQCBzdGF0aWMgVkFMVUUgZmNnaV9z
    X2FjY2VwdChWQUxVRSBzZWxmKQogICB9CiB9CiAKLXN0YXRpYyBWQUxVRSBmY2dpX3NfZWFj
    aChWQUxVRSBzZWxmKQorc3RhdGljIFZBTFVFIGZjZ2lfc19lYWNoKGludCBhcmdjLCBWQUxV
    RSAqYXJndiwgVkFMVUUgc2VsZikKIHsKICAgVkFMVUUgZmNnaTsKKyAgVkFMVUUgc29ja2V0
    OworICBWQUxVRSBhcmdzWzFdOworCisgIHN3aXRjaChhcmdjKQorICB7CisgICAgY2FzZSAx
    OgorICAgICAgc29ja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5nbGV0b25fbWV0aG9kKGNG
    Q0dJLCAiYWNjZXB0IiwgZmNnaV9zX2FjY2VwdCwgLTEpOworICByYl9kZWZpbmVfc2luZ2xl
    dG9uX21ldGhvZChjRkNHSSwgIm9wZW5fc29ja2V0IiwgZmNnaV9zX29wZW5fc29ja2V0LCAy
    KTsKKyAgcmJfZGVmaW5lX3NpbmdsZXRvbl9tZXRob2QoY0ZDR0ksICJlYWNoIiwgZmNnaV9z
    X2VhY2gsIC0xKTsKKyAgcmJfZGVmaW5lX3NpbmdsZXRvbl9tZXRob2QoY0ZDR0ksICJlYWNo
    X3JlcXVlc3QiLCBmY2dpX3NfZWFjaCwgLTEpOwogICByYl9kZWZpbmVfc2luZ2xldG9uX21l
    dGhvZChjRkNHSSwgImlzX2NnaT8iLCBmY2dpX3NfaXNjZ2ksIDApOwogICByYl9kZWZpbmVf
    bWV0aG9kKGNGQ0dJLCAiaW4iLCBmY2dpX2luLCAwKTsKICAgcmJfZGVmaW5lX21ldGhvZChj
    RkNHSSwgIm91dCIsIGZjZ2lfb3V0LCAwKTsKCg==
    --------------010607080103020505010803--
     
    Brad Hilton, Sep 25, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joacim J

    CVS command for patches

    Joacim J, Mar 3, 2005, in forum: Java
    Replies:
    1
    Views:
    326
    Daniel Tryba
    Mar 3, 2005
  2. Thursday
    Replies:
    2
    Views:
    133
  3. benny
    Replies:
    6
    Views:
    198
    Dick Davies
    Apr 25, 2005
  4. Chris Pearl
    Replies:
    0
    Views:
    133
    Chris Pearl
    Oct 16, 2006
  5. Javier Abaroa

    fcgi or ruby-fcgi on Windows-Xp

    Javier Abaroa, Apr 16, 2010, in forum: Ruby
    Replies:
    2
    Views:
    465
    Javier Abaroa
    Apr 19, 2010
Loading...

Share This Page