#include <talloc.h>
#include <tdb.h>
+#include "lib/util/blocking.h"
#include "lib/util/tevent_unix.h"
#include "pkt_read.h"
#include "pkt_write.h"
#include "comm.h"
-static bool set_nonblocking(int fd)
-{
- int v;
-
- v = fcntl(fd, F_GETFL, 0);
- if (v == -1) {
- return false;
- }
- if (fcntl(fd, F_SETFL, v | O_NONBLOCK) == -1) {
- return false;
- }
- return true;
-}
-
/*
* Communication endpoint around a socket
*/
struct comm_context **result)
{
struct comm_context *comm;
+ int ret;
if (fd < 0) {
return EINVAL;
}
/* Socket queue relies on non-blocking sockets. */
- if (!set_nonblocking(fd)) {
+ ret = set_blocking(fd, false);
+ if (ret == -1) {
return EIO;
}
#include <assert.h>
+#include "lib/util/blocking.h"
+
#include "common/pkt_read.c"
static void writer(int fd)
talloc_free(mem_ctx);
}
-static bool set_nonblocking(int fd)
-{
- int v;
-
- v = fcntl(fd, F_GETFL, 0);
- if (v == -1) {
- return false;
- }
- if (fcntl(fd, F_SETFL, v | O_NONBLOCK) == -1) {
- return false;
- }
- return true;
-}
-
static void reader_test(bool fixed)
{
int fd[2];
}
close(fd[1]);
- if (!set_nonblocking(fd[0])) {
+ ret = set_blocking(fd[0], false);
+ if (ret == -1) {
exit(1);
}
#include <assert.h>
+#include "lib/util/blocking.h"
+
#include "common/pkt_read.c"
#include "common/pkt_write.c"
talloc_free(mem_ctx);
}
-static bool set_nonblocking(int fd)
-{
- int v;
-
- v = fcntl(fd, F_GETFL, 0);
- if (v == -1) {
- return false;
- }
- if (fcntl(fd, F_SETFL, v | O_NONBLOCK) == -1) {
- return false;
- }
- return true;
-}
-
int main(void)
{
int fd[2];
}
close(fd[1]);
- if (!set_nonblocking(fd[0])) {
+ ret = set_blocking(fd[0], false);
+ if (ret == -1) {
exit(1);
}
bld.SAMBA_BINARY(target,
source=src,
- deps='talloc tevent tdb tevent-util LIBASYNC_REQ',
+ deps='''talloc tevent tdb tevent-util
+ LIBASYNC_REQ samba-util''',
install_path='${CTDB_TEST_LIBDIR}')
bld.SAMBA_BINARY('reqid_test',