]> arthur.barton.de Git - netatalk.git/commitdiff
- call SIGHUP signal handler only once for worker process
authordidg <didg>
Wed, 4 Dec 2002 10:59:36 +0000 (10:59 +0000)
committerdidg <didg>
Wed, 4 Dec 2002 10:59:36 +0000 (10:59 +0000)
- check attention, tickle return value and die if the connection is closed

etc/afpd/afp_asp.c
etc/afpd/afp_dsi.c
etc/afpd/volume.c
include/atalk/asp.h
include/atalk/dsi.h
libatalk/asp/asp_attn.c
libatalk/asp/asp_tickle.c
libatalk/dsi/dsi_attn.c
libatalk/dsi/dsi_tickle.c

index 3259c9bc674b5ee6c686d8ccf3b4e58cbd624ca0..e822a89ed37b2e47a2eab3774d7f391b4607bca9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: afp_asp.c,v 1.17 2002-08-30 19:32:40 didg Exp $
+ * $Id: afp_asp.c,v 1.18 2002-12-04 10:59:36 didg Exp $
  *
  * Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu)
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
@@ -164,6 +164,15 @@ static void afp_asp_timedown()
         LOG(log_error, logtype_afpd, "afp_timedown: sigaction: %s", strerror(errno) );
         afp_asp_die(1);
     }
+
+    /* ignore SIGHUP */
+    sv.sa_handler = SIG_IGN;
+    sigemptyset( &sv.sa_mask );
+    sv.sa_flags = SA_RESTART;
+    if ( sigaction( SIGHUP, &sv, 0 ) < 0 ) {
+        LOG(log_error, logtype_afpd, "afp_timedown: sigaction SIGHUP: %s", strerror(errno) );
+        afp_asp_die(1);
+    }
 }
 
 void afp_over_asp(AFPObj *obj)
index 0566942bb3ed40ae859dd13a81ef32629a940941..fc754c668715a721e3a1386767976129355bcadf 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: afp_dsi.c,v 1.25 2002-10-11 14:18:23 didg Exp $
+ * $Id: afp_dsi.c,v 1.26 2002-12-04 10:59:36 didg Exp $
  *
  * Copyright (c) 1999 Adrian Sun (asun@zoology.washington.edu)
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
@@ -117,6 +117,16 @@ static void afp_dsi_timedown()
         LOG(log_error, logtype_afpd, "afp_timedown: sigaction: %s", strerror(errno) );
         afp_dsi_die(1);
     }
+
+    /* ignore SIGHUP */
+    sv.sa_handler = SIG_IGN;
+    sigemptyset( &sv.sa_mask );
+    sv.sa_flags = SA_RESTART;
+    if ( sigaction( SIGHUP, &sv, 0 ) < 0 ) {
+        LOG(log_error, logtype_afpd, "afp_timedown: sigaction SIGHUP: %s", strerror(errno) );
+        afp_dsi_die(1);
+    }
+
 }
 
 #ifdef SERVERTEXT
@@ -129,11 +139,15 @@ static void afp_dsi_getmesg (int sig)
 
 static void alarm_handler()
 {
+int err;
     /* if we're in the midst of processing something,
        don't die. */
     if ((child.flags & CHILD_RUNNING) || (child.tickle++ < child.obj->options.timeout)) {
-        if (!pollvoltime(child.obj))
-            dsi_tickle(child.obj->handle);
+        if (!(err = pollvoltime(child.obj)))
+            err = dsi_tickle(child.obj->handle);
+        if (err <= 0) 
+            afp_dsi_die(1);
+        
     } else { /* didn't receive a tickle. close connection */
         LOG(log_error, logtype_afpd, "afp_alarm: child timed out");
         afp_dsi_die(1);
index c5fef8ce8ca352e2722b804e9c0ce42e452e69a0..254b0301d738d8cfa1ac74bddb55b27c30901117 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: volume.c,v 1.43 2002-11-15 10:59:11 srittau Exp $
+ * $Id: volume.c,v 1.44 2002-12-04 10:59:36 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -1217,11 +1217,12 @@ int             ibuflen, *rbuflen;
     }
     /* FIXME 
     */
-    if (afp_version >= 30)
+    if (afp_version >= 30) {
         volume->max_filename = 255;
-    else 
+    }
+    else {
         volume->max_filename = MACFILELEN;
-
+    }
     if (( volume->v_flags & AFPVOL_OPEN  ) == 0 ) {
         /* FIXME unix name != mac name */
         if ((dir = dirnew(volume->v_name, volume->v_name) ) == NULL) {
@@ -1311,7 +1312,6 @@ int               ibuflen, *rbuflen;
             curdir = ovol->v_dir;
         }
     }
-
     dirfree( vol->v_root );
     vol->v_dir = NULL;
 #ifdef CNID_DB
@@ -1393,7 +1393,8 @@ AFPObj *obj;
         if ( (vol->v_flags & AFPVOL_OPEN)  && vol->v_time + 30 < tv.tv_sec) {
             if ( !stat( vol->v_path, &st ) && vol->v_time != st.st_mtime ) {
                 vol->v_time = st.st_mtime;
-                obj->attention(obj->handle, AFPATTN_NOTIFY | AFPATTN_VOLCHANGED);
+                if (!obj->attention(obj->handle, AFPATTN_NOTIFY | AFPATTN_VOLCHANGED))
+                    return -1;
                 return 1;
             }
         }
index d36710186a4c15f2fd442b36a186f58b6392d293..d147deb15b11c9e17164a6734438b80982c5ddc3 100644 (file)
@@ -98,6 +98,6 @@ extern int asp_cmdreply     __P((ASP, int));
 extern int asp_wrtcont      __P((ASP, char *, int *));
 #define asp_wrtreply(a,b)   asp_cmdreply((a), (b))
 extern void asp_kill        __P((int));
-extern void asp_tickle      __P((ASP, const u_int8_t, struct sockaddr_at *));
+extern int asp_tickle      __P((ASP, const u_int8_t, struct sockaddr_at *));
 
 #endif
index 80d08dbc79ca605996e079ce5892a3d589ebc6da..f30a90ee27219b823368e8e29ea3b7d3751543f5 100644 (file)
@@ -135,7 +135,7 @@ extern void dsi_kill __P((int));
 extern void dsi_opensession __P((DSI *));
 extern int  dsi_attention __P((DSI *, AFPUserBytes));
 extern int  dsi_cmdreply __P((DSI *, const int));
-extern void dsi_tickle __P((DSI *));
+extern int dsi_tickle __P((DSI *));
 extern void dsi_getstatus __P((DSI *));
 extern void dsi_close __P((DSI *));
 
index e25d474b77f05271ef0c0acb0f55bd2296a4bdce..1c2a8fa63e00bedeec73912f997e5738e1527e32 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: asp_attn.c,v 1.6 2002-01-04 04:45:48 sibaz Exp $
+ * $Id: asp_attn.c,v 1.7 2002-12-04 10:59:37 didg Exp $
  * Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu)
  * All rights reserved. See COPYRIGHT.
  */
@@ -44,7 +44,7 @@ int asp_attention(ASP asp, AFPUserBytes flags)
 
     if ( atp_sreq( asp->asp_atp, &atpb, 1, 0 ) < 0 ) {
        LOG(log_error, logtype_default, "atp_sreq: %s", strerror(errno) );
-       return -1;
+       return 0;
     }
 
     iov[ 0 ].iov_base = data;
@@ -53,8 +53,8 @@ int asp_attention(ASP asp, AFPUserBytes flags)
     atpb.atp_rresiovcnt = sizeof( iov )/sizeof( iov[ 0 ] );
     if ( atp_rresp( asp->asp_atp, &atpb ) < 0 ) {
        LOG(log_error, logtype_default, "atp_rresp: %s", strerror(errno) );
-       return -1;
+       return 0;
     }
 
-    return 0;
+    return 1;
 }
index 1e35520363a90160db59f0a96b45f41487000ba1..c6f3752634822417bf4b8de31d1b4a8fc6731f5b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: asp_tickle.c,v 1.6 2002-01-04 04:45:48 sibaz Exp $
+ * $Id: asp_tickle.c,v 1.7 2002-12-04 10:59:37 didg Exp $
  */
 
 #ifdef HAVE_CONFIG_H
@@ -18,7 +18,7 @@
 #include <atalk/asp.h>
 
 /* send off a tickle */
-void asp_tickle(ASP asp, const u_int8_t sid, struct sockaddr_at *sat)
+int asp_tickle(ASP asp, const u_int8_t sid, struct sockaddr_at *sat)
 {
   struct atp_block atpb;
   char buf[ASP_HDRSIZ];
@@ -34,5 +34,7 @@ void asp_tickle(ASP asp, const u_int8_t sid, struct sockaddr_at *sat)
   atpb.atp_sreqtries = 1;
   if ( atp_sreq( asp->asp_atp, &atpb, 0, 0 ) < 0 ) {
     LOG(log_error, logtype_default, "atp_sreq: %s", strerror(errno) );
+    return 0;
   }
+  return 1;
 }
index 962ebc2ca6c70042e93f4ac1d5cdb314a2bbd13b..ae0883b6e0dcd2bd1304ef561bc12bbece12e25c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: dsi_attn.c,v 1.3 2001-06-29 14:14:46 rufustfirefly Exp $
+ * $Id: dsi_attn.c,v 1.4 2002-12-04 10:59:37 didg Exp $
  *
  * Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu)
  * All rights reserved. See COPYRIGHT.
 #endif /* MIN */
 
 /* send an attention. this may get called at any time, so we can't use
- * DSI buffers to send one. */
+ * DSI buffers to send one. 
+   return 0 on error
+ */
 int dsi_attention(DSI *dsi, AFPUserBytes flags)
 {
   /* header + AFPUserBytes */
index fd3ca971dc8f55a9e0faa0b995d93bb45a298843..6be41e486e23fb7d93ee83eb2f17aa40a95ff242 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: dsi_tickle.c,v 1.3 2001-06-29 14:14:46 rufustfirefly Exp $
+ * $Id: dsi_tickle.c,v 1.4 2002-12-04 10:59:37 didg Exp $
  *
  * Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu)
  * All rights reserved. See COPYRIGHT.
 /* server generated tickles. as this is only called by the tickle handler,
  * we don't need to block signals. well, actually, we might get it during
  * a SIGHUP. */
-void dsi_tickle(DSI *dsi)
+int dsi_tickle(DSI *dsi)
 {
   char block[DSI_BLOCKSIZ];
   sigset_t oldset;
   u_int16_t id;
-
+  int ret;
+  
   id = htons(dsi_serverID(dsi));
 
   memset(block, 0, sizeof(block));
@@ -35,7 +36,8 @@ void dsi_tickle(DSI *dsi)
   /* code = len = reserved = 0 */
 
   sigprocmask(SIG_BLOCK, &dsi->sigblockset, &oldset);
-  dsi_stream_write(dsi, block, DSI_BLOCKSIZ);
+  ret = dsi_stream_write(dsi, block, DSI_BLOCKSIZ) == DSI_BLOCKSIZ;
   sigprocmask(SIG_SETMASK, &oldset, NULL);
+  return ret;
 }