Ignore:
Timestamp:
Nov 27, 2012, 4:43:17 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated trunk to 3.6.0

Location:
trunk/server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/server

  • trunk/server/source3/utils/net_cache.c

    r414 r745  
    3434 * Both of them are defined by first arg of gencache_iterate() routine.
    3535 */
    36 static void print_cache_entry(const char* keystr, const char* datastr,
     36static void print_cache_entry(const char* keystr, DATA_BLOB value,
    3737                              const time_t timeout, void* dptr)
    3838{
    3939        char *timeout_str;
    4040        char *alloc_str = NULL;
     41        const char *datastr;
     42        char *datastr_free = NULL;
    4143        time_t now_t = time(NULL);
    42         struct tm timeout_tm, *now_tm;
    43         /* localtime returns statically allocated pointer, so timeout_tm
    44            has to be copied somewhere else */
    45 
    46         now_tm = localtime(&timeout);
    47         if (!now_tm) {
     44        struct tm timeout_tm, now_tm;
     45        struct tm *ptimeout_tm, *pnow_tm;
     46
     47        ptimeout_tm = localtime_r(&timeout, &timeout_tm);
     48        if (ptimeout_tm == NULL) {
    4849                return;
    4950        }
    50         memcpy(&timeout_tm, now_tm, sizeof(struct tm));
    51         now_tm = localtime(&now_t);
    52         if (!now_tm) {
     51        pnow_tm = localtime_r(&now_t, &now_tm);
     52        if (pnow_tm == NULL) {
    5353                return;
    5454        }
    5555
    5656        /* form up timeout string depending whether it's today's date or not */
    57         if (timeout_tm.tm_year != now_tm->tm_year ||
    58                         timeout_tm.tm_mon != now_tm->tm_mon ||
    59                         timeout_tm.tm_mday != now_tm->tm_mday) {
     57        if (timeout_tm.tm_year != now_tm.tm_year ||
     58                        timeout_tm.tm_mon != now_tm.tm_mon ||
     59                        timeout_tm.tm_mday != now_tm.tm_mday) {
    6060
    6161                timeout_str = asctime(&timeout_tm);
     
    7272        }
    7373
     74        datastr = (char *)value.data;
     75
     76        if ((value.length > 0) && (value.data[value.length-1] != '\0')) {
     77                datastr_free = talloc_asprintf(
     78                        talloc_tos(), "<binary length %d>",
     79                        (int)value.length);
     80                datastr = datastr_free;
     81                if (datastr == NULL) {
     82                        datastr = "<binary>";
     83                }
     84        }
     85
    7486        d_printf(_("Key: %s\t Timeout: %s\t Value: %s  %s\n"), keystr,
    7587                 timeout_str, datastr, timeout > now_t ? "": _("(expired)"));
     
    221233{
    222234        const char* keystr = argv[0];
    223         char* valuestr = NULL;
     235        DATA_BLOB value;
    224236        time_t timeout;
    225237
     
    231243        }
    232244
    233         if (gencache_get(keystr, &valuestr, &timeout)) {
    234                 print_cache_entry(keystr, valuestr, timeout, NULL);
    235                 SAFE_FREE(valuestr);
     245        if (gencache_get_data_blob(keystr, &value, &timeout, NULL)) {
     246                print_cache_entry(keystr, value, timeout, NULL);
     247                data_blob_free(&value);
    236248                return 0;
    237249        }
     
    261273
    262274        pattern = argv[0];
    263         gencache_iterate(print_cache_entry, NULL, pattern);
     275        gencache_iterate_blobs(print_cache_entry, NULL, pattern);
    264276        return 0;
    265277}
     
    285297                return 0;
    286298        }
    287         gencache_iterate(print_cache_entry, NULL, pattern);
     299        gencache_iterate_blobs(print_cache_entry, NULL, pattern);
    288300        return 0;
    289301}
Note: See TracChangeset for help on using the changeset viewer.