This file is indexed.

/usr/include/dnscore/async.h is in libyadifa-dev 2.1.6-1.

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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
/*------------------------------------------------------------------------------
*
* Copyright (c) 2011-2016, EURid. All rights reserved.
* The YADIFA TM software product is provided under the BSD 3-clause license:
* 
* 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 EURid 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 HOLDER 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.
*
*------------------------------------------------------------------------------
*
*/
#ifndef ASYNC_H
#define	ASYNC_H

#define ASYNC_QUEUE_TYPE_RINGBUFFER 1
#define ASYNC_QUEUE_TYPE_DLL        2

#define ASYNC_QUEUE_TYPE ASYNC_QUEUE_TYPE_DLL

#if ASYNC_QUEUE_TYPE == ASYNC_QUEUE_TYPE_DLL
#include <dnscore/threaded_dll_cw.h>
#elif ASYNC_QUEUE_TYPE == ASYNC_QUEUE_TYPE_RINGBUFFER
#include <dnscore/threaded_ringbuffer_cw.h>
#else
#error "ASYNC_QUEUE_TYPE not set"
#endif
#include <dnscore/pace.h>

#ifdef	__cplusplus
extern "C" {
#endif

/**
 * 
 * Typically, the handler will be a small function that pushes the message in another processing queue,
 * with or without changing the id (so processors can be chained)
 * 
 * The handler can also be a function that allows another function to proceed (delegation mechanism, in the .net linguo)
 * This would make the handling synchronous but the processing parallel
 * 
 */
    
// used by threads to process a task then push it further in the assembly line

struct async_message_s;
    
typedef void async_done_callback(struct async_message_s *msg);

struct async_wait_s
{
    pthread_mutex_t mutex;
    pthread_cond_t  cond_wait;
    volatile s32 wait_count;
    volatile s32 error_code;
};

typedef struct async_wait_s async_wait_s;

struct async_queue_s
{
#if ASYNC_QUEUE_TYPE == ASYNC_QUEUE_TYPE_DLL
    threaded_dll_cw queue;
#elif ASYNC_QUEUE_TYPE == ASYNC_QUEUE_TYPE_RINGBUFFER
    threaded_ringbuffer_cw queue;
#else
    threaded_queue queue;
#endif
    
    pace_s pace;
};

typedef struct async_queue_s async_queue_s;

struct async_message_s
{
    s32 id;         // the message id for the processor
    s32 error_code; // the error code to be set by the processor
    void *args;     // the arguments for the processor
    
    async_done_callback *handler; // what must be called when the processor has finished working
    void *handler_args;             // complementary arguments for the handler
    
    volatile u64 start_time;
};

typedef struct async_message_s async_message_s;

/**
 * 
 * Initialises a synchronisation point
 * count is the number of releases to do before the async_wait call returns
 * 
 * @param aw
 * @param count
 * @return 
 */

void async_wait_init(async_wait_s *aw, s32 count);

/**
 * Waits until the count has be reduced to 0 (or below if something bad is going on)
 * 
 * @param aw
 * @return 
 */

void async_wait(async_wait_s *aw);

/**
 * Waits until the count has be reduced to 0 (or below if something bad is going on)
 *    OR until the amount of microseconds has elapsed.
 * 
 * @param aw
 * @param usec
 * @return true if and only if the wait counter reached 0
 */

bool async_wait_timeout(async_wait_s *aw, u64 usec);

/**
 * Waits until the count has be reduced to 0 (or below if something bad is going on)
 *    OR until the epoch in microseconds has been reached.
 * 
 * @param aw
 * @param usec
 * @return true if and only if the wait counter reached 0
 */

bool async_wait_timeout_absolute(async_wait_s *aw, u64 epoch_usec);

/**
 * Returns the current value of the counter
 * 
 * @param aw
 * @return 
 */

s32 async_wait_get_counter(async_wait_s *aw);

/**
 * 
 * Decreases the count of that amount
 * 
 * @param aw
 * @param count
 * @return 
 */

void async_wait_progress(async_wait_s *aw, s32 count);

void async_wait_set_first_error(async_wait_s *aw, s32 error);

s32 async_wait_get_error(async_wait_s *aw);

/**
 * 
 * Destroys the synchronisation point
 * 
 * @param aw
 * @return 
 */

void async_wait_finalize(async_wait_s *aw);

void async_queue_init(async_queue_s *q, u32 size, u64 min_us, u64 max_us, const char* name);

void async_queue_finalize(async_queue_s *q);

bool async_queue_emtpy(async_queue_s *q);

u32 async_queue_size(async_queue_s *q);

async_message_s *async_message_next(async_queue_s *queue);

async_message_s* async_message_try_next(async_queue_s *queue);

/**
 * 
 * Pushes the message to the queue.
 * The queue is supposed to be read in another thread
 * 
 * @param queue
 * @param msg
 */

void async_message_call(async_queue_s *queue, async_message_s *msg);

/**
 * Sets the handler and handler_args fields to make the message a waiter
 * Restores the fields before returning
 * 
 * @param msg
 */

int async_message_call_and_wait(async_queue_s *queue, async_message_s *msg);

/**
 * Sets the handler and handler_args fields to ignore the result
 * (fire and forget)
 *
 * @param msg
 */

void async_message_call_and_forget(async_queue_s *queue, async_message_s *msg);

/**
 * Sets the handler and handler_args fields to ignore the result
 * (fire and forget)
 *
 * @param msg
 */

void async_message_call_and_release(async_queue_s *queue, async_message_s *msg);

void async_message_pool_init();
async_message_s *async_message_alloc();
void async_message_release(async_message_s *msg);
void async_message_pool_finalize();

#ifdef	__cplusplus
}
#endif

#endif	/* ASYNC_H */