libsysutils: Fix some bugs in NetlinkListener and NetlinkEvent

Signed-off-by: San Mehat <san@android.com>
This commit is contained in:
San Mehat 2009-10-10 17:35:13 -07:00
parent 808c89e120
commit ebfe3db361
3 changed files with 6 additions and 4 deletions

View File

@ -26,7 +26,9 @@ class NetlinkListener : public SocketListener {
public:
NetlinkListener(int socket);
virtual ~NetlinkListener() {}
protected:
virtual bool onDataAvailable(SocketClient *cli);
virtual void onEvent(NetlinkEvent *evt) = 0;
};
#endif

View File

@ -28,6 +28,9 @@ const int NetlinkEvent::NlActionChange = 3;
NetlinkEvent::NetlinkEvent() {
mAction = NlActionUnknown;
memset(mParams, 0, sizeof(mParams));
mPath = NULL;
mSubsystem = NULL;
}
NetlinkEvent::~NetlinkEvent() {

View File

@ -32,8 +32,6 @@ NetlinkListener::NetlinkListener(int socket) :
bool NetlinkListener::onDataAvailable(SocketClient *cli)
{
int socket = cli->getSocket();
LOGD("NetlinkListener::onDataAvailable()");
int count;
if ((count = recv(socket, mBuffer, sizeof(mBuffer), 0)) < 0) {
@ -47,8 +45,7 @@ bool NetlinkListener::onDataAvailable(SocketClient *cli)
goto out;
}
LOGD("Ignoring '%s' netlink event", evt->getSubsystem());
onEvent(evt);
out:
delete evt;
return true;