Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.os.linux.development.apps > #428
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!nuzba.szn.dk!pnx.dk!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | Rainer Weikusat <rweikusat@mssgmbh.com> |
| Newsgroups | comp.os.linux.development.apps |
| Subject | Re: object file memory |
| Date | Thu, 09 Feb 2012 19:00:38 +0000 |
| Lines | 50 |
| Message-ID | <87zkcral2h.fsf@sapphire.mobileactivedefense.com> (permalink) |
| References | <jgpkvf$c83$1@dont-email.me> <20120207000059.76@kylheku.com> <jgrc5t$5f0$1@dont-email.me> <jgrmj8$6pc$1@dont-email.me> <alpine.DEB.2.00.1202072202080.25401@login01.caesar.elte.hu> <jgs7dk$ng5$1@dont-email.me> <jgvbqo$uin$1@dont-email.me> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| X-Trace | individual.net zh1/oabKpI6SLFaEMzM5tA/fbsDS1UOBGRx8PZTNd0+fAk/vw= |
| Cancel-Lock | sha1:/JEI1N/yD7JY1Od9H7f7RYY6Ybc= sha1:4gzmhT9FzIFq6/ZEtJVSdoxa11s= |
| User-Agent | Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) |
| Xref | x330-a1.tempe.blueboxinc.net comp.os.linux.development.apps:428 |
Show key headers only | View raw
Bill M <wpmccormick@just_about_everywhere.com> writes:
[...]
> So I've re-written my client application to something I think is more
> manageable, but I'm still having some trouble. It seems that global
> variables declared with __thread are not keeping their values. I have
> something that looks like this:
>
> *** client.c ***
> static __thread COMM_STATE comm_state;
> static __thread int sockfd;
> static __thread struct sockaddr_in their_addr;
>
> static int connect(SERVER server)
> {
> if(comm_state == CONNECTED) return ALREADY_CONNECTED;
> ...
> sockfd = socket( ... );
> ...
> connect(sockfd, ...
>
> }
>
> int client_write(SERVER server, char* buffer)
> {
> for(;;) {
> if((connect(server)) != ALREADY_CONNECTED)
> continue;
>
> if((comm_send(buffer)) != SUCCESS)
> continue;
>
> //now get a reply here
> ...
> }
> }
>
> *** client_app.c ***
> extern int client_write(SERVER server, char* buffer) ;
>
> So I think you get the idea, and my question is this:
>
> Should globals in client.c be persistent from one client_write call to
> the next for each thread in client_app.c that calls client_write?
Yes. Otherwise, there would be little point in having thread-local
variables. I've used them myself quite a couple of times without
problems.
Back to comp.os.linux.development.apps | Previous | Next — Previous in thread | Next in thread | Find similar
object file memory Bill M <wpmccormick@just_about_everywhere.com> - 2012-02-06 16:41 -0600
Re: object file memory Kaz Kylheku <kaz@kylheku.com> - 2012-02-06 23:07 +0000
Re: object file memory Bill M <wpmccormick@just_about_everywhere.com> - 2012-02-07 08:23 -0600
Re: object file memory Bill M <wpmccormick@just_about_everywhere.com> - 2012-02-07 08:40 -0600
Re: object file memory Bill M <wpmccormick@just_about_everywhere.com> - 2012-02-07 08:58 -0600
Re: object file memory Bill M <wpmccormick@just_about_everywhere.com> - 2012-02-07 11:21 -0600
Re: object file memory "Ersek, Laszlo" <lacos@caesar.elte.hu> - 2012-02-07 22:09 +0100
Re: object file memory Bill M <wpmccormick@just_about_everywhere.com> - 2012-02-07 16:08 -0600
Re: object file memory Bill M <wpmccormick@just_about_everywhere.com> - 2012-02-08 20:42 -0600
Re: object file memory Rainer Weikusat <rweikusat@mssgmbh.com> - 2012-02-09 19:00 +0000
Re: object file memory Joe Beanfish <joe@nospam.duh> - 2012-02-09 11:15 -0500
csiph-web