<html><head><meta http-equiv="content-type" content="text/html; charset=us-ascii"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">Hi,<br><div><br><blockquote type="cite"><div>But when dsync connects over tcps,</div><div><div class="syno-mc-signature syno-mc-signature-id-1">
<div>it uses function implementations in lib-ssl-iostream to send and receive data.</div>
<div>And this simplified call stack would result in some data are read when calling o_stream_uncork<br>
<br></div>
<div><strong>o_stream_uncork => o_stream_flush => o_stream_ssl_flush_buffer => openssl_iostream_bio_sync => openssl_iostream_bio_input</strong></div>
<div><br>
If some data arrive after <span style="color: #222222; font-family: Arial, Verdana, sans-serif; font-size: 13.3333px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">ibc->ibc.io_callback(ibc->ibc.io_context) and before o_stream_uncork,</span></div>
<div><span style="color: #222222; font-family: Arial, Verdana, sans-serif; font-size: 13.3333px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">o_stream_uncork would read the data and then return.</span></div>
<div>After <span style="color: #222222; font-family: Arial, Verdana, sans-serif; font-size: 13.3333px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">o_stream_uncork returns, dsync then waits for new data to be read or written.</span></div>
<div><span style="color: #222222; font-family: Arial, Verdana, sans-serif; font-size: 13.3333px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">But because the data had been read in o_stream_uncork</span><span style="color: #222222; font-family: Arial, Verdana, sans-serif; font-size: 13.3333px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">, and there may be no new data to be read,</span></div>
<div><span style="color: #222222; font-family: Arial, Verdana, sans-serif; font-size: 13.3333px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">dsync may then wait until timeout is met.</span></div></div></div></blockquote><div><br></div><div>If this happens, it's supposed to mark the IO as having data "pending", which should prevent the timeout. The logic seems to me like it should work, although I'm now wondering if it can hang when there is some internal SSL state data that needs to be read even though there is no actual data being sent. So:</div><div><br></div><blockquote type="cite"><div class="syno-mc-signature syno-mc-signature-id-1">
<div>It may happen, but it is hard to reproduce.</div>
</div></blockquote><br></div><div>Are you able to try if this patch happens to fix it? :</div><div><br></div><div><div>diff --git a/src/lib-ssl-iostream/iostream-openssl.c b/src/lib-ssl-iostream/iostream-openssl.c</div><div>index fa9afb22f7..094abaa56c 100644</div><div>--- a/src/lib-ssl-iostream/iostream-openssl.c</div><div>+++ b/src/lib-ssl-iostream/iostream-openssl.c</div><div>@@ -550,10 +550,7 @@ openssl_iostream_bio_input(struct ssl_iostream *ssl_io,</div><div> }</div><div> }</div><div> if (bytes_read || i_stream_get_data_size(ssl_io->plain_input) > 0) {</div><div>- if (i_stream_get_data_size(ssl_io->plain_input) > 0 ||</div><div>- (type != OPENSSL_IOSTREAM_SYNC_TYPE_FIRST_READ &&</div><div>- type != OPENSSL_IOSTREAM_SYNC_TYPE_CONTINUE_READ))</div><div>- i_stream_set_input_pending(ssl_io->ssl_input, TRUE);</div><div>+ i_stream_set_input_pending(ssl_io->ssl_input, TRUE);</div><div> ssl_io->want_read = FALSE;</div><div> }</div><div> return (bytes_read ? 1 : 0);</div></div><br></body></html>