summaryrefslogtreecommitdiff
path: root/source3/nmbd
diff options
context:
space:
mode:
Diffstat (limited to 'source3/nmbd')
-rw-r--r--source3/nmbd/nmbd.c4
-rw-r--r--source3/nmbd/nmbd_packets.c157
2 files changed, 79 insertions, 82 deletions
diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c
index cd47296774..2da879fc94 100644
--- a/source3/nmbd/nmbd.c
+++ b/source3/nmbd/nmbd.c
@@ -490,6 +490,9 @@ static void process(void)
/* free up temp memory */
lp_talloc_free();
+
+ /* check for internal messages */
+ message_init();
}
} /* process */
@@ -791,6 +794,7 @@ static void usage(char *pname)
}
pidfile_create("nmbd");
+ message_init();
DEBUG( 3, ( "Opening sockets %d\n", global_nmb_port ) );
diff --git a/source3/nmbd/nmbd_packets.c b/source3/nmbd/nmbd_packets.c
index 605233f40d..d1f77fe2d2 100644
--- a/source3/nmbd/nmbd_packets.c
+++ b/source3/nmbd/nmbd_packets.c
@@ -1759,7 +1759,16 @@ only use %d.\n", (count*2) + 2, FD_SETSIZE));
}
/****************************************************************************
+do any signal triggered processing
+***************************************************************************/
+static void nmbd_async_processing(void)
+{
+ message_dispatch();
+}
+
+/****************************************************************************
Listens for NMB or DGRAM packets, and queues them.
+ return True if the socket is dead
***************************************************************************/
BOOL listen_for_packets(BOOL run_election)
@@ -1767,6 +1776,7 @@ BOOL listen_for_packets(BOOL run_election)
static fd_set *listen_set = NULL;
static int listen_number = 0;
static int *sock_array = NULL;
+ int i;
fd_set fds;
int selrtn;
@@ -1809,97 +1819,80 @@ BOOL listen_for_packets(BOOL run_election)
BlockSignals(False, SIGTERM);
- selrtn = sys_select_intr(FD_SETSIZE,&fds,&timeout);
+ selrtn = sys_select(FD_SETSIZE,&fds,&timeout);
/* We can only take signals when we are in the select - block them again here. */
BlockSignals(True, SIGTERM);
- if(selrtn > 0)
- {
- int i;
+ if(selrtn == -1) {
+ if (errno == EINTR) {
+ nmbd_async_processing();
+ }
+ return False;
+ }
#ifndef SYNC_DNS
- if (dns_fd != -1 && FD_ISSET(dns_fd,&fds)) {
- run_dns_queue();
- }
+ if (dns_fd != -1 && FD_ISSET(dns_fd,&fds)) {
+ run_dns_queue();
+ }
#endif
- for(i = 0; i < listen_number; i++)
- {
- if(i < (listen_number/2))
- {
- /* Processing a 137 socket. */
- if (FD_ISSET(sock_array[i],&fds))
- {
- struct packet_struct *packet = read_packet(sock_array[i], NMB_PACKET);
- if (packet)
- {
- /*
- * If we got a packet on the broadcast socket and interfaces
- * only is set then check it came from one of our local nets.
- */
- if(lp_bind_interfaces_only() && (sock_array[i] == ClientNMB) &&
- (!is_local_net(packet->ip)))
- {
- DEBUG(7,("discarding nmb packet sent to broadcast socket from %s:%d\n",
- inet_ntoa(packet->ip),packet->port));
- free_packet(packet);
- }
- else if ((ip_equal(loopback_ip, packet->ip) ||
- ismyip(packet->ip)) && packet->port == global_nmb_port)
- {
- DEBUG(7,("discarding own packet from %s:%d\n",
- inet_ntoa(packet->ip),packet->port));
- free_packet(packet);
- }
- else
- {
- /* Save the file descriptor this packet came in on. */
- packet->fd = sock_array[i];
- queue_packet(packet);
- }
- }
- }
- }
- else
- {
- /* Processing a 138 socket. */
-
- if (FD_ISSET(sock_array[i],&fds))
- {
- struct packet_struct *packet = read_packet(sock_array[i], DGRAM_PACKET);
- if (packet)
- {
- /*
- * If we got a packet on the broadcast socket and interfaces
- * only is set then check it came from one of our local nets.
- */
- if(lp_bind_interfaces_only() && (sock_array[i] == ClientDGRAM) &&
- (!is_local_net(packet->ip)))
- {
- DEBUG(7,("discarding dgram packet sent to broadcast socket from %s:%d\n",
- inet_ntoa(packet->ip),packet->port));
- free_packet(packet);
- }
- else if ((ip_equal(loopback_ip, packet->ip) ||
- ismyip(packet->ip)) && packet->port == DGRAM_PORT)
- {
- DEBUG(7,("discarding own packet from %s:%d\n",
- inet_ntoa(packet->ip),packet->port));
- free_packet(packet);
- }
- else
- {
- /* Save the file descriptor this packet came in on. */
- packet->fd = sock_array[i];
- queue_packet(packet);
- }
- }
- }
- } /* end processing 138 socket. */
- } /* end for */
- } /* end if selret > 0 */
+ for(i = 0; i < listen_number; i++) {
+ if (i < (listen_number/2)) {
+ /* Processing a 137 socket. */
+ if (FD_ISSET(sock_array[i],&fds)) {
+ struct packet_struct *packet = read_packet(sock_array[i], NMB_PACKET);
+ if (packet) {
+ /*
+ * If we got a packet on the broadcast socket and interfaces
+ * only is set then check it came from one of our local nets.
+ */
+ if(lp_bind_interfaces_only() && (sock_array[i] == ClientNMB) &&
+ (!is_local_net(packet->ip))) {
+ DEBUG(7,("discarding nmb packet sent to broadcast socket from %s:%d\n",
+ inet_ntoa(packet->ip),packet->port));
+ free_packet(packet);
+ } else if ((ip_equal(loopback_ip, packet->ip) ||
+ ismyip(packet->ip)) && packet->port == global_nmb_port) {
+ DEBUG(7,("discarding own packet from %s:%d\n",
+ inet_ntoa(packet->ip),packet->port));
+ free_packet(packet);
+ } else {
+ /* Save the file descriptor this packet came in on. */
+ packet->fd = sock_array[i];
+ queue_packet(packet);
+ }
+ }
+ }
+ } else {
+ /* Processing a 138 socket. */
+ if (FD_ISSET(sock_array[i],&fds)) {
+ struct packet_struct *packet = read_packet(sock_array[i], DGRAM_PACKET);
+ if (packet) {
+ /*
+ * If we got a packet on the broadcast socket and interfaces
+ * only is set then check it came from one of our local nets.
+ */
+ if(lp_bind_interfaces_only() && (sock_array[i] == ClientDGRAM) &&
+ (!is_local_net(packet->ip))) {
+ DEBUG(7,("discarding dgram packet sent to broadcast socket from %s:%d\n",
+ inet_ntoa(packet->ip),packet->port));
+ free_packet(packet);
+ } else if ((ip_equal(loopback_ip, packet->ip) ||
+ ismyip(packet->ip)) && packet->port == DGRAM_PORT) {
+ DEBUG(7,("discarding own packet from %s:%d\n",
+ inet_ntoa(packet->ip),packet->port));
+ free_packet(packet);
+ } else {
+ /* Save the file descriptor this packet came in on. */
+ packet->fd = sock_array[i];
+ queue_packet(packet);
+ }
+ }
+ }
+ } /* end processing 138 socket. */
+ } /* end for */
return False;
}