From: Haomai Wang Date: Tue, 4 Aug 2015 09:50:36 +0000 (+0800) Subject: EventSocket: Add new event type pipe support X-Git-Tag: v10.0.2~142^2~12 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c7703db989c22be0c1b8007acdbf2a84eb519a65;p=ceph.git EventSocket: Add new event type pipe support Signed-off-by: Haomai Wang --- diff --git a/src/common/event_socket.h b/src/common/event_socket.h index f2ac92de5b39..7bbd7ec33e25 100644 --- a/src/common/event_socket.h +++ b/src/common/event_socket.h @@ -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; diff --git a/src/include/event_type.h b/src/include/event_type.h index adab6907227a..696e7664b3a1 100644 --- a/src/include/event_type.h +++ b/src/include/event_type.h @@ -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