mirror of
https://github.com/samba-team/samba.git
synced 2025-01-10 01:18:15 +03:00
ctdb-tests: Re-use set_blocking instead of re-definition
Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
This commit is contained in:
parent
3031732504
commit
e1e14420a6
@ -24,26 +24,13 @@
|
||||
#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
|
||||
*/
|
||||
@ -78,6 +65,7 @@ int comm_setup(TALLOC_CTX *mem_ctx, struct tevent_context *ev, int fd,
|
||||
struct comm_context **result)
|
||||
{
|
||||
struct comm_context *comm;
|
||||
int ret;
|
||||
|
||||
if (fd < 0) {
|
||||
return EINVAL;
|
||||
@ -88,7 +76,8 @@ int comm_setup(TALLOC_CTX *mem_ctx, struct tevent_context *ev, int fd,
|
||||
}
|
||||
|
||||
/* Socket queue relies on non-blocking sockets. */
|
||||
if (!set_nonblocking(fd)) {
|
||||
ret = set_blocking(fd, false);
|
||||
if (ret == -1) {
|
||||
return EIO;
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,8 @@
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "lib/util/blocking.h"
|
||||
|
||||
#include "common/pkt_read.c"
|
||||
|
||||
static void writer(int fd)
|
||||
@ -210,20 +212,6 @@ static void reader(int fd, bool fixed)
|
||||
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];
|
||||
@ -244,7 +232,8 @@ static void reader_test(bool fixed)
|
||||
}
|
||||
|
||||
close(fd[1]);
|
||||
if (!set_nonblocking(fd[0])) {
|
||||
ret = set_blocking(fd[0], false);
|
||||
if (ret == -1) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,8 @@
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "lib/util/blocking.h"
|
||||
|
||||
#include "common/pkt_read.c"
|
||||
#include "common/pkt_write.c"
|
||||
|
||||
@ -326,20 +328,6 @@ static void reader(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;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int fd[2];
|
||||
@ -360,7 +348,8 @@ int main(void)
|
||||
}
|
||||
|
||||
close(fd[1]);
|
||||
if (!set_nonblocking(fd[0])) {
|
||||
ret = set_blocking(fd[0], false);
|
||||
if (ret == -1) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -656,7 +656,8 @@ def build(bld):
|
||||
|
||||
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',
|
||||
|
Loading…
Reference in New Issue
Block a user