Re: volatile or what? ...

From: Fletcher Glenn (fandmgiiNOSPAM_at_pacbell.net)
Date: 12/21/03

  • Next message: Barry Margolin: "Re: Help with select()"
    Date: Sun, 21 Dec 2003 01:50:15 GMT
    
    

    "Darko M." <mdanko@tesla.rcub.bg.ac.yu> wrote in message
    news:ef663480.0312201634.163913ad@posting.google.com...
    > I have Linux Mandrake 9.0, and work in GNU C++ Compiler.
    >
    > I have a network server divided into two parts: one that handles the
    > existing connections and serves them ("SERVER1"), and the second one
    > that waits for new connections ("SERVER2"). When the Server2 reads
    > call from a new client, it establishes a new socket-connection for it,
    > sends a SIGUSR1 signal (!) to Server1, and then delivers this new
    > connection to it (to Server1). Server1 is the main() function, and the
    > Server2 is a p_thread created from within the main(), at the very
    > beginning. They communicate partly over a few global variables, that
    > are objects of myself-defined classes.
    >
    > What seems to be the problem? Well, after I deliver the SIGUSR1 for
    > the first time, the signal handler modifies the global variables,
    > among other things. And look what happens: between the exit from a
    > signal handler, and return to the main() loop, I get a global variable
    > destructor executed, so every new made connection is disabled, since
    > my global variable is lost.
    >
    > volatile doesn't work, I tried.
    >
    > Please help or at least tell me any addresses to references about this
    > concrete theme, that is C++, signals, global variables etc.
    >
    > Thanks in advance

    Sounds like you have a variable scope problem. However you have that
    variable defined, the compiler thinks that the variable is falling out of
    scope, so the destructor is called. You should look carefully at where your
    "global" variable is defined, and be sure that you are not dealing with a
    variable in scope local to the signal handler only.

    --
    Fletcher Glenn
    

  • Next message: Barry Margolin: "Re: Help with select()"

    Relevant Pages

    • Re: Many global vars in an A97 app - good or bad? Why?
      ... especially the past about appropriate scope. ... >Passing data between forms: why do so few people know about the ... >>Global variables are decidely poorly suited to these two purposes, ... This could be a global class module variable, ...
      (comp.databases.ms-access)
    • Re: How to eliminate this global variable, silent?
      ... Excluding it because it doesn't have global scope is perfectly correct. ... The only argument you can present is: the standard doesn't ... define "global variables". ... yadda yadda. ...
      (comp.lang.c)
    • Re: Trouble with variable scoping
      ... You are confusing file scope with global. ... That is possibly the most common misperception about Perl that I've ... fully-qualify any global variables you decide to use. ... a lexical variable $foo exists in the current scope. ...
      (perl.beginners)
    • Re: VB 6.0 Desktop - Global Variables
      ... MikeD schrieb: ... As has been stated, global variables tend to make maintainability much more difficult and, IMO, make bugs much more likely. ... As you say, having project wide scope, but also without needing a reference to an object. ...
      (microsoft.public.vb.general.discussion)
    • Re: Incrementing Table Error?
      ... The dynamic SQL has it's own scope, and variables do not exist outside the ... T-SQL by using two @ signs, as there are no global variables in T-SQL. ...
      (microsoft.public.sqlserver.programming)