Project

General

Profile

Bug #12126

[PATCH] openssl: accept moving write buffer for write_nonblock

Added by normalperson (Eric Wong) over 3 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:74051]

Description

By setting the SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER flag.
This flag was introduced at the same time as
SSL_MODE_ENABLE_PARTIAL_WRITE in OpenSSL 0.9.4 and makes usage
with non-blocking sockets much easier.

Before this, a Rubyist would need to remember the exact object
which failed to write and reuse it later when the socket became
writable again.  This causes problems when the buffer is given
by another layer of the application (e.g. a buffer is given
by a Rack middleware or application to a Rack web server).

* ext/openssl/ossl_ssl.c (ossl_sslctx_s_alloc):
  enable SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER by default

Related to https://bugs.ruby-lang.org/issues/12085

I'm not sure if this can be considered a bugfix which
should be backported. I have found write_nonblock usability to
be severely hampered by the lack if this flag.


Files


Related issues

Related to Ruby master - Feature #12085: [PATCH] openssl: document `exception: false' for *_nonblockClosedActions

Associated revisions

Revision 280f7322
Added by normal over 3 years ago

openssl: accept moving write buffer for write_nonblock

By setting the SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER flag.
This flag was introduced at the same time as
SSL_MODE_ENABLE_PARTIAL_WRITE in OpenSSL 0.9.4 and makes usage
with non-blocking sockets much easier.

Before this, a Rubyist would need to remember the exact object
which failed to write and reuse it later when the socket became
writable again. This causes problems when the buffer is given
by another layer of the application (e.g. a buffer is given
by a Rack middleware or application to a Rack web server).

  • ext/openssl/ossl_ssl.c (ossl_sslctx_s_alloc): enable SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER by default [Bug #12126]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 54466
Added by normalperson (Eric Wong) over 3 years ago

openssl: accept moving write buffer for write_nonblock

By setting the SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER flag.
This flag was introduced at the same time as
SSL_MODE_ENABLE_PARTIAL_WRITE in OpenSSL 0.9.4 and makes usage
with non-blocking sockets much easier.

Before this, a Rubyist would need to remember the exact object
which failed to write and reuse it later when the socket became
writable again. This causes problems when the buffer is given
by another layer of the application (e.g. a buffer is given
by a Rack middleware or application to a Rack web server).

  • ext/openssl/ossl_ssl.c (ossl_sslctx_s_alloc): enable SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER by default [Bug #12126]

Revision 54466
Added by normal over 3 years ago

openssl: accept moving write buffer for write_nonblock

By setting the SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER flag.
This flag was introduced at the same time as
SSL_MODE_ENABLE_PARTIAL_WRITE in OpenSSL 0.9.4 and makes usage
with non-blocking sockets much easier.

Before this, a Rubyist would need to remember the exact object
which failed to write and reuse it later when the socket became
writable again. This causes problems when the buffer is given
by another layer of the application (e.g. a buffer is given
by a Rack middleware or application to a Rack web server).

  • ext/openssl/ossl_ssl.c (ossl_sslctx_s_alloc): enable SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER by default [Bug #12126]

Revision 54466
Added by normal over 3 years ago

openssl: accept moving write buffer for write_nonblock

By setting the SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER flag.
This flag was introduced at the same time as
SSL_MODE_ENABLE_PARTIAL_WRITE in OpenSSL 0.9.4 and makes usage
with non-blocking sockets much easier.

Before this, a Rubyist would need to remember the exact object
which failed to write and reuse it later when the socket became
writable again. This causes problems when the buffer is given
by another layer of the application (e.g. a buffer is given
by a Rack middleware or application to a Rack web server).

  • ext/openssl/ossl_ssl.c (ossl_sslctx_s_alloc): enable SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER by default [Bug #12126]

Revision 54466
Added by normal over 3 years ago

openssl: accept moving write buffer for write_nonblock

By setting the SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER flag.
This flag was introduced at the same time as
SSL_MODE_ENABLE_PARTIAL_WRITE in OpenSSL 0.9.4 and makes usage
with non-blocking sockets much easier.

Before this, a Rubyist would need to remember the exact object
which failed to write and reuse it later when the socket became
writable again. This causes problems when the buffer is given
by another layer of the application (e.g. a buffer is given
by a Rack middleware or application to a Rack web server).

  • ext/openssl/ossl_ssl.c (ossl_sslctx_s_alloc): enable SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER by default [Bug #12126]

History

Updated by normalperson (Eric Wong) over 3 years ago

normalperson@yhbt.net wrote:

Before this, a Rubyist would need to remember the exact object
which failed to write and reuse it later when the socket became
writable again. This causes problems when the buffer is given
by another layer of the application (e.g. a buffer is given
by a Rack middleware or application to a Rack web server).

I should note the content of the buffer still needs to remain the
unchanged. And IMHO, any reasonable non-blocking server working with
stream sockets is expected to maintain identical content when
retrying writes.

The main difference with this patch is the memory addresses passed
to SSL_write() C function can be safely changed when retrying.
IMHO it's unreasonable for a Ruby programmer to care about memory
addresses passed to C functions when writing in Ruby.

#3

Updated by Anonymous over 3 years ago

  • Status changed from Open to Closed

Applied in changeset r54466.


openssl: accept moving write buffer for write_nonblock

By setting the SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER flag.
This flag was introduced at the same time as
SSL_MODE_ENABLE_PARTIAL_WRITE in OpenSSL 0.9.4 and makes usage
with non-blocking sockets much easier.

Before this, a Rubyist would need to remember the exact object
which failed to write and reuse it later when the socket became
writable again. This causes problems when the buffer is given
by another layer of the application (e.g. a buffer is given
by a Rack middleware or application to a Rack web server).

  • ext/openssl/ossl_ssl.c (ossl_sslctx_s_alloc): enable SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER by default [Bug #12126]
#4

Updated by naruse (Yui NARUSE) over 3 years ago

  • Related to Feature #12085: [PATCH] openssl: document `exception: false' for *_nonblock added
#5

Updated by naruse (Yui NARUSE) over 3 years ago

  • Related to Bug #12309: Segmentation fault caused by OpenSSL added
#6

Updated by naruse (Yui NARUSE) over 3 years ago

  • Related to Bug #6168: Segfault in OpenSSL bindings added
#7

Updated by rhenium (Kazuki Yamaguchi) almost 3 years ago

  • Related to deleted (Bug #6168: Segfault in OpenSSL bindings)
#8

Updated by rhenium (Kazuki Yamaguchi) almost 3 years ago

  • Related to deleted (Bug #12309: Segmentation fault caused by OpenSSL)

Also available in: Atom PDF