mirror of
https://github.com/nginx/nginx.git
synced 2024-11-24 04:49:01 +08:00
nginx-0.0.1-2002-08-23-20:14:30 import
This commit is contained in:
parent
4e5e117108
commit
83661a922b
@ -3,9 +3,11 @@ int ngx_posix_aio_process_events(ngx_log_t *log)
|
||||
{
|
||||
unmask signal
|
||||
|
||||
listen via signal;
|
||||
listen via SIGIO;
|
||||
|
||||
aio_suspend()/aiowait()/aio_waitcomplete();
|
||||
/* BUG: SIGIO can be delivered before aio_*() */
|
||||
|
||||
aio_suspend()/aiowait()/aio_waitcomplete() with timeout
|
||||
|
||||
mask signal
|
||||
|
||||
@ -20,7 +22,7 @@ int ngx_posix_aio_process_events(ngx_log_t *log)
|
||||
{
|
||||
unmask signal
|
||||
|
||||
/* BUG: signal can be delivered before select() */
|
||||
/* BUG: AIO signal can be delivered before select() */
|
||||
|
||||
select(listen);
|
||||
|
||||
|
@ -209,7 +209,12 @@ int ngx_http_filter_copy_hunk(ngx_hunk_t *dst, ngx_hunk_t *src, ngx_log_t *log)
|
||||
if (n == NGX_ERROR) {
|
||||
ngx_log_error(NGX_LOG_ERR, log, ngx_errno,
|
||||
ngx_read_file_n " failed for client");
|
||||
return NGX_ERROR;
|
||||
return n;
|
||||
|
||||
#if (NGX_FILE_AIO)
|
||||
} else if (n == NGX_AGAIN) {
|
||||
return n;
|
||||
#endif
|
||||
|
||||
} else {
|
||||
ngx_assert((n == size), /* void */ ; , log,
|
||||
@ -229,19 +234,3 @@ int ngx_http_filter_copy_hunk(ngx_hunk_t *dst, ngx_hunk_t *src, ngx_log_t *log)
|
||||
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* if no hunk is passed and there is no our hunk
|
||||
or our hunk is still busy then call next filter */
|
||||
if (hunk == NULL
|
||||
&& (ctx->hunk == NULL
|
||||
|| ((ctx->hunk != NULL)
|
||||
&& (ctx->hunk->pos.mem < ctx->hunk->last.mem))
|
||||
)
|
||||
)
|
||||
ctx->next_filter(r, NULL);
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ typedef int ngx_err_t;
|
||||
|
||||
#define ngx_errno errno
|
||||
#define ngx_socket_errno errno
|
||||
#define ngx_set_socket_errno(err) errno = err
|
||||
|
||||
#define ngx_strerror_r(err, errstr, size) \
|
||||
ngx_cpystrn(errstr, strerror(err), size) - (errstr)
|
||||
|
61
src/os/unix/ngx_file.c
Normal file
61
src/os/unix/ngx_file.c
Normal file
@ -0,0 +1,61 @@
|
||||
|
||||
|
||||
ssize_t ngx_read_file(ngx_file_t file, char *buf, size_t size)
|
||||
{
|
||||
read();
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
ssize_t ngx_read_file(ngx_file_t *file, char *buf, size_t size, off_t offset)
|
||||
{
|
||||
if (!file->read->ready) {
|
||||
|
||||
ngx_memzero(&file->iocb, sizeof(iocb));
|
||||
file->iocb.aio_fildes = file->fd;
|
||||
file->iocb.aio_buf = buf;
|
||||
file->iocb.aio_nbytes = size;
|
||||
file->iocb.aio_offset = offset;
|
||||
#if (USE_AIO_KQUEUE)
|
||||
file->iocb.aio_sigevent.sigev_notify = SIGEV_KEVENT;
|
||||
file->iocb.aio_sigevent.sigev_notify_kqueue = tid->kq;
|
||||
file->iocb.aio_sigevent.sigev_value = (union sigval) file;
|
||||
#endif
|
||||
#if (USE_AIO_SIGNAL)
|
||||
file->iocb.aio_sigevent.sigev_notify = SIGEV_SIGNAL;
|
||||
file->iocb.aio_sigevent.sigev_signo = NGX_SIGAIO;
|
||||
#ifndef __FreeBSD__
|
||||
file->iocb.aio_sigevent.sigev_value.sival_ptr = file;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (aio_read(&file->iocb) == -1) {
|
||||
ngx_log_error(NGX_LOG_ERR, file->log, ngx_errno,
|
||||
"aio_read() failed");
|
||||
return NGX_ERROR;
|
||||
|
||||
n = aio_error(&file->iocb);
|
||||
if (n == EINPROGRESS)
|
||||
return NGX_AGAIN;
|
||||
|
||||
if (n == -1) {
|
||||
ngx_log_error(NGX_LOG_ERR, file->log, ngx_errno,
|
||||
"aio_read() failed");
|
||||
return NGX_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
ngx_assert(file->iocb.aio_buf == buf), return NGX_ERROR,
|
||||
"ngx_aio_read_file: another buffer is passed");
|
||||
|
||||
n = aio_return(&file->iocb);
|
||||
if (n == -1) {
|
||||
ngx_log_error(NGX_LOG_ERR, file->log, ngx_errno,
|
||||
"aio_read() failed");
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
#endif
|
@ -10,16 +10,19 @@ typedef struct stat ngx_file_info_t;
|
||||
|
||||
|
||||
#define ngx_open_file open
|
||||
#define ngx_open_file_n "open"
|
||||
#define ngx_open_file_n "open()"
|
||||
|
||||
#define ngx_read_file read
|
||||
#define ngx_read_file_n "read()"
|
||||
|
||||
#define NGX_FILE_RDONLY O_RDONLY
|
||||
|
||||
|
||||
#define ngx_file_type(file, sb) stat(file, sb)
|
||||
#define ngx_file_type_n "stat"
|
||||
#define ngx_file_type_n "stat()"
|
||||
|
||||
#define ngx_stat_fd(fd, sb) fstat(fd, sb)
|
||||
#define ngx_stat_fd_n "fstat"
|
||||
#define ngx_stat_fd_n "fstat()"
|
||||
|
||||
#define ngx_is_dir(sb) (S_ISDIR(sb.st_mode))
|
||||
#define ngx_file_size(sb) sb.st_size
|
||||
|
Loading…
Reference in New Issue
Block a user