summaryrefslogtreecommitdiff
path: root/source3/nmbd/nmbd_packets.c
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2007-05-15 13:44:11 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:22:06 -0500
commitab7a9d2bbe95ac2194db7eb358e3bf1ba4aa8890 (patch)
treefcf302a54401c8d8bc8eac9617957ebb13ea53df /source3/nmbd/nmbd_packets.c
parent83a7d9558b5eb686863d44bd7ef00a9e5926edfd (diff)
downloadsamba-ab7a9d2bbe95ac2194db7eb358e3bf1ba4aa8890.tar.gz
samba-ab7a9d2bbe95ac2194db7eb358e3bf1ba4aa8890.tar.bz2
samba-ab7a9d2bbe95ac2194db7eb358e3bf1ba4aa8890.zip
r22902: Add an event_context and a messaging_context to nmbd. Not used yet.
(This used to be commit 6d210fb8a13e93fe5b7bc160a343f74878dea727)
Diffstat (limited to 'source3/nmbd/nmbd_packets.c')
-rw-r--r--source3/nmbd/nmbd_packets.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/source3/nmbd/nmbd_packets.c b/source3/nmbd/nmbd_packets.c
index d34beb7ff6..2fbf2f4146 100644
--- a/source3/nmbd/nmbd_packets.c
+++ b/source3/nmbd/nmbd_packets.c
@@ -1730,7 +1730,8 @@ BOOL listen_for_packets(BOOL run_election)
int i;
static int maxfd = 0;
- fd_set fds;
+ fd_set r_fds;
+ fd_set w_fds;
int selrtn;
struct timeval timeout;
#ifndef SYNC_DNS
@@ -1745,12 +1746,13 @@ BOOL listen_for_packets(BOOL run_election)
rescan_listen_set = False;
}
- memcpy((char *)&fds, (char *)listen_set, sizeof(fd_set));
+ memcpy((char *)&r_fds, (char *)listen_set, sizeof(fd_set));
+ FD_ZERO(&w_fds);
#ifndef SYNC_DNS
dns_fd = asyncdns_fd();
if (dns_fd != -1) {
- FD_SET(dns_fd, &fds);
+ FD_SET(dns_fd, &r_fds);
maxfd = MAX( maxfd, dns_fd);
}
#endif
@@ -1765,11 +1767,24 @@ BOOL listen_for_packets(BOOL run_election)
timeout.tv_sec = (run_election||num_response_packets) ? 1 : NMBD_SELECT_LOOP;
timeout.tv_usec = 0;
+ {
+ struct timeval now = timeval_current();
+ event_add_to_select_args(nmbd_event_context(), &now,
+ &r_fds, &w_fds, &timeout, &maxfd);
+ }
+
+ if (timeval_is_zero(&timeout)) {
+ /* Process a timed event now... */
+ if (run_events(nmbd_event_context(), 0, NULL, NULL)) {
+ return False;
+ }
+ }
+
/* Prepare for the select - allow certain signals. */
BlockSignals(False, SIGTERM);
- selrtn = sys_select(maxfd+1,&fds,NULL,NULL,&timeout);
+ selrtn = sys_select(maxfd+1,&r_fds,&w_fds,NULL,&timeout);
/* We can only take signals when we are in the select - block them again here. */
@@ -1779,8 +1794,12 @@ BOOL listen_for_packets(BOOL run_election)
return False;
}
+ if (run_events(nmbd_event_context(), selrtn, &r_fds, &w_fds)) {
+ return False;
+ }
+
#ifndef SYNC_DNS
- if (dns_fd != -1 && FD_ISSET(dns_fd,&fds)) {
+ if (dns_fd != -1 && FD_ISSET(dns_fd,&r_fds)) {
run_dns_queue();
}
#endif
@@ -1788,7 +1807,7 @@ BOOL listen_for_packets(BOOL run_election)
for(i = 0; i < listen_number; i++) {
if (i < (listen_number/2)) {
/* Processing a 137 socket. */
- if (FD_ISSET(sock_array[i],&fds)) {
+ if (FD_ISSET(sock_array[i],&r_fds)) {
struct packet_struct *packet = read_packet(sock_array[i], NMB_PACKET);
if (packet) {
/*
@@ -1815,7 +1834,7 @@ BOOL listen_for_packets(BOOL run_election)
}
} else {
/* Processing a 138 socket. */
- if (FD_ISSET(sock_array[i],&fds)) {
+ if (FD_ISSET(sock_array[i],&r_fds)) {
struct packet_struct *packet = read_packet(sock_array[i], DGRAM_PACKET);
if (packet) {
/*