From adae78d0745ec4332bbd343712f8475e6648465b Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 12 Mar 2015 20:16:46 +0000 Subject: [PATCH 07/11] Split _dbus_set_fd_nonblocking vs. _dbus_set_socket_nonblocking The former is Unix-specific, the latter is also portable to Windows. On Unix, they're really the same thing. --- dbus/dbus-internals.h | 3 --- dbus/dbus-server-socket.c | 2 +- dbus/dbus-sysdeps-unix.c | 10 ++++++++++ dbus/dbus-sysdeps-win.c | 8 ++++---- dbus/dbus-sysdeps.h | 6 ++++++ 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/dbus/dbus-internals.h b/dbus/dbus-internals.h index 6368538..225a9b6 100644 --- a/dbus/dbus-internals.h +++ b/dbus/dbus-internals.h @@ -279,9 +279,6 @@ char** _dbus_dup_string_array (const char **array); typedef void (* DBusForeachFunction) (void *element, void *data); -dbus_bool_t _dbus_set_fd_nonblocking (int fd, - DBusError *error); - void _dbus_verbose_bytes (const unsigned char *data, int len, int offset); diff --git a/dbus/dbus-server-socket.c b/dbus/dbus-server-socket.c index a05e301..73ddfe3 100644 --- a/dbus/dbus-server-socket.c +++ b/dbus/dbus-server-socket.c @@ -95,7 +95,7 @@ handle_new_client_fd_and_unlock (DBusServer *server, HAVE_LOCK_CHECK (server); - if (!_dbus_set_fd_nonblocking (client_fd, NULL)) + if (!_dbus_set_socket_nonblocking (client_fd, NULL)) { SERVER_UNLOCK (server); return TRUE; diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index 9603b3a..c0679d9 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -134,6 +134,9 @@ #endif /* Solaris */ +static dbus_bool_t _dbus_set_fd_nonblocking (int fd, + DBusError *error); + static dbus_bool_t _dbus_open_socket (int *fd_p, int domain, @@ -3207,6 +3210,13 @@ _dbus_dup(int fd, * @returns #TRUE on success. */ dbus_bool_t +_dbus_set_socket_nonblocking (DBusSocket fd, + DBusError *error) +{ + return _dbus_set_fd_nonblocking (fd, error); +} + +static dbus_bool_t _dbus_set_fd_nonblocking (int fd, DBusError *error) { diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index eda9e5c..e45f780 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -538,8 +538,8 @@ _dbus_win_handle_set_close_on_exec (HANDLE handle) * @returns #TRUE on success. */ dbus_bool_t -_dbus_set_fd_nonblocking (int handle, - DBusError *error) +_dbus_set_socket_nonblocking (DBusSocket handle, + DBusError *error) { u_long one = 1; @@ -1613,7 +1613,7 @@ _dbus_connect_tcp_socket_with_nonce (const char *host, /* Every SOCKET is also a HANDLE. */ _dbus_win_handle_set_close_on_exec ((HANDLE) fd); - if (!_dbus_set_fd_nonblocking (fd, error)) + if (!_dbus_set_socket_nonblocking (fd, error)) { closesocket (fd); return -1; @@ -1822,7 +1822,7 @@ _dbus_listen_tcp_socket (const char *host, for (i = 0 ; i < nlisten_fd ; i++) { _dbus_win_handle_set_close_on_exec ((HANDLE) listen_fd[i]); - if (!_dbus_set_fd_nonblocking (listen_fd[i], error)) + if (!_dbus_set_socket_nonblocking (listen_fd[i], error)) { goto failed; } diff --git a/dbus/dbus-sysdeps.h b/dbus/dbus-sysdeps.h index 4c92928..4a13716 100644 --- a/dbus/dbus-sysdeps.h +++ b/dbus/dbus-sysdeps.h @@ -164,6 +164,9 @@ _dbus_socket_get_invalid (void) return s; } +dbus_bool_t _dbus_set_socket_nonblocking (DBusSocket fd, + DBusError *error); + DBUS_PRIVATE_EXPORT dbus_bool_t _dbus_close_socket (DBusSocket fd, DBusError *error); @@ -225,6 +228,9 @@ int _dbus_listen_tcp_socket (const char *host, DBusError *error); DBusSocket _dbus_accept (DBusSocket listen_fd); +dbus_bool_t _dbus_set_socket_nonblocking (DBusSocket fd, + DBusError *error); + dbus_bool_t _dbus_read_credentials_socket (DBusSocket client_fd, DBusCredentials *credentials, -- 2.1.4