resource manager and thread (repost)

I’m a little bit lost!!!

When we write a simple server application which is able to create thread we need to have something like:

typedef union{
struct _pulse pulse;
struct my_message msg;
}msg_t;


msg_t msg;

rcvid = MsgReceive(…)

switch (rcvid)
{
case 0:
switch(msg.pulse.code)
{
case _PULSE_CODE_DISCONNECT:
ConnectDetach(Msg.pulse.scoid);
break;
}
break;

}



Now consider a server application developped as a ressource manager, able to receive IO_MSG and able to create a thread to do something, depending on the received message.
the message type is:

typedef union{
struct _io_msg io_msg;
struct _pulse pulse;
};

In the application we have:

for_ever{
ctp = dispatch_block(ctp);

dispatch_handler(ctp);
}

My problem is how can I catch the pulse to call the ConnectDetach()??


I have a second problem which maybe is the same.

After I killed the thread, my ressource manager exits, why ??

Third, If I printf() the message type received I see the following sequence:

IO_CONNECT
IO_MSG
IO_CLOSE
0

What is 0 (zero)?

Thanks Alain.

See below …

Alain Bonnefoy <alain.bonnefoy@icbt.com> wrote:

I’m a little bit lost!!!

When we write a simple server application which is able to create
thread we need to have something like:

typedef union{
struct _pulse pulse;
struct my_message msg;
}msg_t;


msg_t msg;

rcvid = MsgReceive(…)

switch (rcvid)
{
case 0:
switch(msg.pulse.code)
{
case _PULSE_CODE_DISCONNECT:
ConnectDetach(Msg.pulse.scoid);
break;
}
break;

}



Now consider a server application developped as a ressource manager,
able to receive IO_MSG and able to create a thread to do something,
depending on the received message.
the message type is:

typedef union{
struct _io_msg io_msg;
struct _pulse pulse;
};

In the application we have:

for_ever{
ctp = dispatch_block(ctp);

dispatch_handler(ctp);
}

My problem is how can I catch the pulse to call the ConnectDetach()??

Do you mean the _PULSE_CODE_DISCONNECT pulse from clients that have
open()ed your resource manager’s registered name? If yes then don’t
worry about it. The resource manager library already handles this
pulse by doing the ConnectDetach(scoid).

I have a second problem which maybe is the same.

After I killed the thread, my ressource manager exits, why ??

Third, If I printf() the message type received I see the following
sequence:

IO_CONNECT
^ client open()s, open() sends this



IO_MSG
^ client sends IO_MSG



IO_CLOSE
^ client calls close(), close() sends IO_CLOSE message



0
^ the _PULSE_CODE_DISCONNECT pulse, close() calls ConnectDetach(fd)



What is 0 (zero)?

Thanks Alain.