Changeset 745 for trunk/server/source3/utils/net_cache.c
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/source3/utils/net_cache.c
r414 r745 34 34 * Both of them are defined by first arg of gencache_iterate() routine. 35 35 */ 36 static void print_cache_entry(const char* keystr, const char* datastr,36 static void print_cache_entry(const char* keystr, DATA_BLOB value, 37 37 const time_t timeout, void* dptr) 38 38 { 39 39 char *timeout_str; 40 40 char *alloc_str = NULL; 41 const char *datastr; 42 char *datastr_free = NULL; 41 43 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) { 48 49 return; 49 50 } 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) { 53 53 return; 54 54 } 55 55 56 56 /* 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) { 60 60 61 61 timeout_str = asctime(&timeout_tm); … … 72 72 } 73 73 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 74 86 d_printf(_("Key: %s\t Timeout: %s\t Value: %s %s\n"), keystr, 75 87 timeout_str, datastr, timeout > now_t ? "": _("(expired)")); … … 221 233 { 222 234 const char* keystr = argv[0]; 223 char* valuestr = NULL;235 DATA_BLOB value; 224 236 time_t timeout; 225 237 … … 231 243 } 232 244 233 if (gencache_get (keystr, &valuestr, &timeout)) {234 print_cache_entry(keystr, value str, 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); 236 248 return 0; 237 249 } … … 261 273 262 274 pattern = argv[0]; 263 gencache_iterate (print_cache_entry, NULL, pattern);275 gencache_iterate_blobs(print_cache_entry, NULL, pattern); 264 276 return 0; 265 277 } … … 285 297 return 0; 286 298 } 287 gencache_iterate (print_cache_entry, NULL, pattern);299 gencache_iterate_blobs(print_cache_entry, NULL, pattern); 288 300 return 0; 289 301 }
Note:
See TracChangeset
for help on using the changeset viewer.