Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Client/Server + globals

Status
Not open for further replies.

yodaa

Programmer
Jun 10, 2004
64
SE
Hi there,

I have question about Tcl-servers. I have a rather simple server that does som file transfers, built on the hand-shake method. My question is this.
Is there some abovious danger of storing information into global variables. And with information I don't mean port and data such paths etc. that is common for all loged on clients.

I.e. I wish to store the process id for a shell command (time demanding) that might be aborted by the client with a new server request. The thing is that the server might have multiple users logged on wishing to do the same things. Will the globals mess upp the entire server?

Most thankfull for any replies and suggestions.

/yodaa
 
That's a hard question to answer, but in general, yes.
If you are saving data in a scalar variable,-for instance
the pid of the exec'd command-and other users are able to
run this command and reset the pid, than this approach is not feasible.
I would approach it one of two ways:

1.Create an array entry for each client and store all
information in an indiced list for the array data, including
any data derived from processes unique to that client.

2.Allow only one user access to the data obtained by
the shell process at a time and send an alert message
to each client when they are able to execute their command.
This is more of queue based approach, and may not be what you want.

HTH
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top