summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarolin Seeger <kseeger@samba.org>2011-01-15 19:06:16 +0100
committerKarolin Seeger <kseeger@samba.org>2011-01-15 19:06:16 +0100
commit36ea03bbe28122ce03de4969e254dd276cfe5a79 (patch)
tree1e762eb163ba1629a32e9745250338a836748d1b
parentfbcecec057bc05d6fcbdab3ef90d32c56335e833 (diff)
downloadsamba-36ea03bbe28122ce03de4969e254dd276cfe5a79.tar.gz
Revert "s3-printing: reload shares after pcap cache fill"
This reverts commit 9bc0cd243ac66126d42905dd8710d078094e0cd7. This commit seems to break 'make test'.
-rw-r--r--source3/include/proto.h4
-rw-r--r--source3/printing/load.c5
-rw-r--r--source3/printing/pcap.c18
-rw-r--r--source3/printing/print_cups.c33
-rw-r--r--source3/smbd/server.c12
-rw-r--r--source3/web/swat.c4
6 files changed, 26 insertions, 50 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 46ed4ab07ed..7c2893b1798 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -4869,7 +4869,7 @@ void pcap_cache_destroy_specific(struct pcap_cache **ppcache);
bool pcap_cache_add(const char *name, const char *comment);
bool pcap_cache_loaded(void);
void pcap_cache_replace(const struct pcap_cache *cache);
-void pcap_cache_reload(void (*post_cache_fill_fn)(void));
+void pcap_cache_reload(void);
bool pcap_printername_ok(const char *printername);
void pcap_printer_fn_specific(const struct pcap_cache *, void (*fn)(const char *, const char *, void *), void *);
void pcap_printer_fn(void (*fn)(const char *, const char *, void *), void *);
@@ -4880,7 +4880,7 @@ bool aix_cache_reload(void);
/* The following definitions come from printing/print_cups.c */
-bool cups_cache_reload(void (*post_cache_fill_fn)(void));
+bool cups_cache_reload(void);
bool cups_pull_comment_location(NT_PRINTER_INFO_LEVEL_2 *printer);
/* The following definitions come from printing/print_generic.c */
diff --git a/source3/printing/load.c b/source3/printing/load.c
index 00da9cb2921..874f7f25215 100644
--- a/source3/printing/load.c
+++ b/source3/printing/load.c
@@ -53,11 +53,12 @@ static void add_auto_printers(void)
}
/***************************************************************************
-load automatic printer services from pre-populated pcap cache
+load automatic printer services
***************************************************************************/
void load_printers(void)
{
- SMB_ASSERT(pcap_cache_loaded());
+ if (!pcap_cache_loaded())
+ pcap_cache_reload();
add_auto_printers();
diff --git a/source3/printing/pcap.c b/source3/printing/pcap.c
index 0d6480ce015..a6bf52a0a4c 100644
--- a/source3/printing/pcap.c
+++ b/source3/printing/pcap.c
@@ -125,14 +125,13 @@ void pcap_cache_replace(const struct pcap_cache *pcache)
}
}
-void pcap_cache_reload(void (*post_cache_fill_fn)(void))
+void pcap_cache_reload(void)
{
const char *pcap_name = lp_printcapname();
bool pcap_reloaded = False;
struct pcap_cache *tmp_cache = NULL;
XFILE *pcap_file;
char *pcap_line;
- bool post_cache_fill_fn_handled = false;
DEBUG(3, ("reloading printcap cache\n"));
@@ -147,12 +146,7 @@ void pcap_cache_reload(void (*post_cache_fill_fn)(void))
#ifdef HAVE_CUPS
if (strequal(pcap_name, "cups")) {
- pcap_reloaded = cups_cache_reload(post_cache_fill_fn);
- /*
- * cups_cache_reload() is async and calls post_cache_fill_fn()
- * on successful completion
- */
- post_cache_fill_fn_handled = true;
+ pcap_reloaded = cups_cache_reload();
goto done;
}
#endif
@@ -248,13 +242,9 @@ void pcap_cache_reload(void (*post_cache_fill_fn)(void))
done:
DEBUG(3, ("reload status: %s\n", (pcap_reloaded) ? "ok" : "error"));
- if (pcap_reloaded) {
+ if (pcap_reloaded)
pcap_cache_destroy_specific(&tmp_cache);
- if ((post_cache_fill_fn_handled == false)
- && (post_cache_fill_fn != NULL)) {
- post_cache_fill_fn();
- }
- } else {
+ else {
pcap_cache_destroy_specific(&pcap_cache);
pcap_cache = tmp_cache;
}
diff --git a/source3/printing/print_cups.c b/source3/printing/print_cups.c
index a8cc538942e..e2c8b7e0fbf 100644
--- a/source3/printing/print_cups.c
+++ b/source3/printing/print_cups.c
@@ -440,19 +440,13 @@ static bool cups_pcap_load_async(int *pfd)
_exit(0);
}
-struct cups_async_cb_args {
- int pipe_fd;
- void (*post_cache_fill_fn)(void);
-};
-
static void cups_async_callback(struct event_context *event_ctx,
struct fd_event *event,
uint16 flags,
void *p)
{
TALLOC_CTX *frame = talloc_stackframe();
- struct cups_async_cb_args *cb_args = (struct cups_async_cb_args *)p;
- int fd = cb_args->pipe_fd;
+ int fd = *(int *)p;
struct pcap_cache *tmp_pcap_cache = NULL;
DEBUG(5,("cups_async_callback: callback received for printer data. "
@@ -546,36 +540,27 @@ static void cups_async_callback(struct event_context *event_ctx,
/* And the systemwide pcap cache. */
pcap_cache_replace(local_pcap_copy);
-
- /* Caller may have requested post cache fill callback */
- if (cb_args->post_cache_fill_fn) {
- cb_args->post_cache_fill_fn();
- }
} else {
DEBUG(2,("cups_async_callback: failed to read a new "
"printer list\n"));
}
close(fd);
- TALLOC_FREE(cb_args);
+ TALLOC_FREE(p);
TALLOC_FREE(cache_fd_event);
}
-bool cups_cache_reload(void (*post_cache_fill_fn)(void))
+bool cups_cache_reload(void)
{
- struct cups_async_cb_args *cb_args;
- int *p_pipe_fd;
+ int *p_pipe_fd = TALLOC_P(NULL, int);
- cb_args = TALLOC_P(NULL, struct cups_async_cb_args);
- if (!cb_args) {
+ if (!p_pipe_fd) {
return false;
}
- cb_args->post_cache_fill_fn = post_cache_fill_fn;
- p_pipe_fd = &cb_args->pipe_fd;
+
*p_pipe_fd = -1;
/* Set up an async refresh. */
if (!cups_pcap_load_async(p_pipe_fd)) {
- talloc_free(cb_args);
return false;
}
if (!local_pcap_copy) {
@@ -588,7 +573,7 @@ bool cups_cache_reload(void (*post_cache_fill_fn)(void))
cups_async_callback(smbd_event_context(),
NULL,
EVENT_FD_READ,
- (void *)cb_args);
+ (void *)p_pipe_fd);
if (!local_pcap_copy) {
return false;
}
@@ -605,10 +590,10 @@ bool cups_cache_reload(void (*post_cache_fill_fn)(void))
NULL, *p_pipe_fd,
EVENT_FD_READ,
cups_async_callback,
- (void *)cb_args);
+ (void *)p_pipe_fd);
if (!cache_fd_event) {
close(*p_pipe_fd);
- talloc_free(cb_args);
+ TALLOC_FREE(p_pipe_fd);
return false;
}
}
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 6147526172c..d393f26d51c 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -705,9 +705,9 @@ static void smbd_parent_loop(struct smbd_parent_context *parent)
/* NOTREACHED return True; */
}
-/***************************************************************************
- purge stale printers and reload from pre-populated pcap cache
-***************************************************************************/
+/****************************************************************************
+ Reload printers
+**************************************************************************/
void reload_printers(void)
{
int snum;
@@ -715,9 +715,9 @@ void reload_printers(void)
int pnum = lp_servicenumber(PRINTERS_NAME);
const char *pname;
- SMB_ASSERT(pcap_cache_loaded());
+ pcap_cache_reload();
- DEBUG(10, ("reloading printer services from pcap cache\n"));
+ /* remove stale printers */
for (snum = 0; snum < n_services; snum++) {
/* avoid removing PRINTERS_NAME or non-autoloaded printers */
if (snum == pnum || !(lp_snum_ok(snum) && lp_print_ok(snum) &&
@@ -764,7 +764,7 @@ bool reload_services(bool test)
ret = lp_load(get_dyn_CONFIGFILE(), False, False, True, True);
- pcap_cache_reload(&reload_printers);
+ reload_printers();
/* perhaps the config filename is now set */
if (!test)
diff --git a/source3/web/swat.c b/source3/web/swat.c
index 67410824c12..4bfb7318148 100644
--- a/source3/web/swat.c
+++ b/source3/web/swat.c
@@ -490,7 +490,7 @@ static int save_reload(int snum)
return 0;
}
iNumNonAutoPrintServices = lp_numservices();
- pcap_cache_reload(&load_printers);
+ load_printers();
return 1;
}
@@ -1434,7 +1434,7 @@ const char *lang_msg_rotate(TALLOC_CTX *ctx, const char *msgid)
load_config(True);
load_interfaces();
iNumNonAutoPrintServices = lp_numservices();
- pcap_cache_reload(&load_printers);
+ load_printers();
cgi_setup(get_dyn_SWATDIR(), !demo_mode);