| 206 | extern int stat_theadlog_peaklevel; |
| 207 | |
| 208 | void poll_logbuffers() // just copy threadlog to mainlog and restart blocked threads, if necessary |
| 209 | { |
| 210 | int threadloglevel = (100 * threadlog.length()) / threadlog.maxsize(); |
| 211 | if(threadloglevel > stat_theadlog_peaklevel) stat_theadlog_peaklevel = threadloglevel; |
| 212 | while(!mainlog.full() && !threadlog.empty()) |
| 213 | { |
| 214 | mainlog.stage(threadlog.remove()); |
| 215 | mainlog.commit(); |
| 216 | } |
| 217 | if(mainlogoverflow && !mainlog.full()) |
| 218 | { |
| 219 | mlog(ACLOG_ERROR, "main log ringbuffer overflow, %d entries lost", mainlogoverflow); |
| 220 | mainlogoverflow = 0; |
| 221 | } |
| 222 | if(!threadlog.full() && threadlogfullsem.getvalue() < 1) threadlogfullsem.post(); |
| 223 | if(!mainlog.empty() && mainlogsem.getvalue() < 1) mainlogsem.post(); |
| 224 | } |