Hi Alex
Just change:
for (i = num_logfiles; i >= 0; i--) {
to:
for (i = num_logfiles - 1; i >= 0; i--) {
for obvious reasons.
Thanks
Werner
-----Original Message-----
From: Alexander Malysh [mailto:[EMAIL PROTECTED]
Sent: 19 November 2008 15:45
To: [email protected]
Subject: Re: gwlib log issue
Hi,
hmm, seems you are right...
attached patch should fix it.
Werner Coetzee schrieb:
> Hi Alex
>
> I've also got the current CVS version.
> I don't know if it might be related to our gcc version, but I've tried with 2
> different versions,
> and both fail at shutdown.
>
> See attached test outputs.
>
> Regards
> Werner
>
>
>
> -----Original Message-----
> From: Alexander Malysh [mailto:[EMAIL PROTECTED]
> Sent: 19 November 2008 13:02
> To: [email protected]
> Subject: Re: gwlib log issue
>
> Hi Werner,
>
> your patch is wrong because you will inherit log level from the first
> log entry.
> And I'm unable to reproduce your crash with current cvs version:
> 2008-11-19 11:58:39 [6476] [0] INFO: Added logfile `/tmp/log1.log' with
> level `0'.
> 2008-11-19 11:58:39 [6476] [5] DEBUG: Thread 5
> (gw/bb_boxc.c:smsboxc_run) maps to pid 6476.
> 2008-11-19 11:58:39 [6476] [0] DEBUG: Started thread 6
> (gw/smsc/smsc_fake.c:fake_listener)
> 2008-11-19 11:58:39 [6476] [0] INFO: DLR rerouting for smsc id <FAKE>
> disabled.
> 2008-11-19 11:58:39 [6476] [0] INFO: Added logfile `/tmp/log1.log' with
> level `0'.
>
> And no problem at shutdown...
>
> Thanks,
> Alex
>
> Werner Coetzee schrieb:
>> Hi
>>
>> Have anybody had a look at this yet?
>>
>> Regards
>> Werner
>>
>>
>> -----Original Message-----
>> From: Werner Coetzee [mailto:[EMAIL PROTECTED]
>> Sent: 17 November 2008 11:27
>> To: [email protected]
>> Subject: gwlib log issue
>>
>> Hi List
>>
>> I've come across an issue in the shutdown phase of gwlist_shutdown().
>> It happens in the log_close_all() function as part of the log_shutdown().
>>
>> If you have the same log file opened twice (or more), e.g. 2 smsc binds
>> sharing the same log file, fclose() will fail on the second attempt, and
>> abort.
>> The reason is that the log file is added twice to the logfiles array, with
>> the same file descriptor.
>>
>> Below is the output from a test program, opening test1.log, test2.log and
>> then test1.log again.
>> When shutting down, it fails on the second close of test1.log (I've added
>> some extra printf in log_close_all to print the log file being close):
>>
>> 2008-11-17 11:03:45 [27637] [0] INFO: Added logfile `test1.log' with level
>> `0'.
>> 2008-11-17 11:03:45 [27637] [0] INFO: Added logfile `test2.log' with level
>> `0'.
>> 2008-11-17 11:03:45 [27637] [0] INFO: Added logfile `test1.log' with level
>> `0'.
>> 2008-11-17 11:03:45 [27637] [0] DEBUG: calling gwlib_shutdown
>> 2008-11-17 11:03:45 [27637] [0] DEBUG: Closing all log files
>> Closing log file test1.log
>> Closing log file test2.log
>> Closing log file test1.log
>> *** glibc detected *** double free or corruption (!prev): 0x09ed4108 ***
>> Aborted
>>
>>
>> I have attached a patch to fix this issue.
>> Instead of adding the already opened log to the logfiles array again, it
>> will update the log level and exclusivity of the already opened log file,
>> and return its log index.
>>
>> This produces a successful test with output found below:
>>
>> 2008-11-17 11:05:22 [27862] [0] INFO: Added logfile `test1.log' with level
>> `0'.
>> 2008-11-17 11:05:22 [27862] [0] INFO: Added logfile `test2.log' with level
>> `0'.
>> 2008-11-17 11:05:22 [27862] [0] INFO: Re-using logfile `test1.log' with
>> level `0'.
>> 2008-11-17 11:05:22 [27862] [0] DEBUG: calling gwlib_shutdown
>> 2008-11-17 11:05:22 [27862] [0] DEBUG: Closing all log files
>> Closing log file test2.log
>> Closing log file test1.log
>>
>>
>> Please review the patch and comment.
>>
>> Thanks
>> Werner
>>
>>
>>
>>
>