MCPcopy Create free account
hub / github.com/acl-dev/acl / reopen_log

Function reopen_log

lib_acl/src/stdlib/acl_mylog.c:282–340  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

280}
281
282static int reopen_log(ACL_LOG *log)
283{
284 time_t now = time(NULL);
285
286#undef RETURN
287#define RETURN(x) do { \
288 if (log->lock) { \
289 thread_mutex_unlock(log->lock); \
290 } \
291 return (x); \
292} while (0)
293
294 if (log->lock) {
295 thread_mutex_lock(log->lock);
296 }
297
298 if (!(log->flag & ACL_LOG_F_DEAD)
299 || (log->flag & ACL_LOG_F_FIXED)
300 || !IS_NET_STREAM(log)
301 || log->fp == NULL
302 || log->reopen_inter <= 0) {
303
304 RETURN(-1);
305 }
306
307 if (log->count == 0) {
308 if (now - log->last_open < 5 * log->reopen_inter) {
309 RETURN(-1);
310 }
311 } else if (now - log->last_open < log->reopen_inter) {
312 RETURN(-1);
313 }
314
315 if (log->fp->path) {
316 free(log->fp->path);
317 log->fp->path = NULL;
318 }
319#if 0
320 if (log->fp->addr_local) {
321 free(log->fp->addr_local);
322 log->fp->addr_local = NULL;
323 }
324 if (log->fp->addr_peer) {
325 free(log->fp->addr_peer);
326 log->fp->addr_peer = NULL;
327 }
328#endif
329
330 private_vstream_close(log->fp);
331 acl_assert(log->path);
332 log->fp = private_vstream_connect(log->path, 60, 60);
333 log->last_open = time(NULL);
334 if (log->fp == NULL) {
335 RETURN(-1);
336 }
337 log->flag &= ~ACL_LOG_F_DEAD;
338 log->last_open = time(NULL);
339 RETURN(0);

Callers 1

acl_write_to_log2Function · 0.85

Calls 4

thread_mutex_lockFunction · 0.85
freeFunction · 0.85
private_vstream_closeFunction · 0.85
private_vstream_connectFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…