From e93b52a3239298a115c855aa3290a528f0846dae Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 2 May 2007 07:37:58 +1000 Subject: new files for updated events system (This used to be ctdb commit 15d8308e5a0ce04351d70ac3dd25c7698931ebba) --- ctdb/lib/util/util.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 ctdb/lib/util/util.c (limited to 'ctdb/lib/util/util.c') diff --git a/ctdb/lib/util/util.c b/ctdb/lib/util/util.c new file mode 100644 index 0000000000..add3839a95 --- /dev/null +++ b/ctdb/lib/util/util.c @@ -0,0 +1,53 @@ +/* + Unix SMB/CIFS implementation. + + Copyright (C) Andrew Tridgell 2005 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +#include "system/filesys.h" + + +/** + Set a fd into blocking/nonblocking mode. Uses POSIX O_NONBLOCK if available, + else + if SYSV use O_NDELAY + if BSD use FNDELAY +**/ + +_PUBLIC_ int set_blocking(int fd, BOOL set) +{ + int val; +#ifdef O_NONBLOCK +#define FLAG_TO_SET O_NONBLOCK +#else +#ifdef SYSV +#define FLAG_TO_SET O_NDELAY +#else /* BSD */ +#define FLAG_TO_SET FNDELAY +#endif +#endif + + if((val = fcntl(fd, F_GETFL, 0)) == -1) + return -1; + if(set) /* Turn blocking on - ie. clear nonblock flag */ + val &= ~FLAG_TO_SET; + else + val |= FLAG_TO_SET; + return fcntl( fd, F_SETFL, val); +#undef FLAG_TO_SET +} -- cgit From 32de198fd3d59033418ac0e05baaf16b17f5ce46 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 15:29:31 +1000 Subject: update lib/replace from samba4 (This used to be ctdb commit f0555484105668c01c21f56322992e752e831109) --- ctdb/lib/util/util.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'ctdb/lib/util/util.c') diff --git a/ctdb/lib/util/util.c b/ctdb/lib/util/util.c index add3839a95..e19b2dc1fe 100644 --- a/ctdb/lib/util/util.c +++ b/ctdb/lib/util/util.c @@ -5,7 +5,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -14,8 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program; if not, see . */ #include "includes.h" -- cgit From 763183015298f9ac46e8bafad54938b2fb321f4c Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Thu, 17 May 2012 16:08:37 +1000 Subject: server: Replace BOOL datatype with bool, True/False with true/false Signed-off-by: Amitay Isaacs (This used to be ctdb commit 6e5cbe8fff71985e5a2fc16b7e9f2b868011ff5d) --- ctdb/lib/util/util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ctdb/lib/util/util.c') diff --git a/ctdb/lib/util/util.c b/ctdb/lib/util/util.c index e19b2dc1fe..af52805995 100644 --- a/ctdb/lib/util/util.c +++ b/ctdb/lib/util/util.c @@ -28,7 +28,7 @@ if BSD use FNDELAY **/ -_PUBLIC_ int set_blocking(int fd, BOOL set) +_PUBLIC_ int set_blocking(int fd, bool set) { int val; #ifdef O_NONBLOCK -- cgit