diff options
author | Max Kellermann <max@duempel.org> | 2013-01-15 22:27:24 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-01-15 22:42:15 +0100 |
commit | 8917264110fb684ef1fa87fdab14dd78902e8bba (patch) | |
tree | cb20bdc26252f98ce781e92a5e41f31763461ad6 /src/ServerSocket.cxx | |
parent | e90d606f0ad56146e8686acfdfd357005fa5b4a6 (diff) | |
download | mpd-8917264110fb684ef1fa87fdab14dd78902e8bba.tar.gz mpd-8917264110fb684ef1fa87fdab14dd78902e8bba.tar.xz mpd-8917264110fb684ef1fa87fdab14dd78902e8bba.zip |
ServerSocket, SocketUtil: use the SocketError library
Use WinSock errors on Windows.
Diffstat (limited to '')
-rw-r--r-- | src/ServerSocket.cxx | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/ServerSocket.cxx b/src/ServerSocket.cxx index 7f2853e20..3a3a4a528 100644 --- a/src/ServerSocket.cxx +++ b/src/ServerSocket.cxx @@ -25,6 +25,7 @@ #include "ServerSocket.hxx" #include "SocketUtil.hxx" +#include "SocketError.hxx" #include "resolver.h" #include "fd_util.h" #include "glib_socket.h" @@ -35,7 +36,6 @@ #include <sys/stat.h> #include <fcntl.h> #include <string.h> -#include <errno.h> #include <unistd.h> #include <stdlib.h> #include <assert.h> @@ -181,14 +181,17 @@ server_socket_in_event(G_GNUC_UNUSED GIOChannel *source, int fd = accept_cloexec_nonblock(s->fd, (struct sockaddr*)&address, &address_length); if (fd >= 0) { - if (socket_keepalive(fd)) + if (socket_keepalive(fd)) { + const SocketErrorMessage msg; g_warning("Could not set TCP keepalive option: %s", - g_strerror(errno)); + (const char *)msg); + } s->parent.callback(fd, (const struct sockaddr*)&address, address_length, get_remote_uid(fd), s->parent.callback_ctx); } else { - g_warning("accept() failed: %s", g_strerror(errno)); + const SocketErrorMessage msg; + g_warning("accept() failed: %s", (const char *)msg); } return true; @@ -342,9 +345,8 @@ server_socket_add_fd(struct server_socket *ss, int fd, GError **error_r) socklen_t address_length; if (getsockname(fd, (struct sockaddr *)&address, &address_length) < 0) { - g_set_error(error_r, server_socket_quark(), errno, - "Failed to get socket address: %s", - g_strerror(errno)); + SetSocketError(error_r); + g_prefix_error(error_r, "Failed to get socket address"); return false; } |