From: Frederic Marchal Date: Fri, 2 Oct 2015 17:07:55 +0000 (+0200) Subject: Initialize usertab as late as possible X-Git-Url: http://git.ipfire.org/?p=thirdparty%2Fsarg.git;a=commitdiff_plain;h=da56e0c24c19ad4847df2dff3f7a0f8758d37585 Initialize usertab as late as possible The usertab option may use LDAP but the connection to the server was open before parsing the access and useragent logs. It was possible that the connection would time out before the first request was sent. An attempt to fix this problem is to open the connection to the LDAP server after parsing the log files. --- diff --git a/datafile.c b/datafile.c index 54608c6..3582206 100644 --- a/datafile.c +++ b/datafile.c @@ -63,6 +63,8 @@ void data_file(char *tmp) struct userinfostruct *uinfo; longline line; + init_usertab(UserTabFile); + ipantes[0]='\0'; nameantes[0]='\0'; diff --git a/log.c b/log.c index bd860e2..9d4f114 100644 --- a/log.c +++ b/log.c @@ -666,8 +666,6 @@ int main(int argc,char *argv[]) } #endif - init_usertab(UserTabFile); - read_start_time=time(NULL); LogStatus=ReadLogFile(&ReadFilter); read_end_time=time(NULL); diff --git a/report.c b/report.c index 2d81566..a1ea40d 100644 --- a/report.c +++ b/report.c @@ -112,11 +112,11 @@ void gerarel(void) debugaz(__FILE__,__LINE__,_("outdirname=%s\n"),outdirname); } - if (email[0] == '\0') { - if (!FileList_IsEmpty(UserAgentLog)) - UserAgent_Readlog(); - UserAgent(); - } + if (email[0] == '\0' && !FileList_IsEmpty(UserAgentLog)) + UserAgent_Readlog(); + + init_usertab(UserTabFile); + UserAgent(); snprintf(wdirname,sizeof(wdirname),"%s/sarg-general",outdirname); if((fp_gen=MY_FOPEN(wdirname,"w"))==NULL){