Skip to content

Conversation

@mruprich
Copy link

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.

if(conn && conn->data_sock!=-1)
if(conn && conn->data_sock!=-1) {
SetSocketBuffer(conn->data_sock);
SetTCPNodelay(conn->data_sock);
Copy link
Owner

@lavv17 lavv17 Oct 31, 2025

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?

goodbye_done = true;
return DONE;
if (!ssl_shutdown_timer) {
ssl_shutdown_timer = new Timer(0, 200);
Copy link
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.

} 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
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?

ProtoLog::LogError(1,"setsockopt(TCP_MAXSEG,%d): %s",socket_maxseg,strerror(errno));
#endif
}
void Networker::SetTCPNodelay(int sock)
Copy link
Owner

Choose a reason for hiding this comment

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

NoDelay looks better

res = gnutls_bye(session,GNUTLS_SHUT_RDWR);
if (res == GNUTLS_E_SUCCESS) {
if (ssl_shutdown_timer) {
ssl_shutdown_timer->Stop();
Copy link
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

#define BUFFER_SSL_H

#include "buffer.h"
#include "Timer.h"
Copy link
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