Skip to content
Snippets Groups Projects
Commit 023e6880 authored by Henrik (Grubba) Grubbström's avatar Henrik (Grubba) Grubbström
Browse files

Extracted low_do_sendfile() from worker().

Made low_do_sendfile() globally visible.

Rev: src/modules/files/file.h:1.14
Rev: src/modules/files/sendfile.c:1.33
parent 02fdbf3f
No related branches found
No related tags found
No related merge requests found
......@@ -5,7 +5,7 @@
\*/
/*
* $Id: file.h,v 1.13 1999/09/29 14:55:44 mirar Exp $
* $Id: file.h,v 1.14 2000/01/27 15:35:22 grubba Exp $
*/
#ifndef FILE_H
......@@ -47,6 +47,52 @@ struct my_file
struct object *myself;
};
#ifdef _REENTRANT
#ifndef HAVE_STRUCT_IOVEC
struct iovec {
void *iov_base;
int iov_len;
};
#endif /* !HAVE_STRUCT_IOVEC */
struct pike_sendfile
{
struct object *self;
int sent;
struct array *headers;
struct array *trailers;
struct object *from_file;
struct object *to_file;
struct svalue callback;
struct array *args;
int from_fd;
int to_fd;
struct my_file *from;
struct my_file *to;
INT_TYPE offset;
INT_TYPE len;
struct iovec *hd_iov;
struct iovec *tr_iov;
int hd_cnt;
int tr_cnt;
struct iovec *iovs;
char *buffer;
};
#endif /* _REENTRANT */
extern struct program *file_program;
extern struct program *file_ref_program;
......@@ -58,6 +104,8 @@ static void PIKE_CONCAT(file_set_,X) (INT32 args); \
static void PIKE_CONCAT(file_query_,X) (INT32 args); \
void low_do_sendfile(struct pike_sendfile *);
/* Prototypes begin here */
void my_set_close_on_exec(int fd, int to);
void do_set_close_on_exec(void);
......
/*
* $Id: sendfile.c,v 1.32 2000/01/24 21:42:59 grubba Exp $
* $Id: sendfile.c,v 1.33 2000/01/27 15:35:22 grubba Exp $
*
* Sends headers + from_fd[off..off+len-1] + trailers to to_fd asyncronously.
*
......@@ -97,53 +97,6 @@
*/
#ifdef _REENTRANT
/*
* Struct's
*/
#ifndef HAVE_STRUCT_IOVEC
struct iovec {
void *iov_base;
int iov_len;
};
#endif /* !HAVE_STRUCT_IOVEC */
struct pike_sendfile
{
struct object *self;
int sent;
struct array *headers;
struct array *trailers;
struct object *from_file;
struct object *to_file;
struct svalue callback;
struct array *args;
int from_fd;
int to_fd;
struct my_file *from;
struct my_file *to;
INT_TYPE offset;
INT_TYPE len;
struct iovec *hd_iov;
struct iovec *tr_iov;
int hd_cnt;
int tr_cnt;
struct iovec *iovs;
char *buffer;
};
#undef THIS
#define THIS ((struct pike_sendfile *)(fp->current_storage))
......@@ -227,7 +180,7 @@ static int writev(int fd, struct iovec *iov, int n)
* Helper functions
*/
void sf_call_callback(struct pike_sendfile *this)
static void sf_call_callback(struct pike_sendfile *this)
{
if (this->callback.type != T_INT) {
int sz = this->args->size;
......@@ -248,7 +201,7 @@ void sf_call_callback(struct pike_sendfile *this)
}
}
void call_callback_and_free(struct callback *cb, void *this_, void *arg)
static void call_callback_and_free(struct callback *cb, void *this_, void *arg)
{
struct pike_sendfile *this = this_;
int sz;
......@@ -276,7 +229,7 @@ void call_callback_and_free(struct callback *cb, void *this_, void *arg)
*/
/* writev() without the IOV_MAX limit. */
int send_iov(int fd, struct iovec *iov, int iovcnt)
static int send_iov(int fd, struct iovec *iov, int iovcnt)
{
int sent = 0;
......@@ -318,10 +271,8 @@ int send_iov(int fd, struct iovec *iov, int iovcnt)
return sent;
}
void worker(void *this_)
void low_do_sendfile(struct pike_sendfile *this)
{
struct pike_sendfile *this = this_;
/* Make sure we're using blocking I/O */
set_nonblocking(this->to_fd, 0);
......@@ -585,6 +536,13 @@ void worker(void *this_)
SF_DFPRINTF((stderr,
"sendfile: Done. Setting up callback\n"
"%d bytes sent\n", this->sent));
}
static void worker(void *this_)
{
struct pike_sendfile *this = this_;
low_do_sendfile(this);
mt_lock(&interpreter_lock);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment