close socket + kernel module
Hello,
I am working with/writing a kernel module which communicates with user processes using a custom socket family. One of the features that I need in this module is "force shutdown", which will close the sockets and somehow notify the user process(es) that the communication has been broken. I attempted to do the following in the module "shutdown" code: PHP Code:
Any ides on how to properly close a socket from inside a kernel module? Perhaps I need to do something specific in sk_destruct? Thanks, ib |
If the user opens a socket, then the user (or user-side process cleanup code) must close it.
When you determine that the communications represented by some particular socket are no longer possible, then you should signal the user-process (in some agreed-upon way), and also set a flag in your own internal data-structures to reflect the fact that this communication channel is now "dead." If the user ignores the notification and attempts to communicate with a dead channel, the request is turned-away, returning an error indication to the user's socket-I/O request. If the user queries the status of the channel (in some way that you have provided), he will learn that it is "dead as a doornail." Eventually, one way or the other, the user will close what he has opened. When he does so, the data-structures you have created must be expunged. |
You must have some code that notifies the client when your socket becomes unusable (if it's connection-oriented, when the connection is broken; when the interface goes down etc). Copy that code. Don't deallocate socket structures - it's needed for the client to read()/write() and get an error and/or close() properly.
|
All times are GMT -5. The time now is 03:26 AM. |