Changeset 5076 for trunk/oscam-log.c
- Timestamp:
- 04/25/11 17:34:51 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/oscam-log.c
r5065 r5076 130 130 } 131 131 132 /* 133 This function allows to reinit the in-memory loghistory with a new size. 134 */ 135 void cs_reinit_loghist(uint32_t size) 136 { 137 char *tmp, *tmp2; 138 if(size != cfg.loghistorysize){ 139 if(cs_malloc(&tmp, size, -1)){ 140 pthread_mutex_lock(&loghistory_lock); 141 tmp2 = loghist; 142 // On shrinking, the log is not copied and the order is reversed 143 if(size < cfg.loghistorysize){ 144 cfg.loghistorysize = size; 145 cs_sleepms(20); // Monitor or webif may be currently outputting the loghistory but don't use locking so we sleep a bit... 146 loghistptr = tmp; 147 loghist = tmp; 148 } else { 149 if(loghist){ 150 memcpy(tmp, loghist, cfg.loghistorysize); 151 loghistptr = tmp + (loghistptr - loghist); 152 } else loghistptr = tmp; 153 loghistptr = tmp; 154 loghist = tmp; 155 cs_sleepms(20); // Monitor or webif may be currently outputting the loghistory but don't use locking so we sleep a bit... 156 cfg.loghistorysize = size; 157 } 158 pthread_mutex_unlock(&loghistory_lock); 159 //if(tmp2 != NULL) add_garbage(tmp2); 160 } 161 } 162 } 163 132 164 static void get_log_header(int32_t m, char *txt) 133 165 { … … 191 223 char *target_ptr = NULL; 192 224 int target_len = strlen(usrtxt) + (strlen(log_buf) - 8) + 1; 193 char *lastpos = loghist + (cfg.loghistorysize) - 1; 194 225 195 226 pthread_mutex_lock(&loghistory_lock); 227 char *lastpos = loghist + (cfg.loghistorysize) - 1; 196 228 if (!loghistptr) 197 229 loghistptr = loghist;
Note:
See TracChangeset
for help on using the changeset viewer.