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.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89444
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
This commit is contained in:
Simon McVittie 2015-03-12 20:16:46 +00:00
parent 378e01c0d0
commit 21ca7f7cc3
5 changed files with 18 additions and 9 deletions

View file

@ -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);

View file

@ -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;

View file

@ -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)
{

View file

@ -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;
@ -1615,7 +1615,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;
@ -1824,7 +1824,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;
}

View file

@ -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,7 +228,6 @@ int _dbus_listen_tcp_socket (const char *host,
DBusError *error);
DBusSocket _dbus_accept (DBusSocket listen_fd);
dbus_bool_t _dbus_read_credentials_socket (DBusSocket client_fd,
DBusCredentials *credentials,
DBusError *error);