lib/async_req: remove unused sendto_{send,recv} and recvfrom_{send,recv}
authorStefan Metzmacher <metze@samba.org>
Thu, 21 May 2015 10:25:38 +0000 (12:25 +0200)
committerStefan Metzmacher <metze@samba.org>
Fri, 12 Jun 2015 15:08:17 +0000 (17:08 +0200)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
lib/async_req/async_sock.c
lib/async_req/async_sock.h

index ee91b8f..dfc81b8 100644 (file)
 #include "lib/util/tevent_unix.h"
 #include "lib/util/samba_util.h"
 
-#ifndef TALLOC_FREE
-#define TALLOC_FREE(ctx) do { talloc_free(ctx); ctx=NULL; } while(0)
-#endif
-
-struct sendto_state {
-       int fd;
-       const void *buf;
-       size_t len;
-       int flags;
-       const struct sockaddr_storage *addr;
-       socklen_t addr_len;
-       ssize_t sent;
-};
-
-static void sendto_handler(struct tevent_context *ev,
-                              struct tevent_fd *fde,
-                              uint16_t flags, void *private_data);
-
-struct tevent_req *sendto_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
-                              int fd, const void *buf, size_t len, int flags,
-                              const struct sockaddr_storage *addr)
-{
-       struct tevent_req *result;
-       struct sendto_state *state;
-       struct tevent_fd *fde;
-
-       result = tevent_req_create(mem_ctx, &state, struct sendto_state);
-       if (result == NULL) {
-               return result;
-       }
-       state->fd = fd;
-       state->buf = buf;
-       state->len = len;
-       state->flags = flags;
-       state->addr = addr;
-
-       switch (addr->ss_family) {
-       case AF_INET:
-               state->addr_len = sizeof(struct sockaddr_in);
-               break;
-#if defined(HAVE_IPV6)
-       case AF_INET6:
-               state->addr_len = sizeof(struct sockaddr_in6);
-               break;
-#endif
-       case AF_UNIX:
-               state->addr_len = sizeof(struct sockaddr_un);
-               break;
-       default:
-               state->addr_len = sizeof(struct sockaddr_storage);
-               break;
-       }
-
-       fde = tevent_add_fd(ev, state, fd, TEVENT_FD_WRITE, sendto_handler,
-                           result);
-       if (fde == NULL) {
-               TALLOC_FREE(result);
-               return NULL;
-       }
-       return result;
-}
-
-static void sendto_handler(struct tevent_context *ev,
-                              struct tevent_fd *fde,
-                              uint16_t flags, void *private_data)
-{
-       struct tevent_req *req = talloc_get_type_abort(
-               private_data, struct tevent_req);
-       struct sendto_state *state =
-               tevent_req_data(req, struct sendto_state);
-
-       state->sent = sendto(state->fd, state->buf, state->len, state->flags,
-                            (const struct sockaddr *)state->addr,
-                            state->addr_len);
-       if ((state->sent == -1) && (errno == EINTR)) {
-               /* retry */
-               return;
-       }
-       if (state->sent == -1) {
-               tevent_req_error(req, errno);
-               return;
-       }
-       tevent_req_done(req);
-}
-
-ssize_t sendto_recv(struct tevent_req *req, int *perrno)
-{
-       struct sendto_state *state =
-               tevent_req_data(req, struct sendto_state);
-
-       if (tevent_req_is_unix_error(req, perrno)) {
-               return -1;
-       }
-       return state->sent;
-}
-
-struct recvfrom_state {
-       int fd;
-       void *buf;
-       size_t len;
-       int flags;
-       struct sockaddr_storage *addr;
-       socklen_t *addr_len;
-       ssize_t received;
-};
-
-static void recvfrom_handler(struct tevent_context *ev,
-                              struct tevent_fd *fde,
-                              uint16_t flags, void *private_data);
-
-struct tevent_req *recvfrom_send(TALLOC_CTX *mem_ctx,
-                                struct tevent_context *ev,
-                                int fd, void *buf, size_t len, int flags,
-                                struct sockaddr_storage *addr,
-                                socklen_t *addr_len)
-{
-       struct tevent_req *result;
-       struct recvfrom_state *state;
-       struct tevent_fd *fde;
-
-       result = tevent_req_create(mem_ctx, &state, struct recvfrom_state);
-       if (result == NULL) {
-               return result;
-       }
-       state->fd = fd;
-       state->buf = buf;
-       state->len = len;
-       state->flags = flags;
-       state->addr = addr;
-       state->addr_len = addr_len;
-
-       fde = tevent_add_fd(ev, state, fd, TEVENT_FD_READ, recvfrom_handler,
-                           result);
-       if (fde == NULL) {
-               TALLOC_FREE(result);
-               return NULL;
-       }
-       return result;
-}
-
-static void recvfrom_handler(struct tevent_context *ev,
-                              struct tevent_fd *fde,
-                              uint16_t flags, void *private_data)
-{
-       struct tevent_req *req = talloc_get_type_abort(
-               private_data, struct tevent_req);
-       struct recvfrom_state *state =
-               tevent_req_data(req, struct recvfrom_state);
-
-       state->received = recvfrom(state->fd, state->buf, state->len,
-                                  state->flags, (struct sockaddr *)state->addr,
-                                  state->addr_len);
-       if ((state->received == -1) && (errno == EINTR)) {
-               /* retry */
-               return;
-       }
-       if (state->received == 0) {
-               tevent_req_error(req, EPIPE);
-               return;
-       }
-       if (state->received == -1) {
-               tevent_req_error(req, errno);
-               return;
-       }
-       tevent_req_done(req);
-}
-
-ssize_t recvfrom_recv(struct tevent_req *req, int *perrno)
-{
-       struct recvfrom_state *state =
-               tevent_req_data(req, struct recvfrom_state);
-
-       if (tevent_req_is_unix_error(req, perrno)) {
-               return -1;
-       }
-       return state->received;
-}
-
 struct async_connect_state {
        int fd;
        int result;
index 494b92e..1b76fab 100644 (file)
 #include <tevent.h>
 #include "system/network.h"
 
-struct tevent_req *sendto_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
-                              int fd, const void *buf, size_t len, int flags,
-                              const struct sockaddr_storage *addr);
-ssize_t sendto_recv(struct tevent_req *req, int *perrno);
-
-struct tevent_req *recvfrom_send(TALLOC_CTX *mem_ctx,
-                                struct tevent_context *ev,
-                                int fd, void *buf, size_t len, int flags,
-                                struct sockaddr_storage *addr,
-                                socklen_t *addr_len);
-ssize_t recvfrom_recv(struct tevent_req *req, int *perrno);
-
 struct tevent_req *async_connect_send(
        TALLOC_CTX *mem_ctx, struct tevent_context *ev, int fd,
        const struct sockaddr *address, socklen_t address_len,