[Klone-users] Re: Global variable

Stefano Barbato barbato at koanlogic.com
Wed Mar 19 12:33:00 EDT 2008


Hi,

sessions cannot save structures, you have serialize your structure in  
string based variables.

There are other methods to share data between processes like IPC,  
shared memory, databases, etc. but usually those are overkill for  
simple web applications.

bye,
s



On 19/mar/08, at 02:49, Trung, Tran Minh wrote:

> Hi Stefano,
> Thanks for your reply. Now I see why I meet that problem. I think  
> using
> session is a good solution, but session can not save variables like
> structure or object!? How can I do that!?
>
> Thanks
>
> Tran Minh Trung
>
> -----Original Message-----
> From: klone-users-bounces at koanlogic.com
> [mailto:klone-users-bounces at koanlogic.com] On Behalf Of
> klone-users-request at koanlogic.com
> Sent: Tuesday, March 18, 2008 11:00 PM
> To: klone-users at koanlogic.com
> Subject: [?? Probable Spam] Klone-users Digest, Vol 20, Issue 11
>
> Send Klone-users mailing list submissions to
> 	klone-users at koanlogic.com
>
> To subscribe or unsubscribe via the World Wide Web, visit
> 	http://koanlogic.com/cgi-bin/mailman/listinfo/klone-users
> or, via email, send a message with subject or body 'help' to
> 	klone-users-request at koanlogic.com
>
> You can reach the person managing the list at
> 	klone-users-owner at koanlogic.com
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Klone-users digest..."
>
>
> Today's Topics:
>
>   1. Global variable (Trung, Tran Minh)
>   2. Re: Global variable (Stefano Barbato)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 18 Mar 2008 14:49:15 +0700
> From: "Trung, Tran Minh" <trungtm at hpt.vn>
> Subject: [Klone-users] Global variable
> To: <klone-users at koanlogic.com>
> Message-ID:
> 	
> <A0287EF1AF0DA94F81CB8938E06EEC6C3510BC at hpt-exbe-srv.hptvietnam.corp>
> Content-Type: text/plain; charset="us-ascii"
>
> Hi,
>
> I have problem again with KLone !?
>
> I hava a klapp to demo using global variable. My klapp has some file:
>
> + data.h:  declare a STRUCT global variable with name "data_struct"
>
> + data.c: has some functions: read_data, update_data from a file
>
> +interface: has some .kl1 pages
>
>            page1.kl1: when page loads, read data from file to data
> struct and display some fields of it. And after modifying some fields,
> click update button to update to data struct (on memory) and update to
> db file.
>
>            page2.kl1: have functions like page1.kl1 but display some
> other fields of data struct.
>
>            ...
>
> I check all functions running well. But after updating (it is OK),  
> when
> I go to another page and return the previous page, the data will  
> display
> incorrectly (I check the db file, it is OK and read function is OK).  
> And
> I go to another page and return it again, it is OK. Sometimes it is  
> OK,
> sometimes it is wrong (it displays data I can not know where it is).
> Ohh..., what is my problem!? I think because I use global variables !?
>
>
>
> Thanks,
>
>
>
> Tran Minh Trung
>
>
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> http://koanlogic.com/pipermail/klone-users/attachments/20080318/8a8c31a8
> /attachment.html
>
> ------------------------------
>
> Message: 2
> Date: Tue, 18 Mar 2008 10:23:52 +0100
> From: Stefano Barbato <barbato at koanlogic.com>
> Subject: Re: [Klone-users] Global variable
> To: Klone users <klone-users at koanlogic.com>
> Message-ID: <323E3F6B-336E-40D4-8CE7-1C9F0AC48D5D at koanlogic.com>
> Content-Type: text/plain; charset=WINDOWS-1252; format=flowed;
> 	delsp=yes
>
>
> On 18/mar/08, at 08:49, Trung, Tran Minh wrote:
>
>> Hi,
>> I have problem again with KLone !?
>> I hava a klapp to demo using global variable. My klapp has some file:
>> + data.h:  declare a STRUCT global variable with name "data_struct"
>> + data.c: has some functions: read_data, update_data from a file
>> +interface: has some .kl1 pages
>>            page1.kl1: when page loads, read data from file to data
>> struct and display some fields of it. And after modifying some
>> fields, click update button to update to data struct (on memory) and
>> update to db file.
>>            page2.kl1: have functions like page1.kl1 but display
>> some other fields of data struct.
>>            ...
>> I check all functions running well. But after updating (it is OK),
>> when I go to another page and return the previous page, the data
>> will display incorrectly (I check the db file, it is OK and read
>> function is OK). And I go to another page and return it again, it is
>> OK. Sometimes it is OK, sometimes it is wrong (it displays data I
>> can not know where it is). Ohh..., what is my problem!? I think
>> because I use global variables !?
>>
>> Thanks,
>>
>> Tran Minh Trung
>
>
>
> Hi Trung,
>
> for performance and concurrency KLone (just like most unix daemons)
> forks 3 or more processes that handle incoming client requests; every
> request gets served by a random "kloned" process.
>
> Global variables live in processes private address space so every
> "kloned" have its own indipendent global variables i.e. those
> variables are not shared between KLone processes.
>
> You can use session objects (
> http://www.koanlogic.com/klone/api/html/group__session.html
>  ) to keep data between multiple requests, any form of IPC (Inter
> Process Communication) to share data between server processes or a
> shared database like SQLite (http://www.sqlite.org).
>
> bye,
> s
>
>
>
>
>
> ------------------------------
>
> _______________________________________________
> Klone-users mailing list
> Klone-users at koanlogic.com
> http://koanlogic.com/cgi-bin/mailman/listinfo/klone-users
>
>
> End of Klone-users Digest, Vol 20, Issue 11
> *******************************************
>
>
>
> _______________________________________________
> Klone-users mailing list
> Klone-users at koanlogic.com
> http://koanlogic.com/cgi-bin/mailman/listinfo/klone-users
>





More information about the klone-users mailing list