[SSI] openssi/kernel/cluster/ssi/vproc rproc_svr_pproc.c, 1.34, 1.35
Roger Tsang <[email protected]> Mon, 17 Jan 2011 06:59:24 +0000
| Newsgroups | gmane.linux.cluster.ssic.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/vproc
In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv671/cluster/ssi/vproc
Modified Files:
Tag: OPENSSI-FC
rproc_svr_pproc.c
Log Message:
reopen_unload_msg: test rlimit and call expand_files() outside of for-loop since fd_data array is sorted by fdnum. reduce work.
Index: rproc_svr_pproc.c
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/cluster/ssi/vproc/rproc_svr_pproc.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- rproc_svr_pproc.c 15 Dec 2010 06:58:56 -0000 1.34
+++ rproc_svr_pproc.c 17 Jan 2011 06:59:22 -0000 1.35
@@ -205,14 +205,14 @@
reopendata *rdp,
int optype)
{
- task_t *t = current;
fd_data *fddp;
- struct files_struct *files = t->files;
+ struct files_struct *files;
struct file *file;
unsigned int fd, idx;
- int error = 0;
u_int flags;
+ int error;
+ files = current->files;
for (fd = 0; fd < files->max_fds; ++fd) {
if (!FD_ISSET(fd, files->open_fds))
continue;
@@ -220,41 +220,41 @@
}
memset(files->open_fds, 0, files->max_fdset / 8);
memset(files->close_on_exec, 0, files->max_fdset / 8);
+
+ if (rdp->fd_count == 0) {
+ error = 0;
+ goto out;
+ }
fddp = rdp->fd_info;
- for (idx = 0 ; idx < rdp->fd_count; idx++, fddp++) {
- /* heavily "borrowed" from sys_dup2() */
- fd = fddp->fdnum;
- if (fd >= t->signal->rlim[RLIMIT_NOFILE].rlim_cur) {
- printk(KERN_ERR "reopen_unload_msg: "
- "fd exceeds process limits\n");
- error = -EINVAL;
- goto out;
- }
+ /* NB: fdnum's are sorted. see reopen_load_msg() */
+ fd = fddp[rdp->fd_count-1].fdnum;
- /* no race here, but expand_files() expects the lock
- * to be held
- */
- spin_lock(&files->file_lock);
- error = expand_files(files, fd);
- spin_unlock(&files->file_lock);
- if (error < 0)
- goto out;
+ if (fd >= current->signal->rlim[RLIMIT_NOFILE].rlim_cur) {
+ printk(KERN_ERR "reopen_unload_msg: "
+ "fd exceeds process limits\n");
+ error = -EINVAL;
+ goto out;
+ }
- if (FD_ISSET(fd, files->open_fds)) {
- printk(KERN_ERR "reopen_unload_msg: duplicate fd\n");
- error = -EINVAL;
- goto out;
- }
+ /* expand_files() expects file_lock held */
+ spin_lock(&files->file_lock);
+ error = expand_files(files, fd);
+ spin_unlock(&files->file_lock);
+ if (error < 0)
+ goto out;
+ for (idx = 0 ; idx < rdp->fd_count; idx++, fddp++) {
error = reop_import_file(fddp->fbdatap, &file);
if (error) {
printk(KERN_DEBUG "%s: reop_import_file fd=%d"
" error=%d\n", __FUNCTION__, fd, error);
goto out;
}
-
SSI_ASSERT(file);
+
+ /* heavily "borrowed" from sys_dup2() */
+ fd = fddp->fdnum;
files->fd[fd] = file;
FD_SET(fd, files->open_fds);
if (fddp->close_on_exec)
@@ -275,7 +275,6 @@
}
}
files->next_fd = rdp->next_fd;
-
out:
return error;
}
------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl