From c82d816a62d2d6b0b8beb481dd162e1338398b17 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Thu, 5 Mar 2015 19:27:00 +0100 Subject: [PATCH] DBusSocket refactoring - windows part --- dbus/dbus-spawn-win.c | 12 ++++++------ dbus/dbus-sysdeps-win.c | 38 +++++++++++++++++++------------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/dbus/dbus-spawn-win.c b/dbus/dbus-spawn-win.c index 7da7a43..8b08c2c 100644 --- a/dbus/dbus-spawn-win.c +++ b/dbus/dbus-spawn-win.c @@ -77,8 +77,8 @@ struct DBusBabysitter char **envp; HANDLE child_handle; - int socket_to_babysitter; /* Connection to the babysitter thread */ - int socket_to_main; + DBusSocket socket_to_babysitter; /* Connection to the babysitter thread */ + DBusSocket socket_to_main; DBusWatchList *watches; DBusWatch *sitter_watch; @@ -171,10 +171,10 @@ close_socket_to_babysitter (DBusBabysitter *sitter) sitter->sitter_watch = NULL; } - if (sitter->socket_to_babysitter != -1) + if (sitter->socket_to_babysitter != INVALID_SOCKET) { _dbus_close_socket (sitter->socket_to_babysitter, NULL); - sitter->socket_to_babysitter = -1; + sitter->socket_to_babysitter = INVALID_SOCKET; } } @@ -198,10 +198,10 @@ _dbus_babysitter_unref (DBusBabysitter *sitter) { close_socket_to_babysitter (sitter); - if (sitter->socket_to_main != -1) + if (sitter->socket_to_main != INVALID_SOCKET) { _dbus_close_socket (sitter->socket_to_main, NULL); - sitter->socket_to_main = -1; + sitter->socket_to_main = INVALID_SOCKET; } PING(); diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 5025815..a7b24e2 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -52,7 +52,6 @@ #include "dbus-credentials.h" #include -#include #include #include @@ -376,7 +375,7 @@ _dbus_win_free_error_string (char *string) */ int -_dbus_read_socket (int fd, +_dbus_read_socket (DBusSocket fd, DBusString *buffer, int count) { @@ -446,7 +445,7 @@ _dbus_read_socket (int fd, * @returns the number of bytes written or -1 on error */ int -_dbus_write_socket (int fd, +_dbus_write_socket (DBusSocket fd, const DBusString *buffer, int start, int len) @@ -490,7 +489,7 @@ _dbus_write_socket (int fd, * @returns #FALSE if error set */ dbus_bool_t -_dbus_close_socket (int fd, +_dbus_close_socket (DBusSocket fd, DBusError *error) { _DBUS_ASSERT_ERROR_IS_CLEAR (error); @@ -580,7 +579,7 @@ _dbus_set_fd_nonblocking (int handle, * @returns total bytes written from both buffers, or -1 on error */ int -_dbus_write_socket_two (int fd, +_dbus_write_socket_two (DBusSocket fd, const DBusString *buffer1, int start1, int len1, @@ -646,7 +645,7 @@ _dbus_write_socket_two (int fd, dbus_bool_t _dbus_socket_is_invalid (int fd) { - return fd == INVALID_SOCKET ? TRUE : FALSE; + return fd == (int)INVALID_SOCKET ? TRUE : FALSE; } #if 0 @@ -1055,8 +1054,8 @@ failed: * @returns #FALSE on failure (if error is set) */ dbus_bool_t -_dbus_full_duplex_pipe (int *fd1, - int *fd2, +_dbus_full_duplex_pipe (DBusSocket *fd1, + DBusSocket *fd2, dbus_bool_t blocking, DBusError *error) { @@ -1507,7 +1506,7 @@ _dbus_connect_tcp_socket_with_nonce (const char *host, const char *noncefile, DBusError *error) { - int fd = -1, res; + SOCKET fd = INVALID_SOCKET, res; struct addrinfo hints; struct addrinfo *ai, *tmp; @@ -1579,7 +1578,7 @@ _dbus_connect_tcp_socket_with_nonce (const char *host, } freeaddrinfo(ai); - if (fd == -1) + if (fd == INVALID_SOCKET) { dbus_set_error (error, _dbus_error_from_errno (errno), @@ -1643,10 +1642,11 @@ _dbus_listen_tcp_socket (const char *host, const char *port, const char *family, DBusString *retport, - int **fds_p, + DBusSocket **fds_p, DBusError *error) { - int nlisten_fd = 0, *listen_fd = NULL, res, i, port_num = -1; + DBusSocket *listen_fd = NULL; + int nlisten_fd = 0, res, i, port_num = -1; struct addrinfo hints; struct addrinfo *ai, *tmp; @@ -1706,8 +1706,8 @@ _dbus_listen_tcp_socket (const char *host, tmp = ai; while (tmp) { - int fd = -1, *newlisten_fd; - if ((fd = socket (tmp->ai_family, SOCK_STREAM, 0)) == INVALID_SOCKET) + DBusSocket fd = INVALID_SOCKET, *newlisten_fd; + if ((fd = (DBusSocket)socket (tmp->ai_family, SOCK_STREAM, 0)) == INVALID_SOCKET) { DBUS_SOCKET_SET_ERRNO (); dbus_set_error (error, @@ -1849,10 +1849,10 @@ _dbus_listen_tcp_socket (const char *host, * @param listen_fd the listen file descriptor * @returns the connection fd of the client, or -1 on error */ -int -_dbus_accept (int listen_fd) +DBusSocket +_dbus_accept (DBusSocket listen_fd) { - int client_fd; + DBusSocket client_fd; retry: client_fd = accept (listen_fd, NULL, NULL); @@ -1873,7 +1873,7 @@ _dbus_accept (int listen_fd) dbus_bool_t -_dbus_send_credentials_socket (int handle, +_dbus_send_credentials_socket (DBusSocket handle, DBusError *error) { /* FIXME: for the session bus credentials shouldn't matter (?), but @@ -1950,7 +1950,7 @@ again: * @returns #TRUE on success */ dbus_bool_t -_dbus_read_credentials_socket (int handle, +_dbus_read_credentials_socket (DBusSocket handle, DBusCredentials *credentials, DBusError *error) { -- 1.8.4.5