Changeset 751 for trunk/server/source3/smbd/server_reload.c
- Timestamp:
- Nov 29, 2012, 1:59:04 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server/source3/smbd/server_reload.c
r745 r751 39 39 struct auth_serversupplied_info *session_info = NULL; 40 40 struct spoolss_PrinterInfo2 *pinfo2 = NULL; 41 int n_services; 42 int pnum; 41 43 int snum; 42 int n_services = lp_numservices();43 int pnum = lp_servicenumber(PRINTERS_NAME);44 44 const char *pname; 45 const char *sname; 45 46 NTSTATUS status; 46 bool skip = false;47 47 48 SMB_ASSERT(pcap_cache_loaded()); 48 load_printers(ev, msg_ctx); 49 50 n_services = lp_numservices(); 51 pnum = lp_servicenumber(PRINTERS_NAME); 52 49 53 DEBUG(10, ("reloading printer services from pcap cache\n")); 50 54 … … 55 59 /* can't remove stale printers before we 56 60 * are fully initilized */ 57 skip = true;61 return; 58 62 } 59 63 60 /* remove stale printers */ 61 for (snum = 0; skip == false && snum < n_services; snum++) { 62 /* avoid removing PRINTERS_NAME or non-autoloaded printers */ 63 if (snum == pnum || !(lp_snum_ok(snum) && lp_print_ok(snum) && 64 lp_autoloaded(snum))) 64 /* 65 * Add default config for printers added to smb.conf file and remove 66 * stale printers 67 */ 68 for (snum = 0; snum < n_services; snum++) { 69 /* avoid removing PRINTERS_NAME */ 70 if (snum == pnum) { 65 71 continue; 72 } 66 73 74 /* skip no-printer services */ 75 if (!(lp_snum_ok(snum) && lp_print_ok(snum))) { 76 continue; 77 } 78 79 sname = lp_const_servicename(snum); 67 80 pname = lp_printername(snum); 68 if (!pcap_printername_ok(pname)) { 81 82 /* check printer, but avoid removing non-autoloaded printers */ 83 if (lp_autoloaded(snum) && !pcap_printername_ok(pname)) { 69 84 DEBUG(3, ("removing stale printer %s\n", pname)); 70 85 … … 83 98 pname); 84 99 lp_killservice(snum); 100 } else { 101 DEBUG(8, ("Adding default registry entry for printer " 102 "[%s], if it doesn't exist.\n", sname)); 103 nt_printer_add(session_info, session_info, msg_ctx, 104 sname); 85 105 } 86 106 } 87 107 108 /* Make sure deleted printers are gone */ 88 109 load_printers(ev, msg_ctx); 89 110 … … 107 128 test = False; 108 129 } 130 TALLOC_FREE(fname); 109 131 } 110 132 … … 146 168 struct messaging_context *msg_ctx) 147 169 { 170 /* 171 * Reload the printers first in the background process so that 172 * newly added printers get default values created in the registry. 173 * 174 * This will block the process for some time (~1 sec per printer), but 175 * it doesn't block smbd's servering clients. 176 */ 177 reload_printers(ev, msg_ctx); 178 148 179 message_send_all(msg_ctx, MSG_PRINTER_PCAP, NULL, 0, NULL); 149 180 }
Note:
See TracChangeset
for help on using the changeset viewer.