" -b, --book send events to bookkeeping server only\n"
" -l, --log-server <host> specify address of log server\n"
" -s, --socket <path> non-default path of local socket\n"
+ " -L, --lazy [<timeout>] be lazy when closing connections to servers\n"
#ifdef LB_PERF
" -n, --nosend PERFTEST: consume events instead of sending\n"
" -S, --nosync PERFTEST: do not check logd files for lost events\n"
static int verbose = 0;
char *file_prefix = DEFAULT_PREFIX;
int bs_only = 0;
+int lazy_close = 0;
+int default_close_timeout;
#ifdef LB_PERF
int nosend = 0, norecover=0, nosync=0, noparse=0;
char *event_source = NULL;
{"CAdir", required_argument, 0, 'C'},
{"log-server", required_argument, 0, 'l'},
{"socket", required_argument, 0, 's'},
+ {"lazy", optional_argument, 0, 'L'},
#ifdef LB_PERF
{"nosend", no_argument, 0, 'n'},
{"nosync", no_argument, 0, 'S'},
"j:" /* num jobs */
#endif
#endif
+ "L::" /* lazy */
"s:", /* socket */
long_options, (int *) 0)) != EOF)
{
socket_path = strdup(optarg);
break;
+ case 'L':
+ lazy_close = 1;
+ if(optarg)
+ default_close_timeout = atoi(optarg);
+ else
+ default_close_timeout = TIMEOUT;
+ break;
+
#ifdef LB_PERF
case 'n':
nosend = 1;
setlinebuf(stdout);
setlinebuf(stderr);
- i = decode_switches (argc, argv);
-
if ((p = getenv("EDG_WL_INTERLOG_TIMEOUT"))) TIMEOUT = atoi(p);
+ i = decode_switches (argc, argv);
+
/* force -b if we do not have log server */
if(log_server == NULL) {
log_server = strdup(DEFAULT_LOG_SERVER);
il_log(LOG_CRIT, "Failed to initialize output event queues: %s\n", error_get_msg());
exit(EXIT_FAILURE);
}
+ if(lazy_close)
+ il_log(LOG_DEBUG, " using lazy mode when closing connections, timeout %d\n",
+ default_close_timeout);
if (CAcert_dir)
setenv("X509_CERT_DIR", CAcert_dir, 1);
extern char *CAcert_dir;
extern int bs_only;
extern int killflg;
+extern int lazy_close;
+extern int default_close_timeout;
#ifdef LB_PERF
extern int nosend, nosync, norecover, noparse;
#ifdef PERF_EVENTS_INLINE
int flush_result; /* result of flush operation */
pthread_cond_t flush_cond; /* condition variable for flush operation */
#endif
+ /* statistics */
+ int times_empty; /* number of times the queue was emptied */
+ int max_len; /* max queue length */
+ int cur_len; /* current length */
};
struct event_queue *eq = (struct event_queue *)q;
int ret, exit;
int retrycnt;
+ int close_timeout;
if(init_errors(0) < 0) {
il_log(LOG_ERR, "Error initializing thread specific data, exiting!");
&& (eq->flushing != 1)
#endif
) {
- ret = event_queue_wait(eq, 0);
+ if(lazy_close && close_timeout) {
+ ret = event_queue_wait(eq, close_timeout);
+ if(ret == 1) {/* timeout? */
+ event_queue_close(eq);
+ il_log(LOG_DEBUG, " connection to %s:%d closed\n",
+ eq->dest_name, eq->dest_port);
+ }
+ close_timeout = 0;
+ } else
+ ret = event_queue_wait(eq, 0);
if(ret < 0) {
/* error waiting */
il_log(LOG_ERR, "queue_thread: %s\n", error_get_msg());
} /* switch */
/* we are done for now anyway, so close the queue */
+ if((ret == 1) && lazy_close)
+ close_timeout = default_close_timeout;
+ else {
event_queue_close(eq);
+ il_log(LOG_DEBUG, " connection to %s:%d closed\n",
+ eq->dest_name, eq->dest_port);
+ }
}
#if defined(INTERLOGD_HANDLE_CMD) && defined(INTERLOGD_FLUSH)