Skip to content

Commit

Permalink
EventSocket: Add new event type pipe support
Browse files Browse the repository at this point in the history
Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
  • Loading branch information
yuyuyu101 committed Aug 5, 2015
1 parent 4b41cc5 commit a19a61e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
20 changes: 15 additions & 5 deletions src/common/event_socket.h
Expand Up @@ -25,17 +25,27 @@ class EventSocket {
EventSocket(): socket(-1), type(EVENT_SOCKET_TYPE_NONE) {}
bool is_valid() const { return socket != -1; }
int init(int fd, int t) {
switch (t) {
case EVENT_SOCKET_TYPE_PIPE:
#ifdef HAVE_EVENTFD
if (t == EVENT_SOCKET_TYPE_EVENTFD) {
socket = fd;
type = t;
return 0;
}
case EVENT_SOCKET_TYPE_EVENTFD:
#endif
{
socket = fd;
type = t;
return 0;
}
}
return -1;
}
int notify() {
switch (type) {
case EVENT_SOCKET_TYPE_PIPE:
{
char buf[1];
buf[0] = 'i';
return write(socket, buf, 1);
}
case EVENT_SOCKET_TYPE_EVENTFD:
{
uint64_t value = 1;
Expand Down
3 changes: 2 additions & 1 deletion src/include/event_type.h
Expand Up @@ -16,6 +16,7 @@
#define CEPH_COMMON_EVENT_TYPE_H

#define EVENT_SOCKET_TYPE_NONE 0
#define EVENT_SOCKET_TYPE_EVENTFD 1
#define EVENT_SOCKET_TYPE_PIPE 1
#define EVENT_SOCKET_TYPE_EVENTFD 2

#endif

0 comments on commit a19a61e

Please sign in to comment.