aboutsummaryrefslogtreecommitdiff
path: root/src/os/unix
diff options
context:
space:
mode:
Diffstat (limited to 'src/os/unix')
-rw-r--r--src/os/unix/ngx_darwin_init.c1
-rw-r--r--src/os/unix/ngx_freebsd_init.c1
-rw-r--r--src/os/unix/ngx_linux_init.c1
-rw-r--r--src/os/unix/ngx_os.h2
-rw-r--r--src/os/unix/ngx_posix_init.c1
-rw-r--r--src/os/unix/ngx_solaris_init.c1
-rw-r--r--src/os/unix/ngx_udp_send.c56
7 files changed, 63 insertions, 0 deletions
diff --git a/src/os/unix/ngx_darwin_init.c b/src/os/unix/ngx_darwin_init.c
index 1bc7520ca..a9d12a823 100644
--- a/src/os/unix/ngx_darwin_init.c
+++ b/src/os/unix/ngx_darwin_init.c
@@ -23,6 +23,7 @@ static ngx_os_io_t ngx_darwin_io = {
ngx_readv_chain,
ngx_udp_unix_recv,
ngx_unix_send,
+ ngx_udp_unix_send,
#if (NGX_HAVE_SENDFILE)
ngx_darwin_sendfile_chain,
NGX_IO_SENDFILE
diff --git a/src/os/unix/ngx_freebsd_init.c b/src/os/unix/ngx_freebsd_init.c
index c4c12dd74..71672c70b 100644
--- a/src/os/unix/ngx_freebsd_init.c
+++ b/src/os/unix/ngx_freebsd_init.c
@@ -32,6 +32,7 @@ static ngx_os_io_t ngx_freebsd_io = {
ngx_readv_chain,
ngx_udp_unix_recv,
ngx_unix_send,
+ ngx_udp_unix_send,
#if (NGX_HAVE_SENDFILE)
ngx_freebsd_sendfile_chain,
NGX_IO_SENDFILE
diff --git a/src/os/unix/ngx_linux_init.c b/src/os/unix/ngx_linux_init.c
index b306cda7c..a1372e960 100644
--- a/src/os/unix/ngx_linux_init.c
+++ b/src/os/unix/ngx_linux_init.c
@@ -18,6 +18,7 @@ static ngx_os_io_t ngx_linux_io = {
ngx_readv_chain,
ngx_udp_unix_recv,
ngx_unix_send,
+ ngx_udp_unix_send,
#if (NGX_HAVE_SENDFILE)
ngx_linux_sendfile_chain,
NGX_IO_SENDFILE
diff --git a/src/os/unix/ngx_os.h b/src/os/unix/ngx_os.h
index d8bcb0140..c0d59ef71 100644
--- a/src/os/unix/ngx_os.h
+++ b/src/os/unix/ngx_os.h
@@ -28,6 +28,7 @@ typedef struct {
ngx_recv_chain_pt recv_chain;
ngx_recv_pt udp_recv;
ngx_send_pt send;
+ ngx_send_pt udp_send;
ngx_send_chain_pt send_chain;
ngx_uint_t flags;
} ngx_os_io_t;
@@ -47,6 +48,7 @@ ssize_t ngx_udp_unix_recv(ngx_connection_t *c, u_char *buf, size_t size);
ssize_t ngx_unix_send(ngx_connection_t *c, u_char *buf, size_t size);
ngx_chain_t *ngx_writev_chain(ngx_connection_t *c, ngx_chain_t *in,
off_t limit);
+ssize_t ngx_udp_unix_send(ngx_connection_t *c, u_char *buf, size_t size);
#if (IOV_MAX > 64)
diff --git a/src/os/unix/ngx_posix_init.c b/src/os/unix/ngx_posix_init.c
index 61cc8ca7f..76ed94e90 100644
--- a/src/os/unix/ngx_posix_init.c
+++ b/src/os/unix/ngx_posix_init.c
@@ -24,6 +24,7 @@ ngx_os_io_t ngx_os_io = {
ngx_readv_chain,
ngx_udp_unix_recv,
ngx_unix_send,
+ ngx_udp_unix_send,
ngx_writev_chain,
0
};
diff --git a/src/os/unix/ngx_solaris_init.c b/src/os/unix/ngx_solaris_init.c
index f2f3600da..83acae144 100644
--- a/src/os/unix/ngx_solaris_init.c
+++ b/src/os/unix/ngx_solaris_init.c
@@ -19,6 +19,7 @@ static ngx_os_io_t ngx_solaris_io = {
ngx_readv_chain,
ngx_udp_unix_recv,
ngx_unix_send,
+ ngx_udp_unix_send,
#if (NGX_HAVE_SENDFILE)
ngx_solaris_sendfilev_chain,
NGX_IO_SENDFILE
diff --git a/src/os/unix/ngx_udp_send.c b/src/os/unix/ngx_udp_send.c
new file mode 100644
index 000000000..aabbc8e8b
--- /dev/null
+++ b/src/os/unix/ngx_udp_send.c
@@ -0,0 +1,56 @@
+
+/*
+ * Copyright (C) Igor Sysoev
+ * Copyright (C) Nginx, Inc.
+ */
+
+
+#include <ngx_config.h>
+#include <ngx_core.h>
+#include <ngx_event.h>
+
+
+ssize_t
+ngx_udp_unix_send(ngx_connection_t *c, u_char *buf, size_t size)
+{
+ ssize_t n;
+ ngx_err_t err;
+ ngx_event_t *wev;
+
+ wev = c->write;
+
+ for ( ;; ) {
+ n = sendto(c->fd, buf, size, 0, c->sockaddr, c->socklen);
+
+ ngx_log_debug4(NGX_LOG_DEBUG_EVENT, c->log, 0,
+ "sendto: fd:%d %z of %uz to \"%V\"",
+ c->fd, n, size, &c->addr_text);
+
+ if (n >= 0) {
+ if ((size_t) n != size) {
+ wev->error = 1;
+ (void) ngx_connection_error(c, 0, "sendto() incomplete");
+ return NGX_ERROR;
+ }
+
+ c->sent += n;
+
+ return n;
+ }
+
+ err = ngx_socket_errno;
+
+ if (err == NGX_EAGAIN) {
+ wev->ready = 0;
+ ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, NGX_EAGAIN,
+ "sendto() not ready");
+ return NGX_AGAIN;
+ }
+
+ if (err != NGX_EINTR) {
+ wev->error = 1;
+ (void) ngx_connection_error(c, err, "sendto() failed");
+ return NGX_ERROR;
+ }
+ }
+}