Mercurial > hg > nginx
comparison src/os/win32/ngx_sendfile.c @ 8:708f8bb772ec
nginx-0.0.1-2002-09-02-18:48:24 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 02 Sep 2002 14:48:24 +0000 |
parents | c5f071d376e5 |
children | e8cdc2989cee |
comparison
equal
deleted
inserted
replaced
7:b5481d6fbbd4 | 8:708f8bb772ec |
---|---|
1 | 1 |
2 #include <ngx_config.h> | 2 #include <ngx_config.h> |
3 #include <ngx_core.h> | |
3 #include <ngx_types.h> | 4 #include <ngx_types.h> |
5 #include <ngx_files.h> | |
4 #include <ngx_socket.h> | 6 #include <ngx_socket.h> |
5 #include <ngx_errno.h> | 7 #include <ngx_errno.h> |
6 #include <ngx_log.h> | 8 #include <ngx_log.h> |
7 #include <ngx_sendv.h> | 9 #include <ngx_sendv.h> |
8 #include <ngx_sendfile.h> | 10 #include <ngx_sendfile.h> |
11 TODO: | 13 TODO: |
12 various flags | 14 various flags |
13 TransmitPackets | 15 TransmitPackets |
14 */ | 16 */ |
15 | 17 |
16 /* | |
17 returns | |
18 0 done | |
19 -1 error | |
20 */ | |
21 | |
22 #if (HAVE_WIN32_TRANSMITFILE) | 18 #if (HAVE_WIN32_TRANSMITFILE) |
23 | 19 |
24 int ngx_sendfile(ngx_socket_t s, | 20 int ngx_sendfile(ngx_socket_t s, |
25 ngx_iovec_t *headers, int hdr_cnt, | 21 ngx_iovec_t *headers, int hdr_cnt, |
26 ngx_file_t fd, off_t offset, size_t nbytes, | 22 ngx_fd_t fd, off_t offset, size_t nbytes, |
27 ngx_iovec_t *trailers, int trl_cnt, | 23 ngx_iovec_t *trailers, int trl_cnt, |
28 off_t *sent, | 24 off_t *sent, |
29 ngx_log_t *log) | 25 ngx_log_t *log) |
30 { | 26 { |
31 int tfrc, rc; | 27 int tfrc, rc; |
63 tf_err = ngx_socket_errno; | 59 tf_err = ngx_socket_errno; |
64 | 60 |
65 /* set sent */ | 61 /* set sent */ |
66 #if 0 | 62 #if 0 |
67 rc = WSAGetOverlappedResult(s, &olp, (unsigned long *) sent, 0, NULL); | 63 rc = WSAGetOverlappedResult(s, &olp, (unsigned long *) sent, 0, NULL); |
64 #else | |
65 *sent = olp.InternalHigh; | |
66 rc = 1; | |
68 #endif | 67 #endif |
69 | 68 |
70 #if 0 | |
71 ngx_log_debug(log, "ngx_sendfile: %d, @%I64d %I64d:%d" _ | 69 ngx_log_debug(log, "ngx_sendfile: %d, @%I64d %I64d:%d" _ |
72 tfrc _ offset _ *sent _ nbytes); | 70 tfrc _ offset _ *sent _ nbytes); |
73 #else | |
74 ngx_log_debug(log, "ngx_sendfile: %d, @%I64d %d:%d" _ | |
75 tfrc _ offset _ olp.InternalHigh _ nbytes); | |
76 #endif | |
77 | 71 |
78 if (rc == 0) { | 72 if (rc == 0) { |
79 err = ngx_socket_errno; | 73 err = ngx_socket_errno; |
80 ngx_log_error(NGX_LOG_ERR, log, err, | 74 ngx_log_error(NGX_LOG_ERR, log, err, |
81 "ngx_sendfile: WSAGetOverlappedResult failed"); | 75 "ngx_sendfile: WSAGetOverlappedResult failed"); |
83 | 77 |
84 if (tfrc == 0) { | 78 if (tfrc == 0) { |
85 if (tf_err != NGX_EAGAIN) { | 79 if (tf_err != NGX_EAGAIN) { |
86 ngx_log_error(NGX_LOG_ERR, log, tf_err, | 80 ngx_log_error(NGX_LOG_ERR, log, tf_err, |
87 "ngx_sendfile: TransmitFile failed"); | 81 "ngx_sendfile: TransmitFile failed"); |
88 return -1; | 82 return NGX_ERROR; |
89 } | 83 } |
90 | 84 |
91 ngx_log_error(NGX_LOG_INFO, log, tf_err, | 85 ngx_log_error(NGX_LOG_INFO, log, tf_err, |
92 "ngx_sendfile: TransmitFile sent only %I64d bytes", | 86 "ngx_sendfile: TransmitFile sent only %I64d bytes", |
93 *sent); | 87 *sent); |
94 } | 88 } |
95 | 89 |
96 if (rc == 0) | 90 if (rc == 0) |
97 return -1; | 91 return NGX_ERROR; |
98 | 92 |
99 return 0; | 93 return NGX_OK; |
100 } | 94 } |
101 | 95 |
102 #endif | 96 #endif |