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()"