librbd: normalize notify return code

Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
This commit is contained in:
Haomai Wang 2015-08-19 16:15:40 +08:00 committed by Haomai Wang
parent 6d114749ff
commit 39327146be

View File

@ -39,23 +39,29 @@ class EventSocket {
return -1;
}
int notify() {
int ret;
switch (type) {
case EVENT_SOCKET_TYPE_PIPE:
{
char buf[1];
buf[0] = 'i';
return write(socket, buf, 1);
ret = write(socket, buf, 1);
if (ret < 0)
ret = -errno;
}
case EVENT_SOCKET_TYPE_EVENTFD:
{
uint64_t value = 1;
return write(socket, &value, sizeof (value));
ret = write(socket, &value, sizeof (value));
if (ret < 0)
ret = -errno;
}
default:
{
return -1;
ret = -1;
}
}
return ret;
}
};