Well, this program has a race condition, because there is no guarantee 
that ipmi_init() in first_thread runs before second_thread().  You 
should alloc the os handler and call ipmi_init() in the main routine and 
first_thread should just call the operation loop.  I'm surprised the 
program doesn't segv occasionally.

You are also not checking the err value in handle_domain, which might be 
reporting a problem.  Also, interating anything there is useless, that 
handler will be called when the connection comes up (or fails to come 
up).  You probably also want to register a domain_fully_up handler and 
iterate the entities at that point.

Putting prints throughout the program to trace it could be handy for 
debugging.

-corey

[EMAIL PROTECTED] wrote:
> Hi all,
>                                                                               
>                                                
>  In my program i spawned two threads, first thread  dedicated for running the
>  operation_loop ( os_hnd->operation_loop(os_hnd) ), like as follows,  
> ------------------------------
>  static os_handler_t *os_hnd;  // global variable
>                                                                               
>                                                
> void *first_thread()
>  {
>    os_hnd = ipmi_posix_setup_os_handler();
>                                                                               
>                                                
>    if(!os_hnd)
>     {
>      printf(\"Error:Unable to allocate to OS handler\\n\");
>      exit(0);
>     }                                                                         
>                                                      
>    ipmi_init(os_hnd);
>                                                                               
>                                                
>    os_hnd->operation_loop(os_hnd);
>  }
>                                                                               
>                                                
>  --------------------------------  second thread for dedicated to making 
> connection to the IPMI server and getting the sensor details
>  like as folows:
>                                                                               
>                                                
>                                                                               
>                                                
>                                                                               
>                                                
> void handle_sensor(ipmi_entity_t *entity, ipmi_sensor_t *sensor, void 
> *cb_data)
> {
>   // taking sensor getails
> }
> void handle_entity(ipmi_entity_t *entity, void *cb_data)
> {
>   ipmi_entity_iterate_sensors(entity, handle_sensor, tmp_obj);                
>                                                                               
>                                 
> }
> void handle_domain(ipmi_domain_t *domain,
>            int           err,
>            unsigned int  conn_num,
>            unsigned int  port_num,
>            int           still_connected,
>            void          *user_data)
>  {
>                                                                               
>                                                
>   ipmi_domain_iterate_entities(domain, handle_entity, tmp_obj);
>  }
>                                                                               
>                                                
> void *second_thread()
>  {
>                                                                               
>                                                
>   rv = ipmi_ip_setup_con(tip, tport, 1, authcode,  priv_code, (void*) 
> this->m_user, user_length,(void *) this->m_pass, pass_length, os_hnd, NULL, 
> &con);
>   if (rv)
>   {
>     printf(\"Error:Unable to setting up LAN connection\\n\");
>   }
>                                                                               
>                                                
>                                                                               
>                                                
>   rv = ipmi_open_domain(\"\", &con, 1, handle_domain, this, NULL, NULL, NULL, 
> 0, NULL);
>   if (rv)
>   {
>     printf(\"Error:Unable to open domain\\n\");
>   }
>                                                                               
>                                                
>  }
> void fun()
> {
>    // spawning  first thread
>     spawn_n(1, ACE_THR_FUNC (first_thread),
>                                  ACE_reinterpret_cast (void *, NULL),
>                                  THR_NEW_LWP | THR_JOINABLE);
>   // spawning second thread
>    spawn_n(1, ACE_THR_FUNC (second_thread),
>                                  ACE_reinterpret_cast (void *, NULL),
>                                  THR_NEW_LWP | THR_JOINABLE);
>                                                                               
>                                                
>   // constructing the reply message
>                                                                               
>                                                
> }
>                                                                               
>                                                
> -------------------------
>                                                                               
>                                                
> my problem is \'operation_loop\' not running , please give the solution for 
> this problem (Note: with the same architecture).
>                                                                               
>                                                
>                                                                               
>                                                
> Thanks,
> Barani
>
>   


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Openipmi-developer mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openipmi-developer

Reply via email to