Hello,
I write a resource manager which manages several devices and I handle
private messages.
I use ctp->id to know with which device communicates the client.
When the client does an open() on the first device, the id is 0. But when
the client
sends a private message with the same device, the id is -1 ???
Here is the code :
int main(int argc, char **argv)
{
…
if(message_attach(dpp, NULL, FIRST_PRIV_MESS, LAST_PRIV_MESS,
&message_handler, NULL) == -1) {
return EXIT_FAILURE;
}
if(pulse_attach(dpp, 0, 3, &pulse_handler, NULL) == -1) {
perror(“pulse_attach”);
return EXIT_FAILURE;
}
/* start the resource manager message loop */
while(1) {
if((new_ctp = dispatch_block(ctp)) == NULL) {
return EXIT_FAILURE;
}
ctp=new_ctp;
dispatch_handler(ctp);
}
return 0;
}
int io_open(resmgr_context_t *ctp, io_open_t *msg, IOFUNC_ATTR_T *device,
void *extra)
{
int sts;
printf(“IO_OPEN\n”);
sts = iofunc_open_default(ctp, msg, &device->attr, extra);
printf(“ctp->id:%d ctp->rcvid:%d ctp->info.coid:%d\n”, ctp->id,
ctp->rcvid, ctp->info.coid);
return sts;
}
Here the function printf() displays:
ctp->id:0 ctp->rcvid:4 ctp->info.coid:3
int message_handler(message_context_t *ctp, int code, unsigned flags, void
*handle)
{
…
printf(“ctp->id:%d ctp->rcvid:%d ctp->info.coid:%d\n”, ctp->id,
ctp->rcvid, ctp->info.coid);
…
}
Here the function printf() displays:
ctp->id:-1 ctp->rcvid:4 ctp->info.coid:3
I don’t know why ‘id’ is bad.
My problem is to know with which device communicates the client.
If I can’t use ctp->id, is there a simple solution to know the device when
the client uses a private message ?
Thank you for your answer.
-Phil