Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / msg / async / EventEpoll.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
2 // vim: ts=8 sw=2 smarttab
3 /*
4  * Ceph - scalable distributed file system
5  *
6  * Copyright (C) 2014 UnitedStack <haomai@unitedstack.com>
7  *
8  * Author: Haomai Wang <haomaiwang@gmail.com>
9  *
10  * This is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License version 2.1, as published by the Free Software
13  * Foundation.  See file COPYING.
14  *
15  */
16
17 #ifndef CEPH_MSG_EVENTEPOLL_H
18 #define CEPH_MSG_EVENTEPOLL_H
19
20 #include <unistd.h>
21 #include <sys/epoll.h>
22
23 #include "Event.h"
24
25 class EpollDriver : public EventDriver {
26   int epfd;
27   struct epoll_event *events;
28   CephContext *cct;
29   int size;
30
31  public:
32   explicit EpollDriver(CephContext *c): epfd(-1), events(NULL), cct(c), size(0) {}
33   ~EpollDriver() override {
34     if (epfd != -1)
35       close(epfd);
36
37     if (events)
38       free(events);
39   }
40
41   int init(EventCenter *c, int nevent) override;
42   int add_event(int fd, int cur_mask, int add_mask) override;
43   int del_event(int fd, int cur_mask, int del_mask) override;
44   int resize_events(int newsize) override;
45   int event_wait(vector<FiredFileEvent> &fired_events,
46                  struct timeval *tp) override;
47 };
48
49 #endif