-
Notifications
You must be signed in to change notification settings - Fork 177
Improving TLS communication with a timer #768
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| if(conn && conn->data_sock!=-1) | ||
| if(conn && conn->data_sock!=-1) { | ||
| SetSocketBuffer(conn->data_sock); | ||
| SetTCPNodelay(conn->data_sock); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks unneeded
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.