s3-printing: update parent smbd pcap cache
authorDavid Disseldorp <ddiss@suse.de>
Mon, 10 Jan 2011 13:08:07 +0000 (14:08 +0100)
committerKarolin Seeger <kseeger@samba.org>
Sat, 5 Mar 2011 13:34:50 +0000 (14:34 +0100)
If a client connects to a samba share and while connected a printer is
added, the client will see the new printer share after a maximum of
'printcap cache time' seconds.

smbd's forked for new client connections inherit printcap information
from the parent (listener) smbd, which does not perform updates on
printcap cache time expiry. Therefore newly connected clients may
initially be presented with stale printer shares.

Add a housekeeping function to the parent smbd to ensure newly connected
clients see up to date printer shares.

The last 2 patches address bug #7836 (A newly added printer isn't visbile to
clients).
(cherry picked from commit 5a2b2d4aeb6fe4af13aa0c92d22ba5bc9b7f7e13)

source3/include/local.h
source3/smbd/process.c
source3/smbd/server.c

index a88b17be137353194e64674829ee78194a5992f9..d65cc001a91d99158885df62120626d973175949 100644 (file)
 #define LPQ_LOCK_TIMEOUT (5)
 #define NMBD_INTERFACES_RELOAD (120)
 #define NMBD_UNEXPECTED_TIMEOUT (15)
+#define SMBD_HOUSEKEEPING_INTERVAL SMBD_SELECT_TIMEOUT
 
 /* the following are in milliseconds */
 #define LOCK_RETRY_TIMEOUT (100)
index 1596c0d1e72a3da05663d7843d84a1a360e70df3..21b2c910401896fe7bcef2358bd03abbc0e197df 100644 (file)
@@ -2079,7 +2079,7 @@ void check_reload(time_t t)
                        || (t-last_printer_reload_time  < 0) ) 
                {
                        DEBUG( 3,( "Printcap cache time expired.\n"));
-                       reload_printers();
+                       pcap_cache_reload(&reload_printers);
                        last_printer_reload_time = t;
                }
        }
@@ -2365,7 +2365,7 @@ void smbd_process(void)
        }
 
        if (!(event_add_idle(smbd_event_context(), NULL,
-                            timeval_set(SMBD_SELECT_TIMEOUT, 0),
+                            timeval_set(SMBD_HOUSEKEEPING_INTERVAL, 0),
                             "housekeeping", housekeeping_fn, NULL))) {
                DEBUG(0, ("Could not add housekeeping event\n"));
                exit(1);
index 901b8164cc9d3c3e0e1df6c44bf09f5c2396e3a6..45d9270e63bd38c0db8d9c6d4b9976f9b5645f3e 100644 (file)
@@ -541,6 +541,14 @@ static bool smbd_open_one_socket(struct smbd_parent_context *parent,
        return true;
 }
 
+static bool parent_housekeeping_fn(const struct timeval *now, void *private_data)
+{
+       DEBUG(5, ("houskeeping\n"));
+       /* check if we need to reload services */
+       check_reload(time(NULL));
+       return true;
+}
+
 /****************************************************************************
  Open the socket communication.
 ****************************************************************************/
@@ -668,6 +676,14 @@ static bool open_sockets_smbd(struct smbd_parent_context *parent,
        claim_connection(NULL,"",
                         FLAG_MSG_GENERAL|FLAG_MSG_SMBD|FLAG_MSG_DBWRAP);
 
+       if (!(event_add_idle(smbd_event_context(), NULL,
+                            timeval_set(SMBD_HOUSEKEEPING_INTERVAL, 0),
+                            "parent_housekeeping", parent_housekeeping_fn,
+                            parent))) {
+               DEBUG(0, ("Could not add housekeeping event\n"));
+               exit(1);
+       }
+
         /* Listen to messages */
 
        messaging_register(smbd_messaging_context(), NULL,