-
Notifications
You must be signed in to change notification settings - Fork 5
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
[GAIAPLAT-1236] db_server - better error message when 'Address already in use' #881
Changes from 1 commit
ca030ff
5be6309
d0dffa0
081c5fc
c7c03c1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -927,6 +927,14 @@ void server_t::init_listening_socket(const std::string& socket_name) | |
socklen_t server_addr_size = sizeof(server_addr.sun_family) + 1 + ::strlen(&server_addr.sun_path[1]); | ||
if (-1 == ::bind(listening_socket, reinterpret_cast<struct sockaddr*>(&server_addr), server_addr_size)) | ||
{ | ||
// TODO it would be nice to have a common error handler that can handle common errors. | ||
if (errno == EADDRINUSE) | ||
{ | ||
cerr << "ERROR: bind() failed! - " << (::strerror(errno)) << endl; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the pattern should be that we print the friendly error message before the detailed message/stack trace. (You could also avoid duplicating the system error message by putting this in a try/catch block and printing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I followed the same pattern and formatting used in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, that's not so bad (as long as there's no stack trace before the friendly message). Approved. |
||
cerr << "The Gaia Database Server cannot start because another instance is already running. Please stop any instances of the server that are running." << endl; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could there be non running instances of the server that could cause an issue? Maybe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Potentially you could create an address with the same name, but very unlikely.
Changed. |
||
exit(1); | ||
LaurentiuCristofor marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
throw_system_error("bind() failed!"); | ||
LaurentiuCristofor marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
if (-1 == ::listen(listening_socket, 0)) | ||
|
@@ -2596,3 +2604,7 @@ void server_t::run(server_config_t server_conf) | |
} | ||
} | ||
} | ||
|
||
void server_t::handle_common_errors() | ||
{ | ||
} |
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 for our use? If not what useful information does it provide to the user?
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, more skilled users will know what the syscall
bind
is. For now, we just have this one but in the future, we may have more, and knowing exactly what went wrong can be helpful. This can also be used by the user to report the errors back to us.