Ignore:
Timestamp:
Nov 24, 2016, 1:14:11 PM (9 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to version 4.4.3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source3/printing/pcap.c

    r740 r988  
    8484}
    8585
    86 bool pcap_cache_add(const char *name, const char *comment, const char *location)
    87 {
     86bool pcap_cache_loaded(time_t *_last_change)
     87{
     88        NTSTATUS status;
     89        time_t last;
     90
     91        status = printer_list_get_last_refresh(&last);
     92        if (!NT_STATUS_IS_OK(status)) {
     93                return false;
     94        }
     95        if (_last_change != NULL) {
     96                *_last_change = last;
     97        }
     98        return true;
     99}
     100
     101bool pcap_cache_replace(const struct pcap_cache *pcache)
     102{
     103        const struct pcap_cache *p;
    88104        NTSTATUS status;
    89105        time_t t = time_mono(NULL);
    90106
    91         status = printer_list_set_printer(talloc_tos(), name, comment, location, t);
    92         return NT_STATUS_IS_OK(status);
    93 }
    94 
    95 bool pcap_cache_loaded(void)
    96 {
    97         NTSTATUS status;
    98         time_t last;
    99 
    100         status = printer_list_get_last_refresh(&last);
    101         return NT_STATUS_IS_OK(status);
    102 }
    103 
    104 bool pcap_cache_replace(const struct pcap_cache *pcache)
    105 {
    106         const struct pcap_cache *p;
    107         NTSTATUS status;
    108 
    109107        status = printer_list_mark_reload();
    110108        if (!NT_STATUS_IS_OK(status)) {
     
    114112
    115113        for (p = pcache; p; p = p->next) {
    116                 pcap_cache_add(p->name, p->comment, p->location);
     114                status = printer_list_set_printer(talloc_tos(), p->name,
     115                                                  p->comment, p->location, t);
     116                if (!NT_STATUS_IS_OK(status)) {
     117                        return false;
     118                }
    117119        }
    118120
     
    133135        const char *pcap_name = lp_printcapname();
    134136        bool pcap_reloaded = False;
    135         NTSTATUS status;
    136137        bool post_cache_fill_fn_handled = false;
     138        struct pcap_cache *pcache = NULL;
    137139
    138140        DEBUG(3, ("reloading printcap cache\n"));
     
    141143        if (pcap_name == NULL || *pcap_name == 0) {
    142144                DEBUG(0, ("No printcap file name configured!\n"));
    143                 return;
    144         }
    145 
    146         status = printer_list_mark_reload();
    147         if (!NT_STATUS_IS_OK(status)) {
    148                 DEBUG(0, ("Failed to mark printer list for reload!\n"));
    149145                return;
    150146        }
     
    165161#ifdef HAVE_IPRINT
    166162        if (strequal(pcap_name, "iprint")) {
    167                 pcap_reloaded = iprint_cache_reload();
     163                pcap_reloaded = iprint_cache_reload(&pcache);
    168164                goto done;
    169165        }
     
    172168#if defined(SYSV) || defined(HPUX)
    173169        if (strequal(pcap_name, "lpstat")) {
    174                 pcap_reloaded = sysv_cache_reload();
     170                pcap_reloaded = sysv_cache_reload(&pcache);
    175171                goto done;
    176172        }
     
    179175#ifdef AIX
    180176        if (strstr_m(pcap_name, "/qconfig") != NULL) {
    181                 pcap_reloaded = aix_cache_reload();
    182                 goto done;
    183         }
    184 #endif
    185 
    186         pcap_reloaded = std_pcap_cache_reload(pcap_name);
    187 
     177                pcap_reloaded = aix_cache_reload(&pcache);
     178                goto done;
     179        }
     180#endif
     181
     182        pcap_reloaded = std_pcap_cache_reload(pcap_name, &pcache);
     183
     184/* Fix silly compiler warning about done not being used if none of the above
     185 * ifdefs are used */
     186#if defined(HAVE_CUPS) || defined(HAVE_IPRINT) || defined(SYSV) || defined(HPUX) || defined(AIX)
    188187done:
     188#endif
    189189        DEBUG(3, ("reload status: %s\n", (pcap_reloaded) ? "ok" : "error"));
    190190
     
    192192                /* cleanup old entries only if the operation was successful,
    193193                 * otherwise keep around the old entries until we can
    194                  * successfuly reaload */
    195                 status = printer_list_clean_old();
    196                 if (!NT_STATUS_IS_OK(status)) {
    197                         DEBUG(0, ("Failed to cleanup printer list!\n"));
     194                 * successfully reload */
     195
     196                if (!pcap_cache_replace(pcache)) {
     197                        DEBUG(0, ("Failed to replace printer list!\n"));
    198198                }
     199
    199200                if (post_cache_fill_fn != NULL) {
    200201                        post_cache_fill_fn(ev, msg_ctx);
    201202                }
    202203        }
     204        pcap_cache_destroy_specific(&pcache);
    203205
    204206        return;
     
    230232}
    231233
    232 void pcap_printer_fn(void (*fn)(const char *, const char *, const char *, void *), void *pdata)
    233 {
    234         NTSTATUS status;
    235 
    236         status = printer_list_run_fn(fn, pdata);
     234void pcap_printer_read_fn(void (*fn)(const char *, const char *, const char *, void *), void *pdata)
     235{
     236        NTSTATUS status;
     237
     238        status = printer_list_read_run_fn(fn, pdata);
    237239        if (!NT_STATUS_IS_OK(status)) {
    238240                DEBUG(3, ("Failed to run fn for all printers!\n"));
Note: See TracChangeset for help on using the changeset viewer.