From: James Peach Date: Mon, 15 Oct 2007 21:38:33 +0000 (-0700) Subject: Store sendfile capability per-fsp. X-Git-Url: http://git.samba.org/?p=jpeach%2Fsamba.git;a=commitdiff_plain;h=cc48f6f58ae38d41261e9835ab7199994910888a;hp=55bf079402577657d2a11a5a22cd099ead07123d Store sendfile capability per-fsp. This patch adds a bit to the fsp structure to tell the network send path whether this file data can safely be sent using the sendfile(2) system call. This is a useful facility for VFS authors, since sometimes a VFS may need to present a non-file object as a file. In this case, sendfile should not be used. --- diff --git a/source/include/smb.h b/source/include/smb.h index 2b20cfa34fb..d0df005f544 100644 --- a/source/include/smb.h +++ b/source/include/smb.h @@ -520,6 +520,7 @@ typedef struct files_struct { BOOL modified; BOOL is_directory; BOOL is_stat; + BOOL is_sendfile_capable; BOOL aio_write_behind; BOOL lockdb_clean; BOOL initial_delete_on_close; /* Only set at NTCreateX if file was created. */ diff --git a/source/modules/vfs_default.c b/source/modules/vfs_default.c index 286ea1a897f..503577e9ba7 100644 --- a/source/modules/vfs_default.c +++ b/source/modules/vfs_default.c @@ -195,6 +195,11 @@ static int vfswrap_open(vfs_handle_struct *handle, const char *fname, START_PROFILE(syscall_open); result = sys_open(fname, flags, mode); END_PROFILE(syscall_open); + + if (result != -1) { + fsp->is_sendfile_capable = lp_use_sendfile(SNUM(handle->conn)); + } + return result; } diff --git a/source/smbd/reply.c b/source/smbd/reply.c index fc85cece8db..cee8d771ffd 100644 --- a/source/smbd/reply.c +++ b/source/smbd/reply.c @@ -2218,7 +2218,7 @@ void send_file_readbraw(connection_struct *conn, files_struct *fsp, SMB_OFF_T st */ if ( (chain_size == 0) && (nread > 0) && - (fsp->wcp == NULL) && lp_use_sendfile(SNUM(conn)) ) { + (fsp->wcp == NULL) && (fsp->is_sendfile_capable) ) { DATA_BLOB header; _smb_setlen(outbuf,nread); @@ -2561,7 +2561,7 @@ int send_file_readX(connection_struct *conn, char *inbuf,char *outbuf,int length */ if ((chain_size == 0) && (CVAL(inbuf,smb_vwv0) == 0xFF) && - lp_use_sendfile(SNUM(conn)) && (fsp->wcp == NULL) ) { + (fsp->is_sendfile_capable) && (fsp->wcp == NULL) ) { SMB_STRUCT_STAT sbuf; DATA_BLOB header;