Mercurial > hg > nginx
comparison src/os/unix/ngx_file.c @ 5:62b1a364857c
nginx-0.0.1-2002-08-23-20:14:30 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Fri, 23 Aug 2002 16:14:30 +0000 |
parents | |
children | 669801705ab1 |
comparison
equal
deleted
inserted
replaced
4:c5f071d376e5 | 5:62b1a364857c |
---|---|
1 | |
2 | |
3 ssize_t ngx_read_file(ngx_file_t file, char *buf, size_t size) | |
4 { | |
5 read(); | |
6 } | |
7 | |
8 #if 0 | |
9 | |
10 ssize_t ngx_read_file(ngx_file_t *file, char *buf, size_t size, off_t offset) | |
11 { | |
12 if (!file->read->ready) { | |
13 | |
14 ngx_memzero(&file->iocb, sizeof(iocb)); | |
15 file->iocb.aio_fildes = file->fd; | |
16 file->iocb.aio_buf = buf; | |
17 file->iocb.aio_nbytes = size; | |
18 file->iocb.aio_offset = offset; | |
19 #if (USE_AIO_KQUEUE) | |
20 file->iocb.aio_sigevent.sigev_notify = SIGEV_KEVENT; | |
21 file->iocb.aio_sigevent.sigev_notify_kqueue = tid->kq; | |
22 file->iocb.aio_sigevent.sigev_value = (union sigval) file; | |
23 #endif | |
24 #if (USE_AIO_SIGNAL) | |
25 file->iocb.aio_sigevent.sigev_notify = SIGEV_SIGNAL; | |
26 file->iocb.aio_sigevent.sigev_signo = NGX_SIGAIO; | |
27 #ifndef __FreeBSD__ | |
28 file->iocb.aio_sigevent.sigev_value.sival_ptr = file; | |
29 #endif | |
30 #endif | |
31 | |
32 if (aio_read(&file->iocb) == -1) { | |
33 ngx_log_error(NGX_LOG_ERR, file->log, ngx_errno, | |
34 "aio_read() failed"); | |
35 return NGX_ERROR; | |
36 | |
37 n = aio_error(&file->iocb); | |
38 if (n == EINPROGRESS) | |
39 return NGX_AGAIN; | |
40 | |
41 if (n == -1) { | |
42 ngx_log_error(NGX_LOG_ERR, file->log, ngx_errno, | |
43 "aio_read() failed"); | |
44 return NGX_ERROR; | |
45 } | |
46 } | |
47 | |
48 ngx_assert(file->iocb.aio_buf == buf), return NGX_ERROR, | |
49 "ngx_aio_read_file: another buffer is passed"); | |
50 | |
51 n = aio_return(&file->iocb); | |
52 if (n == -1) { | |
53 ngx_log_error(NGX_LOG_ERR, file->log, ngx_errno, | |
54 "aio_read() failed"); | |
55 return NGX_ERROR; | |
56 } | |
57 | |
58 return n; | |
59 } | |
60 | |
61 #endif |