1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00

tevent: move some common tevent_fd related functions into tevent_fd.c

metze
This commit is contained in:
Stefan Metzmacher 2009-01-03 11:18:14 +01:00
parent 1a26b67ee3
commit e928d863e2
8 changed files with 47 additions and 59 deletions

View File

@ -41,6 +41,6 @@ CFLAGS = -I../lib/tevent
# End SUBSYSTEM LIBTEVENT
################################################
LIBTEVENT_OBJ_FILES = $(addprefix $(libteventsrcdir)/, tevent.o tevent_timed.o tevent_signal.o tevent_debug.o tevent_util.o)
LIBTEVENT_OBJ_FILES = $(addprefix $(libteventsrcdir)/, tevent.o tevent_fd.o tevent_timed.o tevent_signal.o tevent_debug.o tevent_util.o)
PUBLIC_HEADERS += $(addprefix $(libteventsrcdir)/, tevent.h tevent_internal.h)

View File

@ -15,7 +15,8 @@ if test x"$teventdir" = "x"; then
fi
fi
TEVENT_OBJ="tevent.o tevent_select.o tevent_signal.o tevent_timed.o tevent_standard.o tevent_debug.o tevent_util.o"
TEVENT_OBJ="tevent.o tevent_fd.o tevent_timed.o tevent_signal.o tevent_debug.o tevent_util.o"
TEVENT_OBJ="$TEVENT_OBJ tevent_standard.o tevent_select.o"
AC_LIBREPLACE_NETWORK_CHECKS
SMB_ENABLE(TEVENT_EPOLL, NO)

View File

@ -447,15 +447,6 @@ static struct tevent_fd *aio_event_add_fd(struct tevent_context *ev, TALLOC_CTX
return fde;
}
/*
return the fd event flags
*/
static uint16_t aio_event_get_fd_flags(struct tevent_fd *fde)
{
return fde->flags;
}
/*
set the fd event flags
*/
@ -560,7 +551,7 @@ static const struct tevent_ops aio_event_ops = {
.context_init = aio_event_context_init,
.add_fd = aio_event_add_fd,
.add_aio = aio_event_add_aio,
.get_fd_flags = aio_event_get_fd_flags,
.get_fd_flags = tevent_common_fd_get_flags,
.set_fd_flags = aio_event_set_fd_flags,
.add_timer = tevent_common_add_timer,
.add_signal = tevent_common_add_signal,

View File

@ -405,15 +405,6 @@ static struct tevent_fd *epoll_event_add_fd(struct tevent_context *ev, TALLOC_CT
return fde;
}
/*
return the fd event flags
*/
static uint16_t epoll_event_get_fd_flags(struct tevent_fd *fde)
{
return fde->flags;
}
/*
set the fd event flags
*/
@ -472,7 +463,7 @@ static int epoll_event_loop_wait(struct tevent_context *ev)
static const struct tevent_ops epoll_event_ops = {
.context_init = epoll_event_context_init,
.add_fd = epoll_event_add_fd,
.get_fd_flags = epoll_event_get_fd_flags,
.get_fd_flags = tevent_common_fd_get_flags,
.set_fd_flags = epoll_event_set_fd_flags,
.add_timer = tevent_common_add_timer,
.add_signal = tevent_common_add_signal,

36
lib/tevent/tevent_fd.c Normal file
View File

@ -0,0 +1,36 @@
/*
Unix SMB/CIFS implementation.
common events code for fd events
Copyright (C) Stefan Metzmacher 2009
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 3 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, see <http://www.gnu.org/licenses/>.
*/
#include "replace.h"
#include "tevent.h"
#include "tevent_internal.h"
#include "tevent_util.h"
uint16_t tevent_common_fd_get_flags(struct tevent_fd *fde)
{
return fde->flags;
}
void tevent_common_fd_set_flags(struct tevent_fd *fde, uint16_t flags)
{
if (fde->flags == flags) return;
fde->flags = flags;
}

View File

@ -146,6 +146,9 @@ struct tevent_context {
bool tevent_register_backend(const char *name, const struct tevent_ops *ops);
uint16_t tevent_common_fd_get_flags(struct tevent_fd *fde);
void tevent_common_fd_set_flags(struct tevent_fd *fde, uint16_t flags);
bool ev_timeval_is_zero(const struct timeval *tv);
struct tevent_timer *tevent_common_add_timer(struct tevent_context *ev,
TALLOC_CTX *mem_ctx,

View File

@ -148,31 +148,6 @@ static struct tevent_fd *select_event_add_fd(struct tevent_context *ev, TALLOC_C
return fde;
}
/*
return the fd event flags
*/
static uint16_t select_event_get_fd_flags(struct tevent_fd *fde)
{
return fde->flags;
}
/*
set the fd event flags
*/
static void select_event_set_fd_flags(struct tevent_fd *fde, uint16_t flags)
{
struct tevent_context *ev;
struct select_event_context *select_ev;
if (fde->flags == flags) return;
ev = fde->event_ctx;
select_ev = talloc_get_type(ev->additional_data, struct select_event_context);
fde->flags = flags;
}
/*
event loop handling using select()
*/
@ -291,8 +266,8 @@ static int select_event_loop_wait(struct tevent_context *ev)
static const struct tevent_ops select_event_ops = {
.context_init = select_event_context_init,
.add_fd = select_event_add_fd,
.get_fd_flags = select_event_get_fd_flags,
.set_fd_flags = select_event_set_fd_flags,
.get_fd_flags = tevent_common_fd_get_flags,
.set_fd_flags = tevent_common_fd_set_flags,
.add_timer = tevent_common_add_timer,
.add_signal = tevent_common_add_signal,
.loop_once = select_event_loop_once,

View File

@ -440,15 +440,6 @@ static struct tevent_fd *std_event_add_fd(struct tevent_context *ev, TALLOC_CTX
return fde;
}
/*
return the fd event flags
*/
static uint16_t std_event_get_fd_flags(struct tevent_fd *fde)
{
return fde->flags;
}
/*
set the fd event flags
*/
@ -593,7 +584,7 @@ static int std_event_loop_wait(struct tevent_context *ev)
static const struct tevent_ops std_event_ops = {
.context_init = std_event_context_init,
.add_fd = std_event_add_fd,
.get_fd_flags = std_event_get_fd_flags,
.get_fd_flags = tevent_common_fd_get_flags,
.set_fd_flags = std_event_set_fd_flags,
.add_timer = tevent_common_add_timer,
.add_signal = tevent_common_add_signal,