Back to home page

Nginx displayed by LXR

Source navigation ]
Diff markup ]
Identifier search ]
general search ]
 
 
Version: nginx-1.13.12 ]​[ nginx-1.12.2 ]​

0001 
0002 /*
0003  * Copyright (C) Igor Sysoev
0004  * Copyright (C) Nginx, Inc.
0005  */
0006 
0007 
0008 #include <ngx_config.h>
0009 #include <ngx_core.h>
0010 #include <ngx_event.h>
0011 
0012 
0013 ssize_t
0014 ngx_udp_unix_send(ngx_connection_t *c, u_char *buf, size_t size)
0015 {
0016     ssize_t       n;
0017     ngx_err_t     err;
0018     ngx_event_t  *wev;
0019 
0020     wev = c->write;
0021 
0022     for ( ;; ) {
0023         n = sendto(c->fd, buf, size, 0, c->sockaddr, c->socklen);
0024 
0025         ngx_log_debug4(NGX_LOG_DEBUG_EVENT, c->log, 0,
0026                        "sendto: fd:%d %z of %uz to \"%V\"",
0027                        c->fd, n, size, &c->addr_text);
0028 
0029         if (n >= 0) {
0030             if ((size_t) n != size) {
0031                 wev->error = 1;
0032                 (void) ngx_connection_error(c, 0, "sendto() incomplete");
0033                 return NGX_ERROR;
0034             }
0035 
0036             c->sent += n;
0037 
0038             return n;
0039         }
0040 
0041         err = ngx_socket_errno;
0042 
0043         if (err == NGX_EAGAIN) {
0044             wev->ready = 0;
0045             ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, NGX_EAGAIN,
0046                            "sendto() not ready");
0047             return NGX_AGAIN;
0048         }
0049 
0050         if (err != NGX_EINTR) {
0051             wev->error = 1;
0052             (void) ngx_connection_error(c, err, "sendto() failed");
0053             return NGX_ERROR;
0054         }
0055     }
0056 }