Ignore:
Timestamp:
Nov 14, 2012, 12:59:34 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to 3.6.0

Location:
vendor/current/lib/async_req
Files:
1 added
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/lib/async_req/async_sock.c

    r414 r740  
    3737#endif
    3838
    39 struct async_send_state {
     39struct sendto_state {
    4040        int fd;
    4141        const void *buf;
    4242        size_t len;
    4343        int flags;
     44        const struct sockaddr_storage *addr;
     45        socklen_t addr_len;
    4446        ssize_t sent;
    4547};
    4648
    47 static void async_send_handler(struct tevent_context *ev,
     49static void sendto_handler(struct tevent_context *ev,
    4850                               struct tevent_fd *fde,
    4951                               uint16_t flags, void *private_data);
    5052
    51 struct tevent_req *async_send_send(TALLOC_CTX *mem_ctx,
    52                                    struct tevent_context *ev,
    53                                    int fd, const void *buf, size_t len,
    54                                    int flags)
     53struct tevent_req *sendto_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
     54                               int fd, const void *buf, size_t len, int flags,
     55                               const struct sockaddr_storage *addr)
    5556{
    5657        struct tevent_req *result;
    57         struct async_send_state *state;
     58        struct sendto_state *state;
    5859        struct tevent_fd *fde;
    5960
    60         result = tevent_req_create(mem_ctx, &state, struct async_send_state);
     61        result = tevent_req_create(mem_ctx, &state, struct sendto_state);
    6162        if (result == NULL) {
    6263                return result;
     
    6667        state->len = len;
    6768        state->flags = flags;
    68 
    69         fde = tevent_add_fd(ev, state, fd, TEVENT_FD_WRITE, async_send_handler,
     69        state->addr = addr;
     70
     71        switch (addr->ss_family) {
     72        case AF_INET:
     73                state->addr_len = sizeof(struct sockaddr_in);
     74                break;
     75#if defined(HAVE_IPV6)
     76        case AF_INET6:
     77                state->addr_len = sizeof(struct sockaddr_in6);
     78                break;
     79#endif
     80        case AF_UNIX:
     81                state->addr_len = sizeof(struct sockaddr_un);
     82                break;
     83        default:
     84                state->addr_len = sizeof(struct sockaddr_storage);
     85                break;
     86        }
     87
     88        fde = tevent_add_fd(ev, state, fd, TEVENT_FD_WRITE, sendto_handler,
    7089                            result);
    7190        if (fde == NULL) {
     
    7695}
    7796
    78 static void async_send_handler(struct tevent_context *ev,
     97static void sendto_handler(struct tevent_context *ev,
    7998                               struct tevent_fd *fde,
    8099                               uint16_t flags, void *private_data)
     
    82101        struct tevent_req *req = talloc_get_type_abort(
    83102                private_data, struct tevent_req);
    84         struct async_send_state *state =
    85                 tevent_req_data(req, struct async_send_state);
    86 
    87         state->sent = send(state->fd, state->buf, state->len, state->flags);
     103        struct sendto_state *state =
     104                tevent_req_data(req, struct sendto_state);
     105
     106        state->sent = sendto(state->fd, state->buf, state->len, state->flags,
     107                             (struct sockaddr *)state->addr, state->addr_len);
    88108        if ((state->sent == -1) && (errno == EINTR)) {
    89109                /* retry */
     
    97117}
    98118
    99 ssize_t async_send_recv(struct tevent_req *req, int *perrno)
    100 {
    101         struct async_send_state *state =
    102                 tevent_req_data(req, struct async_send_state);
     119ssize_t sendto_recv(struct tevent_req *req, int *perrno)
     120{
     121        struct sendto_state *state =
     122                tevent_req_data(req, struct sendto_state);
    103123
    104124        if (tevent_req_is_unix_error(req, perrno)) {
     
    108128}
    109129
    110 struct async_recv_state {
     130struct recvfrom_state {
    111131        int fd;
    112132        void *buf;
    113133        size_t len;
    114134        int flags;
     135        struct sockaddr_storage *addr;
     136        socklen_t *addr_len;
    115137        ssize_t received;
    116138};
    117139
    118 static void async_recv_handler(struct tevent_context *ev,
     140static void recvfrom_handler(struct tevent_context *ev,
    119141                               struct tevent_fd *fde,
    120142                               uint16_t flags, void *private_data);
    121143
    122 struct tevent_req *async_recv_send(TALLOC_CTX *mem_ctx,
    123                                    struct tevent_context *ev,
    124                                    int fd, void *buf, size_t len, int flags)
     144struct tevent_req *recvfrom_send(TALLOC_CTX *mem_ctx,
     145                                 struct tevent_context *ev,
     146                                 int fd, void *buf, size_t len, int flags,
     147                                 struct sockaddr_storage *addr,
     148                                 socklen_t *addr_len)
    125149{
    126150        struct tevent_req *result;
    127         struct async_recv_state *state;
     151        struct recvfrom_state *state;
    128152        struct tevent_fd *fde;
    129153
    130         result = tevent_req_create(mem_ctx, &state, struct async_recv_state);
     154        result = tevent_req_create(mem_ctx, &state, struct recvfrom_state);
    131155        if (result == NULL) {
    132156                return result;
     
    136160        state->len = len;
    137161        state->flags = flags;
    138 
    139         fde = tevent_add_fd(ev, state, fd, TEVENT_FD_READ, async_recv_handler,
     162        state->addr = addr;
     163        state->addr_len = addr_len;
     164
     165        fde = tevent_add_fd(ev, state, fd, TEVENT_FD_READ, recvfrom_handler,
    140166                            result);
    141167        if (fde == NULL) {
     
    146172}
    147173
    148 static void async_recv_handler(struct tevent_context *ev,
     174static void recvfrom_handler(struct tevent_context *ev,
    149175                               struct tevent_fd *fde,
    150176                               uint16_t flags, void *private_data)
     
    152178        struct tevent_req *req = talloc_get_type_abort(
    153179                private_data, struct tevent_req);
    154         struct async_recv_state *state =
    155                 tevent_req_data(req, struct async_recv_state);
    156 
    157         state->received = recv(state->fd, state->buf, state->len,
    158                                state->flags);
     180        struct recvfrom_state *state =
     181                tevent_req_data(req, struct recvfrom_state);
     182
     183        state->received = recvfrom(state->fd, state->buf, state->len,
     184                                   state->flags, (struct sockaddr *)state->addr,
     185                                   state->addr_len);
    159186        if ((state->received == -1) && (errno == EINTR)) {
    160187                /* retry */
     
    172199}
    173200
    174 ssize_t async_recv_recv(struct tevent_req *req, int *perrno)
    175 {
    176         struct async_recv_state *state =
    177                 tevent_req_data(req, struct async_recv_state);
     201ssize_t recvfrom_recv(struct tevent_req *req, int *perrno)
     202{
     203        struct recvfrom_state *state =
     204                tevent_req_data(req, struct recvfrom_state);
    178205
    179206        if (tevent_req_is_unix_error(req, perrno)) {
     
    359386        size_t total_size;
    360387        uint16_t flags;
     388        bool err_on_readability;
    361389};
    362390
     
    386414                goto fail;
    387415        }
    388         state->flags = TEVENT_FD_WRITE;
    389         if (err_on_readability) {
    390                 state->flags |= TEVENT_FD_READ;
    391         }
     416        state->flags = TEVENT_FD_WRITE|TEVENT_FD_READ;
     417        state->err_on_readability = err_on_readability;
    392418
    393419        if (queue == NULL) {
     
    435461
    436462        if ((state->flags & TEVENT_FD_READ) && (flags & TEVENT_FD_READ)) {
    437                 tevent_req_error(req, EPIPE);
    438                 return;
     463                int ret, value;
     464
     465                if (state->err_on_readability) {
     466                        /* Readable and the caller wants an error on read. */
     467                        tevent_req_error(req, EPIPE);
     468                        return;
     469                }
     470
     471                /* Might be an error. Check if there are bytes to read */
     472                ret = ioctl(state->fd, FIONREAD, &value);
     473                /* FIXME - should we also check
     474                   for ret == 0 and value == 0 here ? */
     475                if (ret == -1) {
     476                        /* There's an error. */
     477                        tevent_req_error(req, EPIPE);
     478                        return;
     479                }
     480                /* A request for TEVENT_FD_READ will succeed from now and
     481                   forevermore until the bytes are read so if there was
     482                   an error we'll wait until we do read, then get it in
     483                   the read callback function. Until then, remove TEVENT_FD_READ
     484                   from the flags we're waiting for. */
     485                state->flags &= ~TEVENT_FD_READ;
     486                TEVENT_FD_NOT_READABLE(fde);
     487
     488                /* If not writable, we're done. */
     489                if (!(flags & TEVENT_FD_WRITE)) {
     490                        return;
     491                }
    439492        }
    440493
  • vendor/current/lib/async_req/async_sock.h

    r414 r740  
    2828#include <tevent.h>
    2929
    30 struct tevent_req *async_send_send(TALLOC_CTX *mem_ctx,
    31                                    struct tevent_context *ev,
    32                                    int fd, const void *buf, size_t len,
    33                                    int flags);
    34 ssize_t async_send_recv(struct tevent_req *req, int *perrno);
     30struct tevent_req *sendto_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
     31                               int fd, const void *buf, size_t len, int flags,
     32                               const struct sockaddr_storage *addr);
     33ssize_t sendto_recv(struct tevent_req *req, int *perrno);
    3534
    36 struct tevent_req *async_recv_send(TALLOC_CTX *mem_ctx,
    37                                    struct tevent_context *ev,
    38                                    int fd, void *buf, size_t len, int flags);
    39 ssize_t async_recv_recv(struct tevent_req *req, int *perrno);
     35struct tevent_req *recvfrom_send(TALLOC_CTX *mem_ctx,
     36                                 struct tevent_context *ev,
     37                                 int fd, void *buf, size_t len, int flags,
     38                                 struct sockaddr_storage *addr,
     39                                 socklen_t *addr_len);
     40ssize_t recvfrom_recv(struct tevent_req *req, int *perrno);
    4041
    4142struct tevent_req *async_connect_send(TALLOC_CTX *mem_ctx,
Note: See TracChangeset for help on using the changeset viewer.