On Tue, 04 Oct 2011 23:21:13 +0100, Andrew Beverley wrote:
On Tue, 2011-10-04 at 18:59 +0100, Andrew Beverley wrote:
However, I'm now having problems with multiple instances of the session helper writing to the same database. I thought I had fixed this with the
->sync option, but it appears not. If I open multiple instances of
ext_session_acl in terminal windows on the same database, then I do not get consistent results between each process. If I do a "LOGIN" on one, then I can still get "No session available" on the other. Any ideas why
this might be? Is it a bug with db-185? Debugging shows that the key
does not exist in the second process, despite having been written in the
first.

After further investigation, the problem appears to be that the *read*
database process is being cached (I'm not sure where). So even if the
writing process syncs its changes to the DB file, these aren't reflected
in the process that is reading the DB file.

After a lot of Googling, the only way I can see to fix this is to close
and re-open the database on every read. This is very messy, but does
anyone have any better suggestions?

I also found another bug with the session helper when used in active
mode (which might have been created by me). I'll submit a patch once
I've got a way ahead with the DB.

The problem here was that the "LOGIN" was being written to the database,
as well as the desired key (even though the correct string length was
specified). So it was never actually matching a subsequent query.

Please find attached a patch that fixes both of these. The fix for the
first is messy; the fix for the second is simple, just using strtok
instead of strrchr, so as to force the key to be correctly truncated.

Andy

The reason it was doing strrchr() was that people are free to specify multi-word keys. We need to scan from the end of the line backwards for the token. I think strrchr() is still probably the best to use. The buffer is local so if you can map the strrchr output to an offset it can be freely adjusted to add \0 in the space before "LOGIN".

Amos

Reply via email to