From: Matthew Barnes Date: Sun, 3 Nov 2013 18:02:23 +0000 (-0500) Subject: Remove unused camel_read/write_socket(). X-Git-Tag: submit/tizen/20140917.130222~406 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fba5e72b9f4ec69ada82456e3f0232fb52437462;p=platform%2Fupstream%2Fevolution-data-server.git Remove unused camel_read/write_socket(). --- diff --git a/camel/camel-file-utils.c b/camel/camel-file-utils.c index cd33c95..a4a80e3 100644 --- a/camel/camel-file-utils.c +++ b/camel/camel-file-utils.c @@ -609,197 +609,6 @@ camel_write (gint fd, } /** - * camel_read_socket: - * @fd: a socket - * @buf: buffer to fill - * @n: number of bytes to read into @buf - * @cancellable: optional #GCancellable object, or %NULL - * @error: return location for a #GError, or %NULL - * - * Cancellable read() replacement for sockets. Code that intends to be - * portable to Win32 should call this function only on sockets - * returned from socket(), or accept(). - * - * Returns: number of bytes read or -1 on fail. On failure, errno will - * be set appropriately. If the socket is nonblocking - * camel_read_socket() will retry the read until it gets something. - **/ -gssize -camel_read_socket (gint fd, - gchar *buf, - gsize n, - GCancellable *cancellable, - GError **error) -{ -#ifndef G_OS_WIN32 - return camel_read (fd, buf, n, cancellable, error); -#else - gssize nread; - gint cancel_fd; - - if (g_cancellable_set_error_if_cancelled (cancellable, error)) { - errno = EINTR; - return -1; - } - - cancel_fd = g_cancellable_get_fd (cancellable); - - if (cancel_fd == -1) { - do { - nread = recv (fd, buf, n, 0); - } while (nread == SOCKET_ERROR && WSAGetLastError () == WSAEWOULDBLOCK); - } else { - gint fdmax; - fd_set rdset; - u_long yes = 1; - - ioctlsocket (fd, FIONBIO, &yes); - fdmax = MAX (fd, cancel_fd) + 1; - do { - struct timeval tv; - gint res; - - FD_ZERO (&rdset); - FD_SET (fd, &rdset); - FD_SET (cancel_fd, &rdset); - tv.tv_sec = IO_TIMEOUT; - tv.tv_usec = 0; - nread = -1; - - res = select (fdmax, &rdset, 0, 0, &tv); - if (res == -1) - ; - else if (res == 0) - errno = EAGAIN; - else if (FD_ISSET (cancel_fd, &rdset)) { - errno = EINTR; - goto failed; - } else { - nread = recv (fd, buf, n, 0); - } - } while (nread == -1 && WSAGetLastError () == WSAEWOULDBLOCK); - failed: - ; - } - - g_cancellable_release_fd (cancellable); - - if (g_cancellable_set_error_if_cancelled (cancellable, error)) - return -1; - - if (nread == -1) - g_set_error ( - error, G_IO_ERROR, - g_io_error_from_errno (errno), - "%s", g_strerror (errno)); - - return nread; -#endif -} - -/** - * camel_write_socket: - * @fd: file descriptor - * @buf: buffer to write - * @n: number of bytes of @buf to write - * @error: return location for a #GError, or %NULL - * - * Cancellable write() replacement for sockets. Code that intends to - * be portable to Win32 should call this function only on sockets - * returned from socket() or accept(). - * - * Returns: number of bytes written or -1 on fail. On failure, errno will - * be set appropriately. - **/ -gssize -camel_write_socket (gint fd, - const gchar *buf, - gsize n, - GCancellable *cancellable, - GError **error) -{ -#ifndef G_OS_WIN32 - return camel_write (fd, buf, n, cancellable, error); -#else - gssize w, written = 0; - gint cancel_fd; - - if (g_cancellable_is_cancelled (cancellable)) { - errno = EINTR; - g_set_error ( - error, G_IO_ERROR, - G_IO_ERROR_CANCELLED, - _("Canceled")); - return -1; - } - - cancel_fd = g_cancellable_get_fd (cancellable); - - if (cancel_fd == -1) { - do { - do { - w = send (fd, buf + written, n - written, 0); - } while (w == SOCKET_ERROR && WSAGetLastError () == WSAEWOULDBLOCK); - if (w > 0) - written += w; - } while (w != -1 && written < n); - } else { - gint fdmax; - fd_set rdset, wrset; - u_long arg = 1; - - ioctlsocket (fd, FIONBIO, &arg); - fdmax = MAX (fd, cancel_fd) + 1; - do { - struct timeval tv; - gint res; - - FD_ZERO (&rdset); - FD_ZERO (&wrset); - FD_SET (fd, &wrset); - FD_SET (cancel_fd, &rdset); - tv.tv_sec = IO_TIMEOUT; - tv.tv_usec = 0; - w = -1; - - res = select (fdmax, &rdset, &wrset, 0, &tv); - if (res == SOCKET_ERROR) { - /* w still being -1 will catch this */ - } else if (res == 0) - errno = EAGAIN; - else if (FD_ISSET (cancel_fd, &rdset)) - errno = EINTR; - else { - w = send (fd, buf + written, n - written, 0); - if (w == SOCKET_ERROR) { - if (WSAGetLastError () == WSAEWOULDBLOCK) - w = 0; - } else - written += w; - } - } while (w != -1 && written < n); - arg = 0; - ioctlsocket (fd, FIONBIO, &arg); - } - - g_cancellable_release_fd (cancellable); - - if (g_cancellable_set_error_if_cancelled (cancellable, error)) - return -1; - - if (w == -1) { - g_set_error ( - error, G_IO_ERROR, - g_io_error_from_errno (errno), - "%s", g_strerror (errno)); - return -1; - } - - return written; -#endif -} - -/** * camel_file_util_savename: * @filename: a pathname * diff --git a/camel/camel-file-utils.h b/camel/camel-file-utils.h index e388d34..2381064 100644 --- a/camel/camel-file-utils.h +++ b/camel/camel-file-utils.h @@ -62,9 +62,7 @@ gchar *camel_file_util_safe_filename (const gchar *name); /* Code that intends to be portable to Win32 should use camel_read() * and camel_write() only on file descriptors returned from open(), * creat(), pipe() or fileno(). On Win32 camel_read() and - * camel_write() calls will not be cancellable. For sockets, use - * camel_read_socket() and camel_write_socket(). These are cancellable - * also on Win32. + * camel_write() calls will not be cancellable. */ gssize camel_read (gint fd, gchar *buf, @@ -77,17 +75,6 @@ gssize camel_write (gint fd, GCancellable *cancellable, GError **error); -gssize camel_read_socket (gint fd, - gchar *buf, - gsize n, - GCancellable *cancellable, - GError **error); -gssize camel_write_socket (gint fd, - const gchar *buf, - gsize n, - GCancellable *cancellable, - GError **error); - gchar * camel_file_util_savename (const gchar *filename); G_END_DECLS diff --git a/docs/reference/camel/camel-sections.txt b/docs/reference/camel/camel-sections.txt index 082ffbc..383373c 100644 --- a/docs/reference/camel/camel-sections.txt +++ b/docs/reference/camel/camel-sections.txt @@ -2696,8 +2696,6 @@ camel_file_util_decode_fixed_string camel_file_util_safe_filename camel_read camel_write -camel_read_socket -camel_write_socket camel_file_util_savename