-
Notifications
You must be signed in to change notification settings - Fork 872
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
Applied a new way of socket ID generation #1076
Applied a new way of socket ID generation #1076
Conversation
srtcore/api.cpp
Outdated
try | ||
{ | ||
CGuard l_idlock(m_IDLock); | ||
ns->m_SocketID = generateSocketID(); | ||
} | ||
catch (CUDTException& e) |
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.
Why don't you catch the exception in the above call to generateSocketID()
then?
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.
Because the function that calls the newSocket
function will catch it anyway.
The CUDT::newConnection
OTOH will be called asynchronically as a part of the handshake process, therefore no other part will catch it.
Everything is explained in the comments.
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.
OTOH you might be right in one thing - if this throws an exception, no one will clean the allocated object. I have to put everything under the try block then.
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.
Well, no. There would be a different kind of exception to be thrown. I need to add an interceptor.
catch (...) | ||
{ | ||
delete ns; | ||
throw; | ||
} |
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.
What is the reason for catching any exception?
generateSocketID()
only throws CUDTException
What are other possible exceptions?
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.
This is a simple passthrough - whatever exception (altho' yes, currently it's only CUDTException
) is thrown, it only gets intercepted here, but then propagated further.
This instruction simply intercepts everything and complements the logical requirements of this function. It doesn't take part in any exception handling at all. If you want to put any real name here, then it would be needed to be treated as this action is specific for the exception - whereas it's not. Whatever gets through it, the handling is completely general.
It's not the matter of being strict, it's the matter of level of details that this very function focuses on.
No description provided.