This file is indexed.

/usr/include/udt/epoll.h is in libudt-dev 4.11+dfsg1-1ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/*****************************************************************************
Copyright (c) 2001 - 2010, The Board of Trustees of the University of Illinois.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above
  copyright notice, this list of conditions and the
  following disclaimer.

* Redistributions in binary form must reproduce the
  above copyright notice, this list of conditions
  and the following disclaimer in the documentation
  and/or other materials provided with the distribution.

* Neither the name of the University of Illinois
  nor the names of its contributors may be used to
  endorse or promote products derived from this
  software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/

/*****************************************************************************
written by
   Yunhong Gu, last updated 08/20/2010
*****************************************************************************/

#ifndef __UDT_EPOLL_H__
#define __UDT_EPOLL_H__


#include <map>
#include <set>
#include "udt.h"


struct CEPollDesc
{
   int m_iID;                                // epoll ID
   std::set<UDTSOCKET> m_sUDTSocksOut;       // set of UDT sockets waiting for write events
   std::set<UDTSOCKET> m_sUDTSocksIn;        // set of UDT sockets waiting for read events
   std::set<UDTSOCKET> m_sUDTSocksEx;        // set of UDT sockets waiting for exceptions

   int m_iLocalID;                           // local system epoll ID
   std::set<SYSSOCKET> m_sLocals;            // set of local (non-UDT) descriptors

   std::set<UDTSOCKET> m_sUDTWrites;         // UDT sockets ready for write
   std::set<UDTSOCKET> m_sUDTReads;          // UDT sockets ready for read
   std::set<UDTSOCKET> m_sUDTExcepts;        // UDT sockets with exceptions (connection broken, etc.)
};

class CEPoll
{
friend class CUDT;
friend class CRendezvousQueue;

public:
   CEPoll();
   ~CEPoll();

public: // for CUDTUnited API

      // Functionality:
      //    create a new EPoll.
      // Parameters:
      //    None.
      // Returned value:
      //    new EPoll ID if success, otherwise an error number.

   int create();

      // Functionality:
      //    add a UDT socket to an EPoll.
      // Parameters:
      //    0) [in] eid: EPoll ID.
      //    1) [in] u: UDT Socket ID.
      //    2) [in] events: events to watch.
      // Returned value:
      //    0 if success, otherwise an error number.

   int add_usock(const int eid, const UDTSOCKET& u, const int* events = NULL);

      // Functionality:
      //    add a system socket to an EPoll.
      // Parameters:
      //    0) [in] eid: EPoll ID.
      //    1) [in] s: system Socket ID.
      //    2) [in] events: events to watch.
      // Returned value:
      //    0 if success, otherwise an error number.

   int add_ssock(const int eid, const SYSSOCKET& s, const int* events = NULL);

      // Functionality:
      //    remove a UDT socket event from an EPoll; socket will be removed if no events to watch
      // Parameters:
      //    0) [in] eid: EPoll ID.
      //    1) [in] u: UDT socket ID.
      // Returned value:
      //    0 if success, otherwise an error number.

   int remove_usock(const int eid, const UDTSOCKET& u);

      // Functionality:
      //    remove a system socket event from an EPoll; socket will be removed if no events to watch
      // Parameters:
      //    0) [in] eid: EPoll ID.
      //    1) [in] s: system socket ID.
      // Returned value:
      //    0 if success, otherwise an error number.

   int remove_ssock(const int eid, const SYSSOCKET& s);

      // Functionality:
      //    wait for EPoll events or timeout.
      // Parameters:
      //    0) [in] eid: EPoll ID.
      //    1) [out] readfds: UDT sockets available for reading.
      //    2) [out] writefds: UDT sockets available for writing.
      //    3) [in] msTimeOut: timeout threshold, in milliseconds.
      //    4) [out] lrfds: system file descriptors for reading.
      //    5) [out] lwfds: system file descriptors for writing.
      // Returned value:
      //    number of sockets available for IO.

   int wait(const int eid, std::set<UDTSOCKET>* readfds, std::set<UDTSOCKET>* writefds, int64_t msTimeOut, std::set<SYSSOCKET>* lrfds, std::set<SYSSOCKET>* lwfds);

      // Functionality:
      //    close and release an EPoll.
      // Parameters:
      //    0) [in] eid: EPoll ID.
      // Returned value:
      //    0 if success, otherwise an error number.

   int release(const int eid);

public: // for CUDT to acknowledge IO status

      // Functionality:
      //    Update events available for a UDT socket.
      // Parameters:
      //    0) [in] uid: UDT socket ID.
      //    1) [in] eids: EPoll IDs to be set
      //    1) [in] events: Combination of events to update
      //    1) [in] enable: true -> enable, otherwise disable
      // Returned value:
      //    0 if success, otherwise an error number

   int update_events(const UDTSOCKET& uid, std::set<int>& eids, int events, bool enable);

private:
   int m_iIDSeed;                            // seed to generate a new ID
   pthread_mutex_t m_SeedLock;

   std::map<int, CEPollDesc> m_mPolls;       // all epolls
   pthread_mutex_t m_EPollLock;
};


#endif