Search the web
Sign In
New User? Sign Up
ace-users
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want to share photos of your group with the world? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Fwd: [ace-users] Problem in using ACE_Reactor::instance()->handle_   Message List  
Reply | Forward Message #30992 of 42992 |
Hi,

Could anyone help me in solving this problem please...

Thanks
Chepurthy S.


--- In ace-users@y..., chepurthy soma <chepurthys@y...> wrote:

ACE VERSION: 5.2

HOST MACHINE and OPERATING SYSTEM:
Sun Netra, Solaris.

TARGET MACHINE and OPERATING SYSTEM, if different from HOST:
COMPILER NAME AND VERSION (AND PATCHLEVEL):

CONTENTS OF $ACE_ROOT/ace/config.h:

/* -*- C++ -*- */
// config-sunos5.8.h,v 4.3 2001/07/24 21:58:43 joeh Exp

// The following configuration file is designed to work for SunOS 5.8
// (Solaris 8) platforms using the SunC++ 4.x, 5.x, 6.x, or g++
compilers.

#ifndef ACE_CONFIG_H

// ACE_CONFIG_H is defined by one of the following #included headers.

// #include the SunOS 5.7 config, then add any SunOS 5.8 updates
below.
#include "ace/config-sunos5.7.h"

// The range of thread priorities for 5.8 differs from 5.7 in the
// minimum priority for the SCHED_OTHER policy (i.e.,
// ACE_THR_PRI_OTHER_MIN)
# define ACE_THR_PRI_OTHER_MIN (long) -20

# if defined (_POSIX_PTHREAD_SEMANTICS)
# ifdef ACE_LACKS_RWLOCK_T
# undef ACE_LACKS_RWLOCK_T
# endif /* ACE_LACKS_RWLOCK_T */
# endif /* _POSIX_PTHREAD_SEMANTICS */

#endif /* ACE_CONFIG_H */


CONTENTS OF $ACE_ROOT/include/makeinclude/platform_macros.GNU
(unless
this isn't used in this case, e.g., with Microsoft Visual C++):

# platform_sunos5_g++.GNU,v 4.46 2001/07/24 15:09:30 oci Exp

# SunOS 5.x (Solaris 2.x) with g++ *not* using Orbix

# NOTE: with g++ 2.8.0, you'll need to disable optimization in order
to
# instantiate ACE_Map_Manager (ace/Map_Manager.cpp). The
easiest
# way to do that is to set "optimize = 0", either below or on
# your make command line.

# NOTE: On Solaris86, you'll need to use GNU as instead
of /usr/ccs/bin/as,
# if you want -gstabs+ and -pipe support.
#repo=1

ACE_HAS_GNUG_PRE_2_8 := \
$(shell \
if $(CXX) --version | egrep '^(cygnus-)?2\.[0-7]' > /dev/null;
then \
echo 1; else echo 0; fi)

ifeq (,$(debug))
debug = 1
endif
ifeq (,$(optimize))
optimize = 1
endif
ifeq (,$(threads))
threads = 1
endif

ifeq ($(threads),0)
CFLAGS += -DACE_MT_SAFE=0
endif # threads

ifeq (,$(exceptions))
exceptions = 0
endif
# if we are not working with old gcc ...
ifeq ($(ACE_HAS_GNUG_PRE_2_8),0)
ifeq ($(exceptions),0)
CFLAGS += -fno-exceptions
endif # exceptions
endif # ! ACE_HAS_GNUG_PRE_2_8

ifeq ($(shell /bin/uname -m),i86pc)
#### gcc on Solaris86 doesn't use -g
DCFLAGS += -gstabs+
else # ! i86pc
DCFLAGS += -g
endif # ! i86pc

CC = gcc
CXX = g++
CFLAGS += -W -Wall -Wpointer-arith -pipe #### -Winline
#CCFLAGS += $(CFLAGS) -fno-implicit-templates
CCFLAGS += $(CFLAGS) #### without no-implicit-templates
DLD = $(CXX)
LD = $(CXX)
LDFLAGS +=
LIBS += -lsocket -ldl -lgen -lnsl -lposix4 -lthread
OCFLAGS += -O3
PIC = -fPIC
AR = ar
ARFLAGS = ruv
RANLIB = @true
SOFLAGS = -G $(CPPFLAGS)
SOBUILD = $(COMPILE.cc) $(PIC) -o $(VSHDIR)$*.so $<
PRELIB = @true

PLATFORM_X11_CPPFLAGS= -I/usr/openwin/include -I/usr/dt/include
PLATFORM_X11_LIBS =-lX11
PLATFORM_X11_LDFLAGS=

## Unfortunately, gcc 3.0 fails to many cpp files with
## optimization enabled. Even -O causes the compiler
## to core dump on some files.
ifeq ($(shell $(CXX) --version),3.0)
override optimize = 0
endif




AREA/CLASS/EXAMPLE AFFECTED:

USing ACE_Reactor::instance->handle_events();
DOES THE PROBLEM AFFECT:
COMPILATION?
LINKING?
On Unix systems, did you run make realclean first?
EXECUTION?

Yes, Execution failed.
OTHER (please specify)?


[Please indicate whether ACE, your application, or both are affected.]

My Application is affected.

SYNOPSIS:
[Brief description of the problem]

Error in using ACE_Reactor::instance()->handle_events() for both
signal handling and as a connector.

DESCRIPTION:

The logic I used is as follows:

class MyEventHandler : public ACE_Event_Handler

{

public:

int handle_signal(int signum, siginfo_t*,ucontext_t*)

{

switch(signum)

{

case SIGINT:

//!< Do cleanup….

exit(0);

case SIGUSR1:

//!< Do something….

……

default:

break;

}

return 0;

}

};

void signalHandler()

{

ACE_Reactor::instance()->handle_events();

}

int main()

{

MyEventHandler *eh = new MyEventHandler; // Instantiate the handler

//!< Register the signal handler

ACE_Reactor::instance()->register_handler(SIGINT,eh);

ACE_Reactor::instance()->register_handler(SIGTERM,eh);

ACE_Reactor::instance()->register_handler(SIGUSR1,eh);

//!< Spawn a thread for signal handler.

ACE_Thread_Manager::instance()->spawn_n(1,

(ACE_THR_FUNC)signalHandler,

0,THR_NEW_LWP,

ACE_DEFAULT_THREAD_PRIORITY, 0);

Call EMSClient(); // This is a method called from a different
library, which is explained below.

// Wait for all the tasks to exit.

ACE_Thread_Manager::instance()->wait();

return 0;

}


/*

This is a client library which acts like a connector and does the
following:

Initialization of data

Registers to EMS Server.

Waits for events continuously from EMS Server.

EMSClient()

{

//!< Initialization stuff

………

//!< Register a handler.

ACE_INET_Addr local_addr(_emsinfocurrent.emsc_port);

if(emsc_addr.set(local_addr) != 0)

{

cout << "error occored"<<endl;

return -1;

}

cout <<"Registering endpoint " << endl;

ACE_NEW_RETURN (emscon_endpoint_, EMSconnector (emsc_addr),-1);

if (ACE_Reactor::instance ()->register_handler (emscon_endpoint_,

ACE_Event_Handler::READ_MASK) == -1)

{

cout << "Registering Handle failed "<<endl;

ACE_ERROR_RETURN ((LM_ERROR, "ACE_Reactor::register_handler"), -1);

}

else

cout <<" Handler Registered Successfully to "<<
_emsinfocurrent.emsc_port<<endl;;

//!< Spawns a thread to call handle_events method of ACE_Reactor.

ACE_Thread_Manager::instance()->spawn_n(1,

(ACE_THR_FUNC)eventHandler,

(void *)structsbuff,

THR_NEW_LWP,

ACE_DEFAULT_THREAD_PRIORITY,0);


//!< Do something else….

}

EventHandler() // This method waits in a loop for handling events.

{

while(1)

{

if ((errors=ACE_Reactor::instance ()->handle_events ()) <= 0)

{

cout <<" recv_handler:: ERROR "<<errors<<endl;

return errors;

}

}

cout <<" recv_handler:: EVENT received"<<endl;

return 0;

}




When I run the above logic, Signal handler registration in main
program is successful, but handle_events is failing with return code –
1. I am not able to understand the reason for this. If I move the
registration of signal handler code in main program below EMSClient()
method, then registration is successful and handle events is
receiving data correctly. But Since I do a lot of things in my main
before calling EMSClient(), I need to register signal handler and
start it before going to EMSClient… Moreover I cannot use the
handle_signal method in EMSClient, because there is a lot of cleanup
in main code which cannot be done in EMSClient. Please suggest me a
way to solve this problem.
REPEAT BY:
[What you did to get the error; include test program or session
transcript if at all possible. ]

SAMPLE FIX/WORKAROUND:
[If available ]





Thanks

Chepurthy S.


---------------------------------
   Yahoo! Autos - everything you wanted to know about cars and bikes
--- End forwarded message ---





Thu May 16, 2002 3:07 pm

chepurthys@...
Send Email Send Email

Forward
Message #30992 of 42992 |
Expand Messages Author Sort by Date

Hi, Could anyone help me in solving this problem please... Thanks Chepurthy S. ... ACE VERSION: 5.2 HOST MACHINE and OPERATING SYSTEM: Sun Netra, Solaris. ...
chepurthys
chepurthys@...
Send Email
May 16, 2002
3:11 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help