Skip to content

Improving TLS communication with a timer - #768

Open
mruprich wants to merge 1 commit into
lavv17:masterfrom
mruprich:tls-nagle-algorithm
Open

Improving TLS communication with a timer#768
mruprich wants to merge 1 commit into
lavv17:masterfrom
mruprich:tls-nagle-algorithm

Conversation

@mruprich

Copy link
Copy Markdown

Adding a bit of code on top of #754 . This following change is also authored by Tomas from the previous PR. Some TLS implementations do not send close_notify and we could wait indefinitely for something that never happens.

Also, setting the socket flags to TCP_NODELAY which basically disables the Nagle algorithm.

Comment thread src/ftpclass.cc
if(conn && conn->data_sock!=-1)
if(conn && conn->data_sock!=-1) {
SetSocketBuffer(conn->data_sock);
SetTCPNodelay(conn->data_sock);

@lavv17 lavv17 Oct 31, 2025

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it always give good results? Measured?

Comment thread src/lftp_ssl.cc
goodbye_done = true;
return DONE;
if (!ssl_shutdown_timer) {
ssl_shutdown_timer = new Timer(0, 200);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is 200 ms always enough? Maybe 1 sec is a better default. And a setting would be nice to have.

Comment thread src/lftp_ssl.cc
} else if (res == GNUTLS_E_AGAIN || res == GNUTLS_E_INTERRUPTED) {
/* In ideal world we would not need this if, but windows does not
* send close-notify, so do not wait on server close-notify */
if (gnutls_record_get_direction(session) == 0) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this code invalid?

Comment thread src/network.cc
ProtoLog::LogError(1,"setsockopt(TCP_MAXSEG,%d): %s",socket_maxseg,strerror(errno));
#endif
}
void Networker::SetTCPNodelay(int sock)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NoDelay looks better

Comment thread src/lftp_ssl.cc
res = gnutls_bye(session,GNUTLS_SHUT_RDWR);
if (res == GNUTLS_E_SUCCESS) {
if (ssl_shutdown_timer) {
ssl_shutdown_timer->Stop();

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better delete the timer, it will not be needed anymore

Comment thread src/buffer_ssl.h
#define BUFFER_SSL_H

#include "buffer.h"
#include "Timer.h"

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks unneeded

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants