ChannelCreate question

When using ChannelCreate, you can pass in flags such as
_NTO_CHF_COID_DISCONNECT and _NTO_CHF_DISCONNECT. According to the
documentation, pulse codes _PULSE_CODE_COIDDEATH and
_PULSE_CODE_DISCONNECT, respectively, are delivered to the server. I am
using resmgr_attach with ChannelCreate. Does anyone know how the pulses are
delivered to the server? Do I have to use pulse_attach? Is it done through
one of the io functions set up in resmgr_attach?

Any help would be greatly appreciated. Thanks.

Rex

Rex Lam a écrit :

When using ChannelCreate, you can pass in flags such as
_NTO_CHF_COID_DISCONNECT and _NTO_CHF_DISCONNECT. According to the
documentation, pulse codes _PULSE_CODE_COIDDEATH and
_PULSE_CODE_DISCONNECT, respectively, are delivered to the server. I am
using resmgr_attach with ChannelCreate. Does anyone know how the pulses are
delivered to the server?

As you have a channel crated for your resource manager, you can use it to
receive your pulse.

Do I have to use pulse_attach?

So, I suppose that you want to create a pulse within your server process. In
that case, the answer is yes.

Is it done through
one of the io functions set up in resmgr_attach?

Yes, the one you give as any other iofunc.

Any help would be greatly appreciated. Thanks.

Rex

In case you want to generate a pulse with a timer, you can do:

int check_the_pulse(message_context_t *ctp, int code, unsigned flags, void
*handle){
printf(“I got the pulse\n”);
}

// these structures must exists during your process lifetime
struct itimerspec itime;
struct sigevent event;

int init_timer_pulse(void) {
int pulse_code, coid;
timer_t timerid;

if ((pulse_code = pulse_attach(dpp, MSG_FLAG_ALLOC_PULSE, 0,
check_the_pulse, NULL)) == -1) {
// If you don’t matter of the pulse code value
// the dpp you got from
dispatch_create()
return(errno);
}

// to attach the pulse reception to the resource manager channel and get the
connection id.
if ((coid = message_connect(dpp, MSG_FLAG_SIDE_CHANNEL)) == -1) {
return(errno);
}

SIGEV_PULSE_INIT(&event, coid, SIGEV_PULSE_PRIO_INHERIT, pulse_code, 0);

if (timer_create(CLOCK_REALTIME, &event, &timerid) == -1) {
return (errno);
}

itime.it_value.tv_sec = 0;
itime.it_value.tv_nsec = 500000000;
itime.it_interval.tv_sec = 0;
itime.it_interval.tv_nsec = 500000000;

if (timer_settime(timerid, 0, &itime, NULL) == -1) {
return(errno);
}
}

Regards,
Alain.