patch-2.4.10 linux/fs/lockd/svc.c

Next file: linux/fs/lockd/xdr.c
Previous file: linux/fs/lockd/clntproc.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.9/linux/fs/lockd/svc.c linux/fs/lockd/svc.c
@@ -76,9 +76,8 @@
 	nlmsvc_pid = current->pid;
 	up(&lockd_start);
 
-	exit_mm(current);
-	current->session = 1;
-	current->pgrp = 1;
+	daemonize();
+	reparent_to_init();
 	sprintf(current->comm, "lockd");
 
 	/* Process request with signals blocked.  */
@@ -90,12 +89,6 @@
 	/* kick rpciod */
 	rpciod_up();
 
-	/*
-	 * N.B. current do_fork() doesn't like NULL task->files,
-	 * so we defer closing files until forking rpciod.
-	 */
-	exit_files(current);
-
 	dprintk("NFS locking service started (ver " LOCKD_VERSION ").\n");
 
 	if (!nlm_timeout)
@@ -127,6 +120,16 @@
 			spin_lock_irq(&current->sigmask_lock);
 			flush_signals(current);
 			spin_unlock_irq(&current->sigmask_lock);
+			if (nlmsvc_ops) {
+				nlmsvc_ops->detach();
+#ifdef RPC_DEBUG
+				nlmsvc_grace_period = 10 * HZ;
+#else
+				nlmsvc_grace_period += 5 * nlm_timeout * HZ;
+
+#endif
+				grace_period_expire = nlmsvc_grace_period + jiffies;
+			}
 		}
 
 		/*
@@ -144,13 +147,14 @@
 		 * Find a socket with data available and call its
 		 * recvfrom routine.
 		 */
-		if ((err = svc_recv(serv, rqstp, timeout)) == -EAGAIN)
+		if ((err = svc_recv(serv, rqstp, timeout)) == -EAGAIN
+			|| err == -EINTR
+			)
 			continue;
 		if (err < 0) {
-			if (err != -EINTR)
-				printk(KERN_WARNING
-					"lockd: terminating on error %d\n",
-					-err);
+			printk(KERN_WARNING
+			       "lockd: terminating on error %d\n",
+			       -err);
 			break;
 		}
 
@@ -180,6 +184,8 @@
 	 * shutting down the hosts and clearing the slot.
 	 */
 	if (!nlmsvc_pid || current->pid == nlmsvc_pid) {
+		if (nlmsvc_ops)
+			nlmsvc_ops->detach();
 		nlm_shutdown_hosts();
 		nlmsvc_pid = 0;
 	} else

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)