tech-kern archive

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

Re: closing a socket in kernel mode

On Wed, Jun 04, 2008 at 10:31:29AM -0400, Eddy Quicksall wrote:
> I'm using sockets in kernel level. I use the following functions. I'm having
> trouble closing the socket. What happens is that the file is not freed up
> and I eventually get error 24 (Too many open files). Any ideas?
> sys___socket30()
> soaccept()
> so_send()
> sys_shutdown() (this causes the FIN to be properly sent)

If you can, avoid using the sys_XXX routines.  Instead, directly use
the same soXXX routines that the sys_ routines call.

> -- and finally to close the file I do this, but it ends up sleeping in
> sys_close ---
> -- if I print fp->f_usecount I see it is 0xf. It was suggested that I try
> -- but using FILE_UNUSE(fp,curlwp) does not change that f_usecount nor does
> it
> -- keep sys_close from sleeping
> SCARG(&CloseArgs, fd) = s;
> sys_close(curlwp, &CloseArgs, retval);

Is a file descriptor strictly necessary?

In -current sources, you may find some examples of what you need to do
in gre(4).


David Young             OJC Technologies      Urbana, IL * (217) 278-3933 ext 24

Home | Main Index | Thread Index | Old Index