]> arthur.barton.de Git - netatalk.git/commitdiff
remove SIGUSR2 (message) from the list of blocked signals when writing to the client...
authordidg <didg>
Thu, 22 Oct 2009 05:53:20 +0000 (05:53 +0000)
committerdidg <didg>
Thu, 22 Oct 2009 05:53:20 +0000 (05:53 +0000)
etc/afpd/afp_dsi.c
etc/afpd/messages.c
include/atalk/dsi.h
libatalk/dsi/dsi_init.c

index b66dafc9b69dad64567159af868528a7497c24aa..9b0baaad042ddebd193e7a867bba3d9d49c7ceb6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: afp_dsi.c,v 1.42 2009-10-22 05:09:56 didg Exp $
+ * $Id: afp_dsi.c,v 1.43 2009-10-22 05:53:20 didg Exp $
  *
  * Copyright (c) 1999 Adrian Sun (asun@zoology.washington.edu)
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
@@ -46,7 +46,6 @@
 #define CHILD_DIE         (1 << 0)
 #define CHILD_RUNNING     (1 << 1)
 #define CHILD_SLEEPING    (1 << 2)
-#define CHILD_DATA        (1 << 3)
 
 static struct {
     AFPObj *obj;
@@ -164,7 +163,9 @@ static void afp_dsi_reload(int sig _U_)
 #ifdef SERVERTEXT
 static void afp_dsi_getmesg (int sig _U_)
 {
-    readmessage(child.obj);
+    DSI *dsi = (DSI *) child.obj->handle;
+
+    dsi->msg_request = 1;
     dsi_attention(child.obj->handle, AFPATTN_MESG | AFPATTN_TIME(5));
 }
 #endif /* SERVERTEXT */
@@ -178,13 +179,6 @@ static void alarm_handler(int sig _U_)
      * may use alarm() */
     setitimer(ITIMER_REAL, &dsi->timer, NULL);
 
-    /* we got some traffic from the client since the previous timer 
-     * tick. */
-    if ((child.flags & CHILD_DATA)) {
-        child.flags &= ~CHILD_DATA;
-        return;
-    }
-
     /* if we're in the midst of processing something,
        don't die. */
     if ((child.flags & CHILD_SLEEPING) && child.tickle++ < child.obj->options.sleep) {
@@ -203,6 +197,21 @@ static void alarm_handler(int sig _U_)
     }
 }
 
+/* ----------------- 
+   if dsi->in_write is set attention, tickle (and close?) msg
+   aren't sent. We don't care about tickle 
+*/
+static void pending_request(DSI *dsi)
+{
+    /* send pending attention */
+
+    /* read msg if any, it could be done in afp_getsrvrmesg */
+    if (dsi->msg_request) {
+        dsi->msg_request = 0;
+        readmessage(child.obj);
+    }
+}
+
 /* -------------------------------------------
  afp over dsi. this never returns. 
 */
@@ -315,9 +324,9 @@ void afp_over_dsi(AFPObj *obj)
             /* timer is not every 30 seconds anymore, so we don't get killed on the client side. */
             if ((child.flags & CHILD_DIE))
                 dsi_tickle(dsi);
+            pending_request(dsi);
             continue;
         } 
-        child.flags |= CHILD_DATA;
         switch(cmd) {
         case DSIFUNC_CLOSE:
             afp_dsi_close(obj);
@@ -401,7 +410,6 @@ void afp_over_dsi(AFPObj *obj)
             break;
 
         case DSIFUNC_ATTN: /* attention replies */
-            continue;
             break;
 
             /* error. this usually implies a mismatch of some kind
@@ -413,6 +421,7 @@ void afp_over_dsi(AFPObj *obj)
             dsi_writeflush(dsi);
             break;
         }
+        pending_request(dsi);
     }
 
     /* error */
index 014ce4b5c036758572a972f4c6b6d6335b0539fb..54540a7a7d76a16b6b56c12ec4139451e389cc4b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: messages.c,v 1.20 2009-10-15 10:43:13 didg Exp $
+ * $Id: messages.c,v 1.21 2009-10-22 05:53:20 didg Exp $
  *
  * Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu)
  * All Rights Reserved.  See COPYRIGHT.
@@ -95,6 +95,7 @@ void readmessage(AFPObj *obj)
         /* Drop privs again, failing this is very bad */
         if (seteuid(euid) < 0) {
             LOG(log_error, logtype_afpd, "Could not switch back to uid %d: %s", euid, strerror(errno));
+            exit(EXITERR_SYS);
         }
 
         if (rc < 0) {
index 5053cb13d4565e285d64c7b616d03ebd1fc66c51..b2e6cd98c66c08f75a4c6e80cd37b27cbb63798e 100644 (file)
@@ -65,7 +65,8 @@ typedef struct DSI {
   int     in_write;      /* in the middle of writing multiple packets, signal handlers
                           * can't write to the socket 
                          */
-  
+  int      msg_request;   /* pending message to the client */
+
   u_int32_t attn_quantum, datasize, server_quantum;
   u_int16_t serverID, clientID;
   char      *status;
index ef16896c939241a4d58eb1223f45be6b3edd55aa..6d8405fafb625e95b6abd4e2d49e005ca0bda543 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: dsi_init.c,v 1.7 2009-10-22 05:19:29 didg Exp $
+ * $Id: dsi_init.c,v 1.8 2009-10-22 05:53:20 didg Exp $
  *
  * Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu)
  * All rights reserved. See COPYRIGHT.
@@ -33,8 +33,6 @@ DSI *dsi_init(const dsi_proto protocol, const char *program,
     sigemptyset(&dsi->sigblockset);
     sigaddset(&dsi->sigblockset, SIGTERM);
     sigaddset(&dsi->sigblockset, SIGUSR1);
-    /* always block SIGUSR2 even if SERVERTEXT is not defined */
-    sigaddset(&dsi->sigblockset, SIGUSR2);
     switch (protocol) {
       /* currently the only transport protocol that exists for dsi */
     case DSI_TCPIP: