diff options
author | Stefan Metzmacher <metze@samba.org> | 2015-05-21 12:25:38 +0200 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2015-06-12 17:08:17 +0200 |
commit | ccd038e1523a69197a9aaeca00305b0958f09ff0 (patch) | |
tree | bb03371c3e252ea15a1741b4a4a15307c22c4cb9 /lib/async_req | |
parent | a3282911f6ceb76b2ada567e569a55af8c7ef160 (diff) | |
download | samba-ccd038e1523a69197a9aaeca00305b0958f09ff0.tar.gz |
lib/async_req: remove unused sendto_{send,recv} and recvfrom_{send,recv}
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>
Diffstat (limited to 'lib/async_req')
-rw-r--r-- | lib/async_req/async_sock.c | 178 | ||||
-rw-r--r-- | lib/async_req/async_sock.h | 12 |
2 files changed, 0 insertions, 190 deletions
diff --git a/lib/async_req/async_sock.c b/lib/async_req/async_sock.c index ee91b8f16c8..dfc81b8430b 100644 --- a/lib/async_req/async_sock.c +++ b/lib/async_req/async_sock.c @@ -33,184 +33,6 @@ #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; diff --git a/lib/async_req/async_sock.h b/lib/async_req/async_sock.h index 494b92eb29f..1b76fabed53 100644 --- a/lib/async_req/async_sock.h +++ b/lib/async_req/async_sock.h @@ -28,18 +28,6 @@ #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, |