[patch] SIGHUP reload problem

Jeremy Allison jallison at cthulhu.engr.sgi.com
Tue Feb 16 21:33:45 GMT 1999


> I tried samba-2.0.2 recently, on both a Linux 2.0.32/libc5
> and a Linux 2.2.1+raid-0.9/glibc2 based system. Both times there was a
> SIGHUP reload problem, where the SIGHUP would be recognised but not
> acted upon. Also, the server process doesnt propogate SIGHUP to its
> children. These bugs make any day-to-day administration a nightmare.
> (Requiring users to reconnect to see permission/print command changes)
> 
> The problem is in the smbd/process.c file in the smbd_process()
> function, where even moderate traffic on the open connection would
> prevent the select() from timing out and causing the idle code to be
> run. [This would also suggest there was no echo packets being sent
> from the client to the server.]

Guy,

	Can you try this patch instead of the one you
kindly posted. This patch is somewhat simpler in that
it requires no forked child.

All it does is ensures that timeout processing is
done every SELECT_TIMEOUT seconds - via an smb counter
that causes a check to see if it's time to do timeout
processing every 200 smb requests. This patch is against
Samba 2.0.2.

Let me know if this fixes the problem for you.

Cheers,

	Jeremy Allison,
	Samba Team.

-----------------------cut here-----------------------
Index: process.c
===================================================================
RCS file: /data/cvs/samba/source/smbd/process.c,v
retrieving revision 1.11.2.5
retrieving revision 1.11.2.6
diff -u -r1.11.2.5 -r1.11.2.6
--- process.c	1999/01/20 19:13:27	1.11.2.5
+++ process.c	1999/02/16 21:24:24	1.11.2.6
@@ -740,7 +740,7 @@
  Process any timeout housekeeping. Return False if the caler should exit.
 ****************************************************************************/
 
-static BOOL timeout_processing(int deadtime)
+static BOOL timeout_processing(int deadtime, int *select_timeout, time_t
*last_timeout_processing_time)
 {
   extern int Client;
   static time_t last_smb_conf_reload_time = 0;
@@ -763,7 +763,7 @@
     return False;
   }
 
-  t = time(NULL);
+  *last_timeout_processing_time = t = time(NULL);
 
   if(last_smb_conf_reload_time == 0)
     last_smb_conf_reload_time = t;
@@ -891,6 +891,14 @@
    */
   process_pending_change_notify_queue(t);
 
+  /*
+   * Increase the select timeout back to SMBD_SELECT_TIMEOUT if we
+   * have removed any blocking locks. JRA.
+   */
+
+  *select_timeout = blocking_locks_pending() ?
SMBD_SELECT_TIMEOUT_WITH_PENDING_LOCKS*1000 :
+                                              SMBD_SELECT_TIMEOUT*1000;
+
   return True;
 }
 
@@ -901,6 +909,8 @@
 void smbd_process(void)
 {
   extern int smb_echo_count;
+  time_t last_timeout_processing_time = time(NULL);
+  unsigned int num_smbs = 0;
 
   InBuffer = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN);
   OutBuffer = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN);
@@ -945,14 +955,9 @@
 
    
while(!receive_message_or_smb(InBuffer,BUFFER_SIZE,select_timeout,&got_smb))
     {
-      if(!timeout_processing(deadtime))
+      if(!timeout_processing( deadtime, &select_timeout,
&last_timeout_processing_time))
         return;
-      /*
-       * Increase the select timeout back to SMBD_SELECT_TIMEOUT if we
-       * have removed any blocking locks. JRA.
-       */
-      select_timeout = blocking_locks_pending() ?
SMBD_SELECT_TIMEOUT_WITH_PENDING_LOCKS*1000 :
-                                                  SMBD_SELECT_TIMEOUT*1000;
+      num_smbs = 0; /* Reset smb counter. */
     }
 
     if(got_smb) {
@@ -970,16 +975,28 @@
       process_smb(InBuffer, OutBuffer);
 
       if(smb_echo_count != num_echos) {
-        if(!timeout_processing(deadtime))
+        if(!timeout_processing( deadtime, &select_timeout,
&last_timeout_processing_time))
           return;
+        num_smbs = 0; /* Reset smb counter. */
+      }
+
+      num_smbs++;
 
       /*
-       * Lower the select timeout to SMBD_SELECT_TIMEOUT_WITH_PENDING_LOCKS if
we
-       * now have any blocking locks pending. JRA.
+       * If we are getting smb requests in a constant stream
+       * with no echos, make sure we attempt timeout processing
+       * every select_timeout milliseconds - but only check for this
+       * every 200 smb requests.
        */
 
-      select_timeout = blocking_locks_pending() ?
SMBD_SELECT_TIMEOUT_WITH_PENDING_LOCKS*1000 :
-                                                  SMBD_SELECT_TIMEOUT*1000;
+      if((num_smbs % 200) == 0) {
+        time_t new_check_time = time(NULL);
+        if(last_timeout_processing_time - new_check_time >=
(select_timeout/1000)) {
+          if(!timeout_processing( deadtime, &select_timeout,
&last_timeout_processing_time))
+            return;
+          num_smbs = 0; /* Reset smb counter. */
+          last_timeout_processing_time = new_check_time; /* Reset time. */
+        }
       }
     }
     else
-----------------------end cut------------------------
-- 
--------------------------------------------------------
Buying an operating system without source is like buying
a self-assembly Space Shuttle with no instructions.
--------------------------------------------------------


More information about the samba-technical mailing list