]> arthur.barton.de Git - netatalk.git/blobdiff - libatalk/dsi/dsi_attn.c
Merge 3.0.2 release branch
[netatalk.git] / libatalk / dsi / dsi_attn.c
index 962ebc2ca6c70042e93f4ac1d5cdb314a2bbd13b..80757712192a8240421d71e8f10cce7588310d1a 100644 (file)
@@ -1,5 +1,4 @@
 /*
- * $Id: dsi_attn.c,v 1.3 2001-06-29 14:14:46 rufustfirefly Exp $
  *
  * Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu)
  * All rights reserved. See COPYRIGHT.
 #include <string.h>
 #include <signal.h>
 #include <sys/types.h>
+#include <arpa/inet.h>
 
 #include <atalk/dsi.h>
 #include <atalk/afp.h>
-#include <netatalk/endian.h>
 
 #ifndef MIN
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 #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 */
   char block[DSI_BLOCKSIZ + sizeof(AFPUserBytes)];
-  sigset_t oldset;
-  u_int32_t len, nlen;
-  u_int16_t id;
+  uint32_t len, nlen;
+  uint16_t id;
+
+  if (dsi->flags & DSI_SLEEPING)
+      return 1;
 
+  if (dsi->in_write) {
+      return -1;
+  }      
   id = htons(dsi_serverID(dsi));
   flags = htons(flags);
   len = MIN(sizeof(flags), dsi->attn_quantum);
@@ -47,9 +54,5 @@ int dsi_attention(DSI *dsi, AFPUserBytes flags)
   /* reserved = 0 */
 
   /* send an attention */
-  sigprocmask(SIG_BLOCK, &dsi->sigblockset, &oldset);
-  len = dsi_stream_write(dsi, block, DSI_BLOCKSIZ + len);
-  sigprocmask(SIG_SETMASK, &oldset, NULL);
-
-  return len;
+  return dsi_stream_write(dsi, block, DSI_BLOCKSIZ + len, DSI_NOWAIT);
 }