nginx-0.0.1-2002-09-02-18:48:24 import
diff --git a/src/os/unix/freebsd/ngx_sendfile.c b/src/os/unix/freebsd/ngx_sendfile.c
index 1b60774..ff577db 100644
--- a/src/os/unix/freebsd/ngx_sendfile.c
+++ b/src/os/unix/freebsd/ngx_sendfile.c
@@ -1,5 +1,6 @@
#include <ngx_config.h>
+#include <ngx_core.h>
#include <ngx_types.h>
#include <ngx_file.h>
#include <ngx_socket.h>
@@ -14,12 +15,6 @@
check sent if errno == EINTR then should return right sent.
*/
-/*
- returns
- 0 done
- -1 error
-*/
-
#if (HAVE_FREEBSD_SENDFILE)
int ngx_sendfile(ngx_socket_t s,
@@ -50,7 +45,7 @@
if (err != NGX_EAGAIN && err != NGX_EINTR) {
ngx_log_error(NGX_LOG_ERR, log, err,
"ngx_sendfile: sendfile failed");
- return -1;
+ return NGX_ERROR;
} else {
ngx_log_error(NGX_LOG_INFO, log, err,
@@ -61,7 +56,7 @@
ngx_log_debug(log, "ngx_sendfile: %d, @%qd %qd:%d" _
rc _ offset _ *sent _ nbytes);
- return 0;
+ return NGX_OK;
}
#endif
diff --git a/src/os/unix/ngx_file.c b/src/os/unix/ngx_files.c
similarity index 80%
rename from src/os/unix/ngx_file.c
rename to src/os/unix/ngx_files.c
index 69b6975..a3dc36d 100644
--- a/src/os/unix/ngx_file.c
+++ b/src/os/unix/ngx_files.c
@@ -1,8 +1,19 @@
+#include <ngx_core.h>
+#include <ngx_file.h>
-ssize_t ngx_read_file(ngx_file_t file, char *buf, size_t size, off_t offset)
+ssize_t ngx_read_file(ngx_file_t *file, char *buf, size_t size, off_t offset)
{
- return pread(file->fd, buf, size, offset);
+ ssize_t n;
+
+ ngx_log_debug(file->log, "read: %x, %d, %qd" _ buf _ size _ offset);
+
+ n = pread(file->fd, buf, size, offset);
+
+ if (n == NGX_ERROR)
+ ngx_log_error(NGX_LOG_ERR, file->log, ngx_errno, "read() failed");
+
+ return n;
}
#if 0
diff --git a/src/os/unix/ngx_file.h b/src/os/unix/ngx_files.h
similarity index 82%
rename from src/os/unix/ngx_file.h
rename to src/os/unix/ngx_files.h
index 33ba6d8..9369db0 100644
--- a/src/os/unix/ngx_file.h
+++ b/src/os/unix/ngx_files.h
@@ -1,5 +1,5 @@
-#ifndef _NGX_FILE_H_INCLUDED_
-#define _NGX_FILE_H_INCLUDED_
+#ifndef _NGX_FILES_H_INCLUDED_
+#define _NGX_FILES_H_INCLUDED_
#include <sys/types.h>
@@ -12,7 +12,6 @@
#define ngx_open_file open
#define ngx_open_file_n "open()"
-#define ngx_read_file read
#define ngx_read_file_n "read()"
#define NGX_FILE_RDONLY O_RDONLY
@@ -29,4 +28,4 @@
#define ngx_file_mtime(sb) sb.st_mtime
-#endif /* _NGX_FILE_H_INCLUDED_ */
+#endif /* _NGX_FILES_H_INCLUDED_ */
diff --git a/src/os/unix/ngx_sendfile.h b/src/os/unix/ngx_sendfile.h
index 768e23c..c9a5923 100644
--- a/src/os/unix/ngx_sendfile.h
+++ b/src/os/unix/ngx_sendfile.h
@@ -3,7 +3,7 @@
#include <ngx_types.h>
-#include <ngx_file.h>
+#include <ngx_files.h>
#include <ngx_socket.h>
#include <ngx_log.h>
#include <ngx_sendv.h>
diff --git a/src/os/unix/ngx_sendv.c b/src/os/unix/ngx_sendv.c
index 22838c2..dec16a1 100644
--- a/src/os/unix/ngx_sendv.c
+++ b/src/os/unix/ngx_sendv.c
@@ -1,15 +1,18 @@
+#include <ngx_core.h>
#include <ngx_types.h>
#include <ngx_socket.h>
#include <ngx_sendv.h>
ssize_t ngx_sendv(ngx_socket_t s, ngx_iovec_t *iovec, int n, size_t *sent)
{
- ssize_t rc = writev(s, iovec, n);
+ ssize_t rc;
+
+ rc = writev(s, iovec, n);
if (rc == -1)
- return -1;
+ return NGX_ERROR;
*sent = rc;
- return 0;
+ return NGX_OK;
}
diff --git a/src/os/unix/ngx_time.h b/src/os/unix/ngx_time.h
index f81ee4e..42bb716 100644
--- a/src/os/unix/ngx_time.h
+++ b/src/os/unix/ngx_time.h
@@ -4,6 +4,8 @@
#include <ngx_config.h>
+typedef u_int ngx_msec_t;
+
typedef struct tm ngx_tm_t;
#define ngx_tm_sec tm_sec
@@ -18,7 +20,7 @@
void ngx_localtime(ngx_tm_t *tm);
-u_int ngx_msec(void);
+ngx_msec_t ngx_msec(void);
#endif /* _NGX_TIME_H_INCLUDED_ */
diff --git a/src/os/win32/ngx_errno.h b/src/os/win32/ngx_errno.h
index 5197fdd..bd20ddf 100644
--- a/src/os/win32/ngx_errno.h
+++ b/src/os/win32/ngx_errno.h
@@ -6,12 +6,14 @@
typedef DWORD ngx_err_t;
-#define ngx_errno GetLastError()
-#define ngx_socket_errno WSAGetLastError()
+#define ngx_errno GetLastError()
+#define ngx_socket_errno WSAGetLastError()
+#define ngx_set_socket_errno(err) WSASetLastError(err)
#define NGX_ENOENT ERROR_FILE_NOT_FOUND
#define NGX_EAGAIN WSAEWOULDBLOCK
#define NGX_EADDRINUSE WSAEADDRINUSE
+#define NGX_ETIMEDOUT WSAETIMEDOUT
int ngx_strerror_r(ngx_err_t err, char *errstr, size_t size);
diff --git a/src/os/win32/ngx_files.c b/src/os/win32/ngx_files.c
new file mode 100644
index 0000000..8a91901
--- /dev/null
+++ b/src/os/win32/ngx_files.c
@@ -0,0 +1,18 @@
+
+#include <ngx_core.h>
+#include <ngx_types.h>
+#include <ngx_file.h>
+
+ssize_t ngx_read_file(ngx_file_t *file, char *buf, size_t size, off_t offset)
+{
+ size_t n;
+
+ if (ReadFile(file->fd, buf, size, &n, NULL) == 0) {
+ ngx_log_error(NGX_LOG_ERR, file->log, ngx_errno, "ReadFile() failed");
+ return NGX_ERROR;
+ }
+
+ return n;
+}
+
+
diff --git a/src/os/win32/ngx_file.h b/src/os/win32/ngx_files.h
similarity index 83%
rename from src/os/win32/ngx_file.h
rename to src/os/win32/ngx_files.h
index aaae84b..bddfe0d 100644
--- a/src/os/win32/ngx_file.h
+++ b/src/os/win32/ngx_files.h
@@ -1,5 +1,5 @@
-#ifndef _NGX_FILE_H_INCLUDED_
-#define _NGX_FILE_H_INCLUDED_
+#ifndef _NGX_FILES_H_INCLUDED_
+#define _NGX_FILES_H_INCLUDED_
#include <ngx_config.h>
@@ -21,9 +21,9 @@
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, \
NULL, OPEN_EXISTING, 0, NULL)
-#define ngx_open_file_n "CreateFile"
+#define ngx_open_file_n "CreateFile()"
-#define NGX_FILE_RDONLY GENERIC_READ
+#define NGX_FILE_RDONLY GENERIC_READ
int ngx_file_type(char *filename, ngx_file_info_t *fi);
@@ -51,4 +51,7 @@
*/
-#endif /* _NGX_FILE_H_INCLUDED_ */
+#define ngx_read_file_n "ReadFile()"
+
+
+#endif /* _NGX_FILES_H_INCLUDED_ */
diff --git a/src/os/win32/ngx_sendfile.c b/src/os/win32/ngx_sendfile.c
index c41b3b3..560f50f 100644
--- a/src/os/win32/ngx_sendfile.c
+++ b/src/os/win32/ngx_sendfile.c
@@ -1,6 +1,8 @@
#include <ngx_config.h>
+#include <ngx_core.h>
#include <ngx_types.h>
+#include <ngx_files.h>
#include <ngx_socket.h>
#include <ngx_errno.h>
#include <ngx_log.h>
@@ -13,17 +15,11 @@
TransmitPackets
*/
-/*
- returns
- 0 done
- -1 error
-*/
-
#if (HAVE_WIN32_TRANSMITFILE)
int ngx_sendfile(ngx_socket_t s,
ngx_iovec_t *headers, int hdr_cnt,
- ngx_file_t fd, off_t offset, size_t nbytes,
+ ngx_fd_t fd, off_t offset, size_t nbytes,
ngx_iovec_t *trailers, int trl_cnt,
off_t *sent,
ngx_log_t *log)
@@ -65,15 +61,13 @@
/* set sent */
#if 0
rc = WSAGetOverlappedResult(s, &olp, (unsigned long *) sent, 0, NULL);
+#else
+ *sent = olp.InternalHigh;
+ rc = 1;
#endif
-#if 0
ngx_log_debug(log, "ngx_sendfile: %d, @%I64d %I64d:%d" _
tfrc _ offset _ *sent _ nbytes);
-#else
- ngx_log_debug(log, "ngx_sendfile: %d, @%I64d %d:%d" _
- tfrc _ offset _ olp.InternalHigh _ nbytes);
-#endif
if (rc == 0) {
err = ngx_socket_errno;
@@ -85,7 +79,7 @@
if (tf_err != NGX_EAGAIN) {
ngx_log_error(NGX_LOG_ERR, log, tf_err,
"ngx_sendfile: TransmitFile failed");
- return -1;
+ return NGX_ERROR;
}
ngx_log_error(NGX_LOG_INFO, log, tf_err,
@@ -94,9 +88,9 @@
}
if (rc == 0)
- return -1;
+ return NGX_ERROR;
- return 0;
+ return NGX_OK;
}
#endif
diff --git a/src/os/win32/ngx_sendfile.h b/src/os/win32/ngx_sendfile.h
index 053db8e..a80750b 100644
--- a/src/os/win32/ngx_sendfile.h
+++ b/src/os/win32/ngx_sendfile.h
@@ -4,13 +4,14 @@
#include <ngx_config.h>
#include <ngx_types.h>
+#include <ngx_files.h>
#include <ngx_socket.h>
#include <ngx_log.h>
#include <ngx_sendv.h>
int ngx_sendfile(ngx_socket_t s,
ngx_iovec_t *headers, int hdr_cnt,
- ngx_file_t fd, off_t offset, size_t nbytes,
+ ngx_fd_t fd, off_t offset, size_t nbytes,
ngx_iovec_t *trailers, int trl_cnt,
off_t *sent,
ngx_log_t *log);
diff --git a/src/os/win32/ngx_socket.h b/src/os/win32/ngx_socket.h
index 2708b5f..95e427c 100644
--- a/src/os/win32/ngx_socket.h
+++ b/src/os/win32/ngx_socket.h
@@ -5,7 +5,10 @@
#include <ngx_config.h>
#include <ngx_log.h>
+#define INET_ADDRSTRLEN 16
+
typedef SOCKET ngx_socket_t;
+typedef int socklen_t;
void ngx_init_sockets(ngx_log_t *log);
@@ -13,11 +16,12 @@
WSASocket(af, type, proto, NULL, 0, flags)
#define ngx_socket_n "WSASocket()"
-int ngx_nonblocking_n(s);
+int ngx_nonblocking(ngx_socket_t s);
#define ngx_nonblocking_n "ioctlsocket(FIONBIO)"
#define ngx_close_socket closesocket
#define ngx_close_socket_n "closesocket()"
+
#endif /* _NGX_SOCKET_H_INCLUDED_ */
diff --git a/src/os/win32/ngx_time.h b/src/os/win32/ngx_time.h
index be93244..a810c70 100644
--- a/src/os/win32/ngx_time.h
+++ b/src/os/win32/ngx_time.h
@@ -4,6 +4,8 @@
#include <windows.h>
+typedef unsigned int ngx_msec_t;
+
typedef SYSTEMTIME ngx_tm_t;
typedef FILETIME ngx_mtime_t;
diff --git a/src/os/win32/ngx_types.h b/src/os/win32/ngx_types.h
index fdf6ccd..7521633 100644
--- a/src/os/win32/ngx_types.h
+++ b/src/os/win32/ngx_types.h
@@ -5,6 +5,7 @@
#include <ngx_config.h>
+typedef int ssize_t;
typedef long time_t;