summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2000-09-11 07:33:44 +0000
committerAndrew Tridgell <tridge@samba.org>2000-09-11 07:33:44 +0000
commit6a503f95b10f6661b089f30f2b5ffebead32685c (patch)
tree70fa529a1b654159b9d9b98d291b54884956f195 /source
parentdb1ec05f89071cd1ae4b190dda843b38e2d97cef (diff)
downloadsamba-6a503f95b10f6661b089f30f2b5ffebead32685c.tar.gz
samba-6a503f95b10f6661b089f30f2b5ffebead32685c.tar.xz
samba-6a503f95b10f6661b089f30f2b5ffebead32685c.zip
debug messages now work for nmbd
Diffstat (limited to 'source')
-rw-r--r--source/nmbd/nmbd.c4
-rw-r--r--source/nmbd/nmbd_packets.c157
2 files changed, 79 insertions, 82 deletions
diff --git a/source/nmbd/nmbd.c b/source/nmbd/nmbd.c
index cd472967747..2da879fc943 100644
--- a/source/nmbd/nmbd.c
+++ b/source/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/source/nmbd/nmbd_packets.c b/source/nmbd/nmbd_packets.c
index 605233f40d3..d1f77fe2d22 100644
--- a/source/nmbd/nmbd_packets.c
+++ b/source/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;
}