Skip to content

Commit 09100ec

Browse files
committed
libevent in server_child.
git-svn-id: file:///svn/nsd/trunk@3638 a26ef69c-88ff-0310-839f-98b793d9c207
1 parent bb48cd2 commit 09100ec

File tree

9 files changed

+235
-237
lines changed

9 files changed

+235
-237
lines changed

doc/ChangeLog

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
27 August 2012: Wouter
2+
- libevent in server_child.
3+
14
21 August 2012: Matthijs
25
- Fix bug#464: Conditionally define MAXHOSTNAMELEN
36

ipc.c

+7-9
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,17 @@ static void xfrd_send_quit_req(xfrd_state_t* xfrd);
3131
static void xfrd_handle_ipc_read(struct event* handler, xfrd_state_t* xfrd);
3232

3333
void
34-
child_handle_parent_command(netio_type *ATTR_UNUSED(netio),
35-
netio_handler_type *handler,
36-
netio_event_types_type event_types)
34+
child_handle_parent_command(int fd, short event, void* arg)
3735
{
3836
sig_atomic_t mode;
3937
int len;
4038
struct ipc_handler_conn_data *data =
41-
(struct ipc_handler_conn_data *) handler->user_data;
42-
if (!(event_types & NETIO_EVENT_READ)) {
39+
(struct ipc_handler_conn_data *) arg;
40+
if (!(event & EV_READ)) {
4341
return;
4442
}
4543

46-
if ((len = read(handler->fd, &mode, sizeof(mode))) == -1) {
44+
if ((len = read(fd, &mode, sizeof(mode))) == -1) {
4745
log_msg(LOG_ERR, "handle_parent_command: read: %s",
4846
strerror(errno));
4947
return;
@@ -64,14 +62,14 @@ child_handle_parent_command(netio_type *ATTR_UNUSED(netio),
6462
#ifdef BIND8_STATS
6563
DEBUG(DEBUG_IPC, 2, (LOG_INFO, "quit QUIT_WITH_STATS"));
6664
/* reply with ack and stats and then quit */
67-
if(!write_socket(handler->fd, &mode, sizeof(mode))) {
65+
if(!write_socket(fd, &mode, sizeof(mode))) {
6866
log_msg(LOG_ERR, "cannot write quitwst to parent");
6967
}
70-
if(!write_socket(handler->fd, &data->nsd->st,
68+
if(!write_socket(fd, &data->nsd->st,
7169
sizeof(data->nsd->st))) {
7270
log_msg(LOG_ERR, "cannot write stats to parent");
7371
}
74-
fsync(handler->fd);
72+
fsync(fd);
7573
#endif /* BIND8_STATS */
7674
data->nsd->mode = NSD_QUIT;
7775
break;

ipc.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ void parent_handle_child_command(netio_type *netio,
7575
* Routine used by server_child.
7676
* Handle a command received from the parent process.
7777
*/
78-
void child_handle_parent_command(netio_type *netio,
79-
netio_handler_type *handler, netio_event_types_type event_types);
78+
void child_handle_parent_command(int fd, short event, void* arg);
8079

8180
/*
8281
* Routine used by xfrd

netio.c

+1-26
Original file line numberDiff line numberDiff line change
@@ -151,32 +151,7 @@ netio_dispatch(netio_type *netio, const struct timespec *timeout, const sigset_t
151151
max_fd = handler->fd;
152152
}
153153
if (handler->event_types & NETIO_EVENT_READ) {
154-
extern int slowaccept;
155-
extern struct timespec slowaccept_timeout;
156-
157-
if ((handler->event_types & NETIO_EVENT_ACCEPT) && slowaccept) {
158-
if (timespec_compare(&slowaccept_timeout, netio_current_time(netio)) < 0) {
159-
slowaccept = 0;
160-
}
161-
if (slowaccept) {
162-
/** Timeout after slowaccept timeout. */
163-
struct timespec relative;
164-
relative.tv_sec = slowaccept_timeout.tv_sec;
165-
relative.tv_nsec = slowaccept_timeout.tv_nsec;
166-
timespec_subtract(&relative, netio_current_time(netio));
167-
if (!have_timeout ||
168-
timespec_compare(&relative, &minimum_timeout) < 0) {
169-
have_timeout = 1;
170-
minimum_timeout.tv_sec = relative.tv_sec;
171-
minimum_timeout.tv_nsec = relative.tv_nsec;
172-
}
173-
} else {
174-
FD_SET(handler->fd, &readfds);
175-
}
176-
} else {
177-
/* Not accept event or not slow accept */
178-
FD_SET(handler->fd, &readfds);
179-
}
154+
FD_SET(handler->fd, &readfds);
180155
}
181156
if (handler->event_types & NETIO_EVENT_WRITE) {
182157
FD_SET(handler->fd, &writefds);

netio.h

-3
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@
5050

5151
#include "region-allocator.h"
5252

53-
#define NETIO_SLOW_ACCEPT_TIMEOUT 2 /* in seconds */
54-
5553
/*
5654
* The type of events a handler is interested in. These can be OR'ed
5755
* together to specify multiple event types.
@@ -62,7 +60,6 @@ enum netio_event_types {
6260
NETIO_EVENT_WRITE = 2,
6361
NETIO_EVENT_EXCEPT = 4,
6462
NETIO_EVENT_TIMEOUT = 8,
65-
NETIO_EVENT_ACCEPT = 16
6663
};
6764
typedef enum netio_event_types netio_event_types_type;
6865

nsd.h

+2
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,10 @@ int server_init(struct nsd *nsd);
232232
int server_prepare(struct nsd *nsd);
233233
void server_main(struct nsd *nsd);
234234
void server_child(struct nsd *nsd);
235+
struct event_base* nsd_child_event_base(void);
235236
/* extra domain numbers for temporary domains */
236237
#define EXTRA_DOMAIN_NUMBERS 1024
238+
#define SLOW_ACCEPT_TIMEOUT 2 /* in seconds */
237239
/* allocate and init xfrd variables */
238240
void server_prepare_xfrd(struct nsd *nsd);
239241
/* start xfrdaemon (again) */

remote.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ int daemon_remote_open_ports(struct daemon_remote* rc,
8686
* Setup comm points for accepting remote control connections.
8787
* @param rc: state
8888
* @param xfrd: the process that hosts the control connection.
89-
* The rc is attached to its netio.
89+
* The rc is attached to its event base.
9090
*/
9191
void daemon_remote_attach(struct daemon_remote* rc, struct xfrd_state* xfrd);
9292

0 commit comments

Comments
 (0)