View topic - PULSE_CODE_DISCONNECT: cleaning up my own data

PULSE_CODE_DISCONNECT: cleaning up my own data

anything that doesn't fit to other groups.

PULSE_CODE_DISCONNECT: cleaning up my own data

Postby Mr.Green » Fri Jun 11, 2010 7:27 am

Hello,
I am having a problem when a task dies that has connected to my server.
I am storing information about the connected tasks within an internal table.
When a task sends a PULSE_CODE_DISCONNECT, I need to clean up my table.

I tried to use ConnectClientInfo to get the PID of this task by the received SCOID, but ConnectClientInfo returns always -1 (errno EFAULT).

Code: Select all
struct _client_info client_info;                  if(ConnectClientInfo(new_msg_in->pulse.scoid, &client_info, 0) == -1)
{
   printf("%d", errno);         
}



Why doesn't ConnectClientInfo work? Is there something wrong with the client_info-Buffer?

Or other way round: Could I store the SCOID besides the PID in my table, so I could search for the SCOID when the connected Client dies?
Is the SCOID unique?

Thanks,
Mr.Green
Mr.Green
Active Member
 
Posts: 37
Joined: Tue Nov 11, 2008 12:21 pm

Postby Tim » Fri Jun 11, 2010 1:39 pm

Mr Green,

The scoid is unique otherwise you wouldn't be able to close a particular connection between processes.

That said, it's not clear why your code is indicating a fault with the ConnectClientInfo() call. The only plausible explanation I have (assuming your new_msg->pulse.scoid isn't the issue) is that the process you are trying to get info for no longer exists because it already died. The *easy* way to test if that is the case is to do the same ConnectClientInfo() call when receiving a normal message and if that doesn't indicate an error then you have your answer.

Tim
Tim
Senior Member
 
Posts: 1469
Joined: Wed Mar 10, 2004 12:28 am

Postby Mr.Green » Mon Jun 14, 2010 5:44 am

Good morning,
Of course I call the ConnectClientInfo() in that moment when the DISCONNECT-Pulse arrives, so I guess this information has been already removed?
When I call it when a normal Pulse arrives, it works.
But I don't understand why: I don't need to use the SCOID (at least at the moment) in another case than the DISCONNECT-Pulse arrives.

So how could I get the PID of the died task that has sent a DISCONNECT?

Regards, Mr.Green
Mr.Green
Active Member
 
Posts: 37
Joined: Tue Nov 11, 2008 12:21 pm

Postby Tim » Mon Jun 14, 2010 1:32 pm

Mr Green,

I don't think you can get the PID of a process that has died because the process has already been removed from the kernel.

The normal DISCONNECT case when a process voluntarily disconnects is different because it still exists and so the kernel can give you its PID.

So your choices are:

1) Store the scoid (as you pointed out in your initial post)
2) Obtain the PID of the process when it initially connects and register with the kernel to be informed when that process exits and clean up that way (requires other API calls).

Tim
Tim
Senior Member
 
Posts: 1469
Joined: Wed Mar 10, 2004 12:28 am


Return to General Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron