aboutsummaryrefslogtreecommitdiff
path: root/src/os/win32/ngx_sendfile.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2003-02-06 17:21:13 +0000
committerIgor Sysoev <igor@sysoev.ru>2003-02-06 17:21:13 +0000
commit7300977320e04280c13d4d89a279f75af9c5f893 (patch)
tree6c935b625eb2dbd83e71e5b2e23ac83bfd88aded /src/os/win32/ngx_sendfile.c
parent2a2d2b5094ee88dba5984eddfc4135b66bb8007e (diff)
downloadnginx-7300977320e04280c13d4d89a279f75af9c5f893.tar.gz
nginx-7300977320e04280c13d4d89a279f75af9c5f893.zip
nginx-0.0.1-2003-02-06-20:21:13 import
Diffstat (limited to 'src/os/win32/ngx_sendfile.c')
-rw-r--r--src/os/win32/ngx_sendfile.c70
1 files changed, 59 insertions, 11 deletions
diff --git a/src/os/win32/ngx_sendfile.c b/src/os/win32/ngx_sendfile.c
index 560f50f7b..ce43b37b3 100644
--- a/src/os/win32/ngx_sendfile.c
+++ b/src/os/win32/ngx_sendfile.c
@@ -6,6 +6,7 @@
#include <ngx_socket.h>
#include <ngx_errno.h>
#include <ngx_log.h>
+#include <ngx_connection.h>
#include <ngx_sendv.h>
#include <ngx_sendfile.h>
@@ -17,18 +18,51 @@
#if (HAVE_WIN32_TRANSMITFILE)
-int ngx_sendfile(ngx_socket_t s,
+int ngx_sendfile(ngx_connection_t *c,
ngx_iovec_t *headers, int hdr_cnt,
ngx_fd_t fd, off_t offset, size_t nbytes,
ngx_iovec_t *trailers, int trl_cnt,
- off_t *sent,
- ngx_log_t *log)
+ off_t *sent, u_int flags)
{
int tfrc, rc;
ngx_err_t tf_err, err;
OVERLAPPED olp;
TRANSMIT_FILE_BUFFERS tfb, *ptfb;
+#if 0
+ ev = c->write;
+
+ if (ev->timedout) {
+ ngx_set_socket_errno(NGX_ETIMEDOUT);
+ ngx_log_error(NGX_LOG_ERR, ev->log, 0, "TransmitFile() timed out");
+
+ return NGX_ERROR;
+ }
+
+ if (ev->ready) {
+ ev->ready = 0;
+
+#if (HAVE_IOCP_EVENT) /* iocp */
+
+ if (ngx_event_flags & NGX_HAVE_IOCP_EVENT) {
+ if (ev->ovlp.error) {
+ ngx_log_error(NGX_LOG_ERR, ev->log, 0, "TransmitFile() failed");
+ return NGX_ERROR;
+ }
+
+ return ev->available;
+ }
+ }
+
+#endif
+
+ /* TODO: WSAGetOverlappedResult stuff */
+
+ }
+
+#endif
+
+
tf_err = 0;
err = 0;
@@ -49,40 +83,54 @@ int ngx_sendfile(ngx_socket_t s,
ptfb = NULL;
}
+#if 0
+ flags = TF_DISCONNECT|TF_REUSE_SOCKET;
+#endif
+
+ tfrc = TransmitFile(c->fd, fd, nbytes, 0, &olp, ptfb, flags);
+
+#if 0
#if 1
- tfrc = TransmitFile(s, fd, nbytes, 0, &olp, ptfb, 0);
+ tfrc = TransmitFile(c->fd, fd, nbytes, 0, &olp, ptfb, 0);
#else
- tfrc = TransmitFile(s, fd, nbytes, 0, NULL, ptfb, 0);
+ tfrc = TransmitFile(c->fd, fd, nbytes, 0, NULL, ptfb, 0);
+#endif
#endif
- if (tfrc == 0)
+ if (tfrc == 0) {
tf_err = ngx_socket_errno;
+ ngx_log_error(NGX_LOG_NOTICE, c->log, tf_err,
+ "ngx_sendfile: TransmitFile failed");
+ if (tf_err == WSA_IO_PENDING) {
+ return NGX_AGAIN;
+ }
+ }
/* set sent */
#if 0
- rc = WSAGetOverlappedResult(s, &olp, (unsigned long *) sent, 0, NULL);
+ rc = WSAGetOverlappedResult(c->fd, &olp, (unsigned long *) sent, 0, NULL);
#else
*sent = olp.InternalHigh;
rc = 1;
#endif
- ngx_log_debug(log, "ngx_sendfile: %d, @%I64d %I64d:%d" _
+ ngx_log_debug(c->log, "TransmitFile: %d, @%I64d %I64d:%d" _
tfrc _ offset _ *sent _ nbytes);
if (rc == 0) {
err = ngx_socket_errno;
- ngx_log_error(NGX_LOG_ERR, log, err,
+ ngx_log_error(NGX_LOG_ERR, c->log, err,
"ngx_sendfile: WSAGetOverlappedResult failed");
}
if (tfrc == 0) {
if (tf_err != NGX_EAGAIN) {
- ngx_log_error(NGX_LOG_ERR, log, tf_err,
+ ngx_log_error(NGX_LOG_ERR, c->log, tf_err,
"ngx_sendfile: TransmitFile failed");
return NGX_ERROR;
}
- ngx_log_error(NGX_LOG_INFO, log, tf_err,
+ ngx_log_error(NGX_LOG_INFO, c->log, tf_err,
"ngx_sendfile: TransmitFile sent only %I64d bytes",
*sent);
}