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)));
+ }
}
* 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));
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;
DEBUG(DEBUG_ALERT,
("ctdb exiting with error: "
"failed to create directory \"%s\" (%s)\n",
- dir, strerror(ret)));
+ dir, strerror(errno)));
exit(1);
}
}