Re: How to keep track of socket close()?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have a question on socket close().

I want to be able to keep track of socket related information as
sockets are created and destroyed. One way I can do is to interpose
bind() and connect() system calls so that I can add them to my table.
Then I keep track of shutdown() to delete the given socket
information.
FYI, I use socket descriptor as an index of my table.
Now one problem is that I do not know if the given file descriptor is
socket descriptor when the user calls close() system call. I suppose
there is a way but I think that it may be too expensive to check out
all the file descriptor when close() is called.
Is there any nice way I can know when the socket is closed? Please
give me some advice. Thank you very much.


I found an answer by myself. But I thought that it could benefit
someone so I would like to post the answer that I found.

if (current->files->fd[fd]->f_dentry->d_inode->i_sb->s_magic == SOCKFS_MAGIC)

Please also advise me if you have any better solution. Thanks.

Ilho <><
--

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux