Changeset 862 for trunk/server/source3/smbd/server_reload.c
- Timestamp:
- May 13, 2014, 11:39:04 AM (11 years ago)
- Location:
- trunk/server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 860
- Property svn:mergeinfo changed
-
trunk/server/source3/smbd/server_reload.c
r751 r862 37 37 struct messaging_context *msg_ctx) 38 38 { 39 int n_services; 40 int pnum; 41 int snum; 42 const char *pname; 43 44 n_services = lp_numservices(); 45 pnum = lp_servicenumber(PRINTERS_NAME); 46 47 DEBUG(10, ("reloading printer services from pcap cache\n")); 48 49 /* 50 * Add default config for printers added to smb.conf file and remove 51 * stale printers 52 */ 53 for (snum = 0; snum < n_services; snum++) { 54 /* avoid removing PRINTERS_NAME */ 55 if (snum == pnum) { 56 continue; 57 } 58 59 /* skip no-printer services */ 60 if (!(lp_snum_ok(snum) && lp_print_ok(snum))) { 61 continue; 62 } 63 64 pname = lp_printername(snum); 65 66 /* check printer, but avoid removing non-autoloaded printers */ 67 if (lp_autoloaded(snum) && !pcap_printername_ok(pname)) { 68 DEBUG(3, ("removing stale printer %s\n", pname)); 69 lp_killservice(snum); 70 } 71 } 72 73 /* Make sure deleted printers are gone */ 74 load_printers(ev, msg_ctx); 75 } 76 77 /**************************************************************************** 78 purge stale printers and reload from pre-populated pcap cache 79 **************************************************************************/ 80 void reload_printers_full(struct tevent_context *ev, 81 struct messaging_context *msg_ctx) 82 { 39 83 struct auth_serversupplied_info *session_info = NULL; 40 struct spoolss_PrinterInfo2 *pinfo2 = NULL;41 84 int n_services; 42 85 int pnum; … … 46 89 NTSTATUS status; 47 90 48 load_printers(ev, msg_ctx);49 50 91 n_services = lp_numservices(); 51 92 pnum = lp_servicenumber(PRINTERS_NAME); 52 93 53 DEBUG(10, ("reloading printer services from pcap cache\n")); 54 55 status = make_session_info_system(talloc_tos(), &session_info); 94 status = make_session_info_system(talloc_new(NULL), &session_info); 56 95 if (!NT_STATUS_IS_OK(status)) { 57 DEBUG(3, ("reload_printers: " 58 "Could not create system session_info\n")); 96 DEBUG(3, ("Could not create system session_info\n")); 59 97 /* can't remove stale printers before we 60 98 * are fully initilized */ … … 82 120 /* check printer, but avoid removing non-autoloaded printers */ 83 121 if (lp_autoloaded(snum) && !pcap_printername_ok(pname)) { 84 DEBUG(3, ("removing stale printer %s\n", pname)); 85 122 struct spoolss_PrinterInfo2 *pinfo2 = NULL; 86 123 if (is_printer_published(session_info, session_info, 87 124 msg_ctx, 88 NULL, lp_servicename(snum), 89 NULL, &pinfo2)) { 125 NULL, 126 lp_servicename(snum), 127 &pinfo2)) { 90 128 nt_printer_publish(session_info, 91 129 session_info, … … 97 135 nt_printer_remove(session_info, session_info, msg_ctx, 98 136 pname); 99 lp_killservice(snum);100 137 } else { 101 138 DEBUG(8, ("Adding default registry entry for printer " … … 106 143 } 107 144 108 /* Make sure deleted printers are gone*/109 load_printers(ev, msg_ctx);145 /* finally, purge old snums */ 146 reload_printers(ev, msg_ctx); 110 147 111 148 TALLOC_FREE(session_info); … … 161 198 return(ret); 162 199 } 163 164 /****************************************************************************165 Notify smbds of new printcap data166 **************************************************************************/167 void reload_pcap_change_notify(struct tevent_context *ev,168 struct messaging_context *msg_ctx)169 {170 /*171 * Reload the printers first in the background process so that172 * newly added printers get default values created in the registry.173 *174 * This will block the process for some time (~1 sec per printer), but175 * it doesn't block smbd's servering clients.176 */177 reload_printers(ev, msg_ctx);178 179 message_send_all(msg_ctx, MSG_PRINTER_PCAP, NULL, 0, NULL);180 }
Note:
See TracChangeset
for help on using the changeset viewer.