diff options
author | Jeremy Allison <jra@samba.org> | 2008-10-10 15:55:49 -0700 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2008-10-10 15:55:49 -0700 |
commit | 430cc443901865a5c781ce4ac5cf65b450ccbe61 (patch) | |
tree | 52381cac9852369ca4797ad2c0a86c705e2b9362 /source3/printing | |
parent | eada8f8abe6e4b770b7a2e279fc897a4272b6fa5 (diff) | |
download | samba-430cc443901865a5c781ce4ac5cf65b450ccbe61.tar.gz samba-430cc443901865a5c781ce4ac5cf65b450ccbe61.tar.bz2 samba-430cc443901865a5c781ce4ac5cf65b450ccbe61.zip |
Async is trickier than it looks :-). Don't use a stack variable for a private data ptr.
Jeremy.
Diffstat (limited to 'source3/printing')
-rw-r--r-- | source3/printing/print_cups.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/source3/printing/print_cups.c b/source3/printing/print_cups.c index 6fe24e181e..14119626e5 100644 --- a/source3/printing/print_cups.c +++ b/source3/printing/print_cups.c @@ -505,24 +505,32 @@ static void cups_async_callback(struct event_context *event_ctx, "printer list\n")); } close(fd); + TALLOC_FREE(p); } bool cups_cache_reload(void) { - int fd = -1; + int *p_pipe_fd = TALLOC_P(NULL, int); + + if (!p_pipe_fd) { + return false; + } /* Set up an async refresh. */ - if (!cups_pcap_load_async(&fd)) { + if (!cups_pcap_load_async(p_pipe_fd)) { return false; } if (!local_pcap_copy) { /* We have no local cache, wait directly for * async refresh to complete. */ + DEBUG(10,("cups_cache_reload: sync read on fd %d\n", + *p_pipe_fd )); + cups_async_callback(smbd_event_context(), NULL, EVENT_FD_READ, - (void *)&fd); + (void *)p_pipe_fd); if (!local_pcap_copy) { return false; } @@ -531,14 +539,18 @@ bool cups_cache_reload(void) * local copy. */ pcap_cache_replace(local_pcap_copy); + DEBUG(10,("cups_cache_reload: async read on fd %d\n", + *p_pipe_fd )); + /* Trigger an event when the pipe can be read. */ cache_fd_event = event_add_fd(smbd_event_context(), - NULL, fd, + NULL, *p_pipe_fd, EVENT_FD_READ, cups_async_callback, - (void *)&fd); + (void *)p_pipe_fd); if (!cache_fd_event) { - close(fd); + close(*p_pipe_fd); + TALLOC_FREE(p_pipe_fd); return false; } } |