torture/attr: use security_ace_equal instead of sec_ace_equal
[samba.git] / ctdb / common / ctdb_util.c
index 7a70fea9cd71c1c51eeedff6d3c68a294d1daff4..fd0d7da1d8f05e9d5b67a24b8afde4f94cafbf40 100644 (file)
@@ -415,16 +415,34 @@ void ctdb_restore_scheduler(struct ctdb_context *ctdb)
 
 void set_nonblocking(int fd)
 {
-       unsigned v;
+       int v;
+
        v = fcntl(fd, F_GETFL, 0);
-        fcntl(fd, F_SETFL, v | O_NONBLOCK);
+       if (v == -1) {
+               DEBUG(DEBUG_WARNING, ("Failed to get file status flags - %s\n",
+                                     strerror(errno)));
+               return;
+       }
+        if (fcntl(fd, F_SETFL, v | O_NONBLOCK) == -1) {
+               DEBUG(DEBUG_WARNING, ("Failed to set non_blocking on fd - %s\n",
+                                     strerror(errno)));
+       }
 }
 
 void set_close_on_exec(int fd)
 {
-       unsigned v;
+       int v;
+
        v = fcntl(fd, F_GETFD, 0);
-       fcntl(fd, F_SETFD, v | FD_CLOEXEC);
+       if (v == -1) {
+               DEBUG(DEBUG_WARNING, ("Failed to get file descriptor flags - %s\n",
+                                     strerror(errno)));
+               return;
+       }
+       if (fcntl(fd, F_SETFD, v | FD_CLOEXEC) != 0) {
+               DEBUG(DEBUG_WARNING, ("Failed to set close_on_exec on fd - %s\n",
+                                     strerror(errno)));
+       }
 }
 
 
@@ -717,7 +735,7 @@ int32_t get_debug_by_desc(const char *desc)
  * we'd fail to mmap later on. */
 void ctdb_lockdown_memory(struct ctdb_context *ctdb)
 {
-#ifdef HAVE_MLOCKALL
+#if defined(HAVE_MLOCKALL) && !defined(_AIX_)
        /* Extra stack, please! */
        char dummy[10000];
        memset(dummy, 0, sizeof(dummy));
@@ -726,11 +744,6 @@ void ctdb_lockdown_memory(struct ctdb_context *ctdb)
                return;
        }
 
-       /* TODO: Add a command line option to disable memory lockdown.
-        *       This can be a performance issue on AIX since fork() copies
-        *       all locked memory pages. 
-        */
-
        /* Ignore when running in local daemons mode */
        if (getuid() != 0) {
                return;
@@ -821,7 +834,7 @@ void ctdb_mkdir_p_or_die(struct ctdb_context *ctdb, const char *dir, int mode)
                DEBUG(DEBUG_ALERT,
                      ("ctdb exiting with error: "
                       "failed to create directory \"%s\" (%s)\n",
-                      dir, strerror(ret)));
+                      dir, strerror(errno)));
                exit(1);
        }
 }