[haXe/Neko] - ThreadServer and several sqlite connections question

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[haXe/Neko] - ThreadServer and several sqlite connections question

Viktor Hesselbom
Hello

I have a ThreadServer using sqlite to act like a sql-server. Now, can each client have their own connection to different database (.db) files or will that mess things up? I think each client has it's own thread so it shouldn't be a problem but I'd like it confirmed so I don't waste time.

Thanks for your help,
Viktor Hesselbom

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: [haXe/Neko] - ThreadServer and several sqlite connections question

Ian Martins
Viktor Hesselbom wrote:
>
> I have a ThreadServer using sqlite to act like a sql-server. Now, can
> each client have their own connection to different database (.db)
> files or will that mess things up? I think each client has it's own
> thread so it shouldn't be a problem but I'd like it confirmed so I
> don't waste time.
thread server has multiple threads for listening on sockets, but uses a
single worker thread to handle all message processing.  it should be
fine for all clients to share db connections since only one thread will
be using it (the worker).  I don't see a problem with each client having
its own db connections either.



--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: [haXe/Neko] - ThreadServer and several sqlite connections question

Nicolas Cannasse
In reply to this post by Viktor Hesselbom
Viktor Hesselbom a écrit :
> Hello
>
> I have a ThreadServer using sqlite to act like a sql-server. Now, can
> each client have their own connection to different database (.db) files
> or will that mess things up? I think each client has it's own thread so
> it shouldn't be a problem but I'd like it confirmed so I don't waste time.

You might want to check is the SQLite library is thread-safe or not.
This will not cause any problem for Neko itself.

Nicolas

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: [haXe/Neko] - ThreadServer and several sqlite connections question

Viktor Hesselbom
Ok, I'll check that. The problem I was thinking of was if all would write to the same .db file even though I specify different connection for each client. It could get messed up.

On SQLite's website they say a function used to check if it's thread-safe or not. I'm just using the SQLite class in Neko, how can I check if it's thread safe or not through that?

Viktor

2008/10/23 Nicolas Cannasse <[hidden email]>
Viktor Hesselbom a écrit :

Hello

I have a ThreadServer using sqlite to act like a sql-server. Now, can each client have their own connection to different database (.db) files or will that mess things up? I think each client has it's own thread so it shouldn't be a problem but I'd like it confirmed so I don't waste time.

You might want to check is the SQLite library is thread-safe or not. This will not cause any problem for Neko itself.

Nicolas


--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: [haXe/Neko] - ThreadServer and several sqlite connections question

Nicolas Cannasse
Viktor Hesselbom a écrit :
> Ok, I'll check that. The problem I was thinking of was if all would
> write to the same .db file even though I specify different connection
> for each client. It could get messed up.

I think that you'll have file-locking issues anyway, at least when
updating your database.

> On SQLite's website they say a function used to check if it's
> thread-safe or not. I'm just using the SQLite class in Neko, how can I
> check if it's thread safe or not through that?

You can't, since it would require to export this function in the Neko
API. You can try to modify the sqlite.ndll sources (in
neko/libs/sqlite/sqlite.c).

Nicolas
-

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: [haXe/Neko] - ThreadServer and several sqlite connections question

Viktor Hesselbom
Hmm, do you think I should connect to a database each time before a query is sent (querys from users gets sent over sockets) instead of trying to have several open connections to different databases on different thread instead?

I just don't want the querys to get messed up and start writing to other connections than where they're supposed to go.

Thanks,
Viktor

2008/10/24 Nicolas Cannasse <[hidden email]>
Viktor Hesselbom a écrit :

Ok, I'll check that. The problem I was thinking of was if all would write to the same .db file even though I specify different connection for each client. It could get messed up.

I think that you'll have file-locking issues anyway, at least when updating your database.


On SQLite's website they say a function used to check if it's thread-safe or not. I'm just using the SQLite class in Neko, how can I check if it's thread safe or not through that?

You can't, since it would require to export this function in the Neko API. You can try to modify the sqlite.ndll sources (in neko/libs/sqlite/sqlite.c).


Nicolas
-

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org