|
|
1 | /* |
|
|
2 | * libeio implementation |
|
|
3 | * |
|
|
4 | * Copyright (c) 2007,2008 Marc Alexander Lehmann <libeio@schmorp.de> |
|
|
5 | * All rights reserved. |
|
|
6 | * |
|
|
7 | * Redistribution and use in source and binary forms, with or without modifica- |
|
|
8 | * tion, are permitted provided that the following conditions are met: |
|
|
9 | * |
|
|
10 | * 1. Redistributions of source code must retain the above copyright notice, |
|
|
11 | * this list of conditions and the following disclaimer. |
|
|
12 | * |
|
|
13 | * 2. Redistributions in binary form must reproduce the above copyright |
|
|
14 | * notice, this list of conditions and the following disclaimer in the |
|
|
15 | * documentation and/or other materials provided with the distribution. |
|
|
16 | * |
|
|
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
|
|
18 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- |
|
|
19 | * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
|
|
20 | * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- |
|
|
21 | * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
|
|
22 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
|
|
23 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
|
|
24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- |
|
|
25 | * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
|
|
26 | * OF THE POSSIBILITY OF SUCH DAMAGE. |
|
|
27 | * |
|
|
28 | * Alternatively, the contents of this file may be used under the terms of |
|
|
29 | * the GNU General Public License ("GPL") version 2 or any later version, |
|
|
30 | * in which case the provisions of the GPL are applicable instead of |
|
|
31 | * the above. If you wish to allow the use of your version of this file |
|
|
32 | * only under the terms of the GPL and not to allow others to use your |
|
|
33 | * version of this file under the BSD license, indicate your decision |
|
|
34 | * by deleting the provisions above and replace them with the notice |
|
|
35 | * and other provisions required by the GPL. If you do not delete the |
|
|
36 | * provisions above, a recipient may use your version of this file under |
|
|
37 | * either the BSD or the GPL. |
|
|
38 | */ |
|
|
39 | |
1 | #include "eio.h" |
40 | #include "eio.h" |
2 | #include "xthread.h" |
41 | #include "xthread.h" |
3 | |
42 | |
4 | #include <errno.h> |
43 | #include <errno.h> |
5 | #include <stddef.h> |
44 | #include <stddef.h> |
… | |
… | |
70 | /* buffer size for various temporary buffers */ |
109 | /* buffer size for various temporary buffers */ |
71 | #define EIO_BUFSIZE 65536 |
110 | #define EIO_BUFSIZE 65536 |
72 | |
111 | |
73 | #define dBUF \ |
112 | #define dBUF \ |
74 | char *eio_buf; \ |
113 | char *eio_buf; \ |
75 | X_LOCK (wrklock); \ |
114 | ETP_WORKER_LOCK (self); \ |
76 | self->dbuf = eio_buf = malloc (EIO_BUFSIZE); \ |
115 | self->dbuf = eio_buf = malloc (EIO_BUFSIZE); \ |
77 | X_UNLOCK (wrklock); \ |
116 | ETP_WORKER_UNLOCK (self); \ |
78 | errno = ENOMEM; \ |
117 | errno = ENOMEM; \ |
79 | if (!eio_buf) \ |
118 | if (!eio_buf) \ |
80 | return -1; |
119 | return -1; |
81 | |
120 | |
82 | #define EIO_TICKS ((1000000 + 1023) >> 10) |
121 | #define EIO_TICKS ((1000000 + 1023) >> 10) |
83 | |
122 | |
|
|
123 | /*****************************************************************************/ |
|
|
124 | |
|
|
125 | #define ETP_PRI_MIN EIO_PRI_MIN |
|
|
126 | #define ETP_PRI_MAX EIO_PRI_MAX |
|
|
127 | |
|
|
128 | #define ETP_REQ eio_req |
|
|
129 | #define ETP_DESTROY(req) eio_destroy (req) |
|
|
130 | static int eio_finish (eio_req *req); |
|
|
131 | #define ETP_FINISH(req) eio_finish (req) |
|
|
132 | |
|
|
133 | #define ETP_WORKER_CLEAR(req) \ |
|
|
134 | if (wrk->dbuf) \ |
|
|
135 | { \ |
|
|
136 | free (wrk->dbuf); \ |
|
|
137 | wrk->dbuf = 0; \ |
|
|
138 | } \ |
|
|
139 | \ |
|
|
140 | if (wrk->dirp) \ |
|
|
141 | { \ |
|
|
142 | closedir (wrk->dirp); \ |
|
|
143 | wrk->dirp = 0; \ |
|
|
144 | } |
|
|
145 | #define ETP_WORKER_COMMON \ |
|
|
146 | void *dbuf; \ |
|
|
147 | DIR *dirp; |
|
|
148 | |
|
|
149 | /*****************************************************************************/ |
|
|
150 | |
|
|
151 | #define ETP_NUM_PRI (ETP_PRI_MAX - ETP_PRI_MIN + 1) |
|
|
152 | |
|
|
153 | /* calculcate time difference in ~1/EIO_TICKS of a second */ |
|
|
154 | static int tvdiff (struct timeval *tv1, struct timeval *tv2) |
|
|
155 | { |
|
|
156 | return (tv2->tv_sec - tv1->tv_sec ) * EIO_TICKS |
|
|
157 | + ((tv2->tv_usec - tv1->tv_usec) >> 10); |
|
|
158 | } |
|
|
159 | |
|
|
160 | static unsigned int started, idle, wanted = 4; |
|
|
161 | |
84 | static void (*want_poll_cb) (void); |
162 | static void (*want_poll_cb) (void); |
85 | static void (*done_poll_cb) (void); |
163 | static void (*done_poll_cb) (void); |
86 | |
164 | |
87 | static unsigned int max_poll_time = 0; |
165 | static unsigned int max_poll_time; /* reslock */ |
88 | static unsigned int max_poll_reqs = 0; |
166 | static unsigned int max_poll_reqs; /* reslock */ |
89 | |
167 | |
90 | /* calculcate time difference in ~1/EIO_TICKS of a second */ |
168 | static volatile unsigned int nreqs; /* reqlock */ |
91 | static int tvdiff (struct timeval *tv1, struct timeval *tv2) |
169 | static volatile unsigned int nready; /* reqlock */ |
92 | { |
170 | static volatile unsigned int npending; /* reqlock */ |
93 | return (tv2->tv_sec - tv1->tv_sec ) * EIO_TICKS |
171 | static volatile unsigned int max_idle = 4; |
94 | + ((tv2->tv_usec - tv1->tv_usec) >> 10); |
|
|
95 | } |
|
|
96 | |
172 | |
97 | static unsigned int started, idle, wanted = 4; |
|
|
98 | |
|
|
99 | /* worker threads management */ |
|
|
100 | static mutex_t wrklock = X_MUTEX_INIT; |
173 | static mutex_t wrklock = X_MUTEX_INIT; |
101 | |
|
|
102 | typedef struct worker |
|
|
103 | { |
|
|
104 | /* locked by wrklock */ |
|
|
105 | struct worker *prev, *next; |
|
|
106 | |
|
|
107 | thread_t tid; |
|
|
108 | |
|
|
109 | /* locked by reslock, reqlock or wrklock */ |
|
|
110 | eio_req *req; /* currently processed request */ |
|
|
111 | void *dbuf; |
|
|
112 | DIR *dirp; |
|
|
113 | } worker; |
|
|
114 | |
|
|
115 | static worker wrk_first = { &wrk_first, &wrk_first, 0 }; |
|
|
116 | |
|
|
117 | static void worker_clear (worker *wrk) |
|
|
118 | { |
|
|
119 | if (wrk->dirp) |
|
|
120 | { |
|
|
121 | closedir (wrk->dirp); |
|
|
122 | wrk->dirp = 0; |
|
|
123 | } |
|
|
124 | |
|
|
125 | if (wrk->dbuf) |
|
|
126 | { |
|
|
127 | free (wrk->dbuf); |
|
|
128 | wrk->dbuf = 0; |
|
|
129 | } |
|
|
130 | } |
|
|
131 | |
|
|
132 | static void worker_free (worker *wrk) |
|
|
133 | { |
|
|
134 | wrk->next->prev = wrk->prev; |
|
|
135 | wrk->prev->next = wrk->next; |
|
|
136 | |
|
|
137 | free (wrk); |
|
|
138 | } |
|
|
139 | |
|
|
140 | static volatile unsigned int nreqs, nready, npending; |
|
|
141 | static volatile unsigned int max_idle = 4; |
|
|
142 | |
|
|
143 | static mutex_t reslock = X_MUTEX_INIT; |
174 | static mutex_t reslock = X_MUTEX_INIT; |
144 | static mutex_t reqlock = X_MUTEX_INIT; |
175 | static mutex_t reqlock = X_MUTEX_INIT; |
145 | static cond_t reqwait = X_COND_INIT; |
176 | static cond_t reqwait = X_COND_INIT; |
146 | |
177 | |
|
|
178 | typedef struct etp_worker |
|
|
179 | { |
|
|
180 | /* locked by wrklock */ |
|
|
181 | struct etp_worker *prev, *next; |
|
|
182 | |
|
|
183 | thread_t tid; |
|
|
184 | |
|
|
185 | /* locked by reslock, reqlock or wrklock */ |
|
|
186 | ETP_REQ *req; /* currently processed request */ |
|
|
187 | |
|
|
188 | ETP_WORKER_COMMON |
|
|
189 | } etp_worker; |
|
|
190 | |
|
|
191 | static etp_worker wrk_first = { &wrk_first, &wrk_first, 0 }; /* NOT etp */ |
|
|
192 | |
|
|
193 | #define ETP_WORKER_LOCK(wrk) X_LOCK (wrklock) |
|
|
194 | #define ETP_WORKER_UNLOCK(wrk) X_UNLOCK (wrklock) |
|
|
195 | |
|
|
196 | /* worker threads management */ |
|
|
197 | |
|
|
198 | static void etp_worker_clear (etp_worker *wrk) |
|
|
199 | { |
|
|
200 | ETP_WORKER_CLEAR (wrk); |
|
|
201 | } |
|
|
202 | |
|
|
203 | static void etp_worker_free (etp_worker *wrk) |
|
|
204 | { |
|
|
205 | wrk->next->prev = wrk->prev; |
|
|
206 | wrk->prev->next = wrk->next; |
|
|
207 | |
|
|
208 | free (wrk); |
|
|
209 | } |
|
|
210 | |
147 | unsigned int eio_nreqs (void) |
211 | static unsigned int etp_nreqs (void) |
148 | { |
212 | { |
|
|
213 | int retval; |
|
|
214 | if (WORDACCESS_UNSAFE) X_LOCK (reqlock); |
|
|
215 | retval = nreqs; |
|
|
216 | if (WORDACCESS_UNSAFE) X_UNLOCK (reqlock); |
149 | return nreqs; |
217 | return retval; |
150 | } |
218 | } |
151 | |
219 | |
152 | unsigned int eio_nready (void) |
220 | static unsigned int etp_nready (void) |
153 | { |
221 | { |
154 | unsigned int retval; |
222 | unsigned int retval; |
155 | |
223 | |
156 | if (WORDACCESS_UNSAFE) X_LOCK (reqlock); |
224 | if (WORDACCESS_UNSAFE) X_LOCK (reqlock); |
157 | retval = nready; |
225 | retval = nready; |
158 | if (WORDACCESS_UNSAFE) X_UNLOCK (reqlock); |
226 | if (WORDACCESS_UNSAFE) X_UNLOCK (reqlock); |
159 | |
227 | |
160 | return retval; |
228 | return retval; |
161 | } |
229 | } |
162 | |
230 | |
163 | unsigned int eio_npending (void) |
231 | static unsigned int etp_npending (void) |
164 | { |
232 | { |
165 | unsigned int retval; |
233 | unsigned int retval; |
166 | |
234 | |
167 | if (WORDACCESS_UNSAFE) X_LOCK (reqlock); |
235 | if (WORDACCESS_UNSAFE) X_LOCK (reqlock); |
168 | retval = npending; |
236 | retval = npending; |
169 | if (WORDACCESS_UNSAFE) X_UNLOCK (reqlock); |
237 | if (WORDACCESS_UNSAFE) X_UNLOCK (reqlock); |
170 | |
238 | |
171 | return retval; |
239 | return retval; |
172 | } |
240 | } |
173 | |
241 | |
174 | unsigned int eio_nthreads (void) |
242 | static unsigned int etp_nthreads (void) |
175 | { |
243 | { |
176 | unsigned int retval; |
244 | unsigned int retval; |
177 | |
245 | |
178 | if (WORDACCESS_UNSAFE) X_LOCK (reqlock); |
246 | if (WORDACCESS_UNSAFE) X_LOCK (reqlock); |
179 | retval = started; |
247 | retval = started; |
… | |
… | |
186 | * a somewhat faster data structure might be nice, but |
254 | * a somewhat faster data structure might be nice, but |
187 | * with 8 priorities this actually needs <20 insns |
255 | * with 8 priorities this actually needs <20 insns |
188 | * per shift, the most expensive operation. |
256 | * per shift, the most expensive operation. |
189 | */ |
257 | */ |
190 | typedef struct { |
258 | typedef struct { |
191 | eio_req *qs[EIO_NUM_PRI], *qe[EIO_NUM_PRI]; /* qstart, qend */ |
259 | ETP_REQ *qs[ETP_NUM_PRI], *qe[ETP_NUM_PRI]; /* qstart, qend */ |
192 | int size; |
260 | int size; |
193 | } reqq; |
261 | } etp_reqq; |
194 | |
262 | |
195 | static reqq req_queue; |
263 | static etp_reqq req_queue; |
196 | static reqq res_queue; |
264 | static etp_reqq res_queue; |
197 | |
265 | |
198 | static int reqq_push (reqq *q, eio_req *req) |
266 | static int reqq_push (etp_reqq *q, ETP_REQ *req) |
199 | { |
267 | { |
200 | int pri = req->pri; |
268 | int pri = req->pri; |
201 | req->next = 0; |
269 | req->next = 0; |
202 | |
270 | |
203 | if (q->qe[pri]) |
271 | if (q->qe[pri]) |
… | |
… | |
209 | q->qe[pri] = q->qs[pri] = req; |
277 | q->qe[pri] = q->qs[pri] = req; |
210 | |
278 | |
211 | return q->size++; |
279 | return q->size++; |
212 | } |
280 | } |
213 | |
281 | |
214 | static eio_req *reqq_shift (reqq *q) |
282 | static ETP_REQ *reqq_shift (etp_reqq *q) |
215 | { |
283 | { |
216 | int pri; |
284 | int pri; |
217 | |
285 | |
218 | if (!q->size) |
286 | if (!q->size) |
219 | return 0; |
287 | return 0; |
220 | |
288 | |
221 | --q->size; |
289 | --q->size; |
222 | |
290 | |
223 | for (pri = EIO_NUM_PRI; pri--; ) |
291 | for (pri = ETP_NUM_PRI; pri--; ) |
224 | { |
292 | { |
225 | eio_req *req = q->qs[pri]; |
293 | eio_req *req = q->qs[pri]; |
226 | |
294 | |
227 | if (req) |
295 | if (req) |
228 | { |
296 | { |
… | |
… | |
234 | } |
302 | } |
235 | |
303 | |
236 | abort (); |
304 | abort (); |
237 | } |
305 | } |
238 | |
306 | |
239 | static void grp_try_feed (eio_req *grp) |
307 | static void etp_atfork_prepare (void) |
240 | { |
308 | { |
241 | while (grp->size < grp->int2 && !EIO_CANCELLED (grp)) |
309 | X_LOCK (wrklock); |
|
|
310 | X_LOCK (reqlock); |
|
|
311 | X_LOCK (reslock); |
|
|
312 | #if !HAVE_PREADWRITE |
|
|
313 | X_LOCK (preadwritelock); |
|
|
314 | #endif |
|
|
315 | #if !HAVE_READDIR_R |
|
|
316 | X_LOCK (readdirlock); |
|
|
317 | #endif |
|
|
318 | } |
|
|
319 | |
|
|
320 | static void etp_atfork_parent (void) |
|
|
321 | { |
|
|
322 | #if !HAVE_READDIR_R |
|
|
323 | X_UNLOCK (readdirlock); |
|
|
324 | #endif |
|
|
325 | #if !HAVE_PREADWRITE |
|
|
326 | X_UNLOCK (preadwritelock); |
|
|
327 | #endif |
|
|
328 | X_UNLOCK (reslock); |
|
|
329 | X_UNLOCK (reqlock); |
|
|
330 | X_UNLOCK (wrklock); |
|
|
331 | } |
|
|
332 | |
|
|
333 | static void etp_atfork_child (void) |
|
|
334 | { |
|
|
335 | ETP_REQ *prv; |
|
|
336 | |
|
|
337 | while (prv = reqq_shift (&req_queue)) |
|
|
338 | ETP_DESTROY (prv); |
|
|
339 | |
|
|
340 | while (prv = reqq_shift (&res_queue)) |
|
|
341 | ETP_DESTROY (prv); |
|
|
342 | |
|
|
343 | while (wrk_first.next != &wrk_first) |
242 | { |
344 | { |
243 | int old_len = grp->size; |
345 | etp_worker *wrk = wrk_first.next; |
244 | |
346 | |
245 | EIO_FEED (grp); |
347 | if (wrk->req) |
|
|
348 | ETP_DESTROY (wrk->req); |
246 | |
349 | |
247 | /* stop if no progress has been made */ |
350 | etp_worker_clear (wrk); |
248 | if (old_len == grp->size) |
351 | etp_worker_free (wrk); |
249 | { |
|
|
250 | grp->feed = 0; |
|
|
251 | break; |
|
|
252 | } |
|
|
253 | } |
|
|
254 | } |
|
|
255 | |
|
|
256 | static int eio_finish (eio_req *req); |
|
|
257 | |
|
|
258 | static int grp_dec (eio_req *grp) |
|
|
259 | { |
|
|
260 | --grp->size; |
|
|
261 | |
|
|
262 | /* call feeder, if applicable */ |
|
|
263 | grp_try_feed (grp); |
|
|
264 | |
|
|
265 | /* finish, if done */ |
|
|
266 | if (!grp->size && grp->int1) |
|
|
267 | return eio_finish (grp); |
|
|
268 | else |
|
|
269 | return 0; |
|
|
270 | } |
|
|
271 | |
|
|
272 | void eio_destroy (eio_req *req) |
|
|
273 | { |
|
|
274 | if ((req)->flags & EIO_FLAG_PTR1_FREE) free (req->ptr1); |
|
|
275 | if ((req)->flags & EIO_FLAG_PTR2_FREE) free (req->ptr2); |
|
|
276 | |
|
|
277 | EIO_DESTROY (req); |
|
|
278 | } |
|
|
279 | |
|
|
280 | static int eio_finish (eio_req *req) |
|
|
281 | { |
|
|
282 | int res = EIO_FINISH (req); |
|
|
283 | |
|
|
284 | if (req->grp) |
|
|
285 | { |
352 | } |
286 | int res2; |
|
|
287 | eio_req *grp = req->grp; |
|
|
288 | |
353 | |
289 | /* unlink request */ |
354 | started = 0; |
290 | if (req->grp_next) req->grp_next->grp_prev = req->grp_prev; |
355 | idle = 0; |
291 | if (req->grp_prev) req->grp_prev->grp_next = req->grp_next; |
356 | nreqs = 0; |
|
|
357 | nready = 0; |
|
|
358 | npending = 0; |
292 | |
359 | |
293 | if (grp->grp_first == req) |
360 | etp_atfork_parent (); |
294 | grp->grp_first = req->grp_next; |
|
|
295 | |
|
|
296 | res2 = grp_dec (grp); |
|
|
297 | |
|
|
298 | if (!res && res2) |
|
|
299 | res = res2; |
|
|
300 | } |
|
|
301 | |
|
|
302 | eio_destroy (req); |
|
|
303 | |
|
|
304 | return res; |
|
|
305 | } |
361 | } |
306 | |
362 | |
307 | void eio_grp_cancel (eio_req *grp) |
363 | static void |
308 | { |
364 | etp_once_init (void) |
309 | for (grp = grp->grp_first; grp; grp = grp->grp_next) |
365 | { |
310 | eio_cancel (grp); |
366 | X_THREAD_ATFORK (etp_atfork_prepare, etp_atfork_parent, etp_atfork_child); |
311 | } |
367 | } |
312 | |
368 | |
313 | void eio_cancel (eio_req *req) |
369 | static int |
|
|
370 | etp_init (void (*want_poll)(void), void (*done_poll)(void)) |
314 | { |
371 | { |
315 | X_LOCK (wrklock); |
372 | static pthread_once_t doinit = PTHREAD_ONCE_INIT; |
316 | req->flags |= EIO_FLAG_CANCELLED; |
|
|
317 | X_UNLOCK (wrklock); |
|
|
318 | |
373 | |
319 | eio_grp_cancel (req); |
374 | pthread_once (&doinit, etp_once_init); |
320 | } |
|
|
321 | |
375 | |
|
|
376 | want_poll_cb = want_poll; |
|
|
377 | done_poll_cb = done_poll; |
|
|
378 | } |
|
|
379 | |
322 | X_THREAD_PROC (eio_proc); |
380 | X_THREAD_PROC (etp_proc); |
323 | |
381 | |
324 | static void start_thread (void) |
382 | static void etp_start_thread (void) |
325 | { |
383 | { |
326 | worker *wrk = calloc (1, sizeof (worker)); |
384 | etp_worker *wrk = calloc (1, sizeof (etp_worker)); |
327 | |
385 | |
328 | /*TODO*/ |
386 | /*TODO*/ |
329 | assert (("unable to allocate worker thread data", wrk)); |
387 | assert (("unable to allocate worker thread data", wrk)); |
330 | |
388 | |
331 | X_LOCK (wrklock); |
389 | X_LOCK (wrklock); |
332 | |
390 | |
333 | if (thread_create (&wrk->tid, eio_proc, (void *)wrk)) |
391 | if (thread_create (&wrk->tid, etp_proc, (void *)wrk)) |
334 | { |
392 | { |
335 | wrk->prev = &wrk_first; |
393 | wrk->prev = &wrk_first; |
336 | wrk->next = wrk_first.next; |
394 | wrk->next = wrk_first.next; |
337 | wrk_first.next->prev = wrk; |
395 | wrk_first.next->prev = wrk; |
338 | wrk_first.next = wrk; |
396 | wrk_first.next = wrk; |
… | |
… | |
342 | free (wrk); |
400 | free (wrk); |
343 | |
401 | |
344 | X_UNLOCK (wrklock); |
402 | X_UNLOCK (wrklock); |
345 | } |
403 | } |
346 | |
404 | |
347 | static void maybe_start_thread (void) |
405 | static void etp_maybe_start_thread (void) |
348 | { |
406 | { |
349 | if (eio_nthreads () >= wanted) |
407 | if (etp_nthreads () >= wanted) |
350 | return; |
408 | return; |
351 | |
409 | |
352 | /* todo: maybe use idle here, but might be less exact */ |
410 | /* todo: maybe use idle here, but might be less exact */ |
353 | if (0 <= (int)eio_nthreads () + (int)eio_npending () - (int)eio_nreqs ()) |
411 | if (0 <= (int)etp_nthreads () + (int)etp_npending () - (int)etp_nreqs ()) |
354 | return; |
412 | return; |
355 | |
413 | |
356 | start_thread (); |
414 | etp_start_thread (); |
357 | } |
415 | } |
358 | |
416 | |
359 | void eio_submit (eio_req *req) |
|
|
360 | { |
|
|
361 | req->pri += EIO_PRI_BIAS; |
|
|
362 | |
|
|
363 | if (req->pri < EIO_PRI_MIN + EIO_PRI_BIAS) req->pri = EIO_PRI_MIN + EIO_PRI_BIAS; |
|
|
364 | if (req->pri > EIO_PRI_MAX + EIO_PRI_BIAS) req->pri = EIO_PRI_MAX + EIO_PRI_BIAS; |
|
|
365 | |
|
|
366 | ++nreqs; |
|
|
367 | |
|
|
368 | X_LOCK (reqlock); |
|
|
369 | ++nready; |
|
|
370 | reqq_push (&req_queue, req); |
|
|
371 | X_COND_SIGNAL (reqwait); |
|
|
372 | X_UNLOCK (reqlock); |
|
|
373 | |
|
|
374 | maybe_start_thread (); |
|
|
375 | } |
|
|
376 | |
|
|
377 | static void end_thread (void) |
417 | static void etp_end_thread (void) |
378 | { |
418 | { |
379 | eio_req *req = calloc (1, sizeof (eio_req)); |
419 | eio_req *req = calloc (1, sizeof (eio_req)); |
380 | |
420 | |
381 | req->type = EIO_QUIT; |
421 | req->type = -1; |
382 | req->pri = EIO_PRI_MAX + EIO_PRI_BIAS; |
422 | req->pri = ETP_PRI_MAX - ETP_PRI_MIN; |
383 | |
423 | |
384 | X_LOCK (reqlock); |
424 | X_LOCK (reqlock); |
385 | reqq_push (&req_queue, req); |
425 | reqq_push (&req_queue, req); |
386 | X_COND_SIGNAL (reqwait); |
426 | X_COND_SIGNAL (reqwait); |
387 | X_UNLOCK (reqlock); |
427 | X_UNLOCK (reqlock); |
… | |
… | |
389 | X_LOCK (wrklock); |
429 | X_LOCK (wrklock); |
390 | --started; |
430 | --started; |
391 | X_UNLOCK (wrklock); |
431 | X_UNLOCK (wrklock); |
392 | } |
432 | } |
393 | |
433 | |
394 | void eio_set_max_poll_time (double nseconds) |
|
|
395 | { |
|
|
396 | if (WORDACCESS_UNSAFE) X_LOCK (reqlock); |
|
|
397 | max_poll_time = nseconds; |
|
|
398 | if (WORDACCESS_UNSAFE) X_UNLOCK (reqlock); |
|
|
399 | } |
|
|
400 | |
|
|
401 | void eio_set_max_poll_reqs (unsigned int maxreqs) |
|
|
402 | { |
|
|
403 | if (WORDACCESS_UNSAFE) X_LOCK (reqlock); |
|
|
404 | max_poll_reqs = maxreqs; |
|
|
405 | if (WORDACCESS_UNSAFE) X_UNLOCK (reqlock); |
|
|
406 | } |
|
|
407 | |
|
|
408 | void eio_set_max_idle (unsigned int nthreads) |
|
|
409 | { |
|
|
410 | if (WORDACCESS_UNSAFE) X_LOCK (reqlock); |
|
|
411 | max_idle = nthreads <= 0 ? 1 : nthreads; |
|
|
412 | if (WORDACCESS_UNSAFE) X_UNLOCK (reqlock); |
|
|
413 | } |
|
|
414 | |
|
|
415 | void eio_set_min_parallel (unsigned int nthreads) |
|
|
416 | { |
|
|
417 | if (wanted < nthreads) |
|
|
418 | wanted = nthreads; |
|
|
419 | } |
|
|
420 | |
|
|
421 | void eio_set_max_parallel (unsigned int nthreads) |
|
|
422 | { |
|
|
423 | if (wanted > nthreads) |
|
|
424 | wanted = nthreads; |
|
|
425 | |
|
|
426 | while (started > wanted) |
|
|
427 | end_thread (); |
|
|
428 | } |
|
|
429 | |
|
|
430 | int eio_poll (void) |
434 | static int etp_poll (void) |
431 | { |
435 | { |
432 | int maxreqs = max_poll_reqs; |
436 | unsigned int maxreqs; |
|
|
437 | unsigned int maxtime; |
433 | struct timeval tv_start, tv_now; |
438 | struct timeval tv_start, tv_now; |
434 | eio_req *req; |
|
|
435 | |
439 | |
|
|
440 | X_LOCK (reslock); |
|
|
441 | maxreqs = max_poll_reqs; |
|
|
442 | maxtime = max_poll_time; |
|
|
443 | X_UNLOCK (reslock); |
|
|
444 | |
436 | if (max_poll_time) |
445 | if (maxtime) |
437 | gettimeofday (&tv_start, 0); |
446 | gettimeofday (&tv_start, 0); |
438 | |
447 | |
439 | for (;;) |
448 | for (;;) |
440 | { |
449 | { |
|
|
450 | ETP_REQ *req; |
|
|
451 | |
441 | maybe_start_thread (); |
452 | etp_maybe_start_thread (); |
442 | |
453 | |
443 | X_LOCK (reslock); |
454 | X_LOCK (reslock); |
444 | req = reqq_shift (&res_queue); |
455 | req = reqq_shift (&res_queue); |
445 | |
456 | |
446 | if (req) |
457 | if (req) |
… | |
… | |
454 | X_UNLOCK (reslock); |
465 | X_UNLOCK (reslock); |
455 | |
466 | |
456 | if (!req) |
467 | if (!req) |
457 | return 0; |
468 | return 0; |
458 | |
469 | |
|
|
470 | X_LOCK (reqlock); |
459 | --nreqs; |
471 | --nreqs; |
|
|
472 | X_UNLOCK (reqlock); |
460 | |
473 | |
461 | if (req->type == EIO_GROUP && req->size) |
474 | if (req->type == EIO_GROUP && req->size) |
462 | { |
475 | { |
463 | req->int1 = 1; /* mark request as delayed */ |
476 | req->int1 = 1; /* mark request as delayed */ |
464 | continue; |
477 | continue; |
465 | } |
478 | } |
466 | else |
479 | else |
467 | { |
480 | { |
468 | int res = eio_finish (req); |
481 | int res = ETP_FINISH (req); |
469 | if (res) |
482 | if (res) |
470 | return res; |
483 | return res; |
471 | } |
484 | } |
472 | |
485 | |
473 | if (maxreqs && !--maxreqs) |
486 | if (maxreqs && !--maxreqs) |
474 | break; |
487 | break; |
475 | |
488 | |
476 | if (max_poll_time) |
489 | if (maxtime) |
477 | { |
490 | { |
478 | gettimeofday (&tv_now, 0); |
491 | gettimeofday (&tv_now, 0); |
479 | |
492 | |
480 | if (tvdiff (&tv_start, &tv_now) >= max_poll_time) |
493 | if (tvdiff (&tv_start, &tv_now) >= maxtime) |
481 | break; |
494 | break; |
482 | } |
495 | } |
483 | } |
496 | } |
484 | |
497 | |
485 | errno = EAGAIN; |
498 | errno = EAGAIN; |
486 | return -1; |
499 | return -1; |
|
|
500 | } |
|
|
501 | |
|
|
502 | static void etp_cancel (ETP_REQ *req) |
|
|
503 | { |
|
|
504 | X_LOCK (wrklock); |
|
|
505 | req->flags |= EIO_FLAG_CANCELLED; |
|
|
506 | X_UNLOCK (wrklock); |
|
|
507 | |
|
|
508 | eio_grp_cancel (req); |
|
|
509 | } |
|
|
510 | |
|
|
511 | static void etp_submit (ETP_REQ *req) |
|
|
512 | { |
|
|
513 | req->pri -= ETP_PRI_MIN; |
|
|
514 | |
|
|
515 | if (req->pri < ETP_PRI_MIN - ETP_PRI_MIN) req->pri = ETP_PRI_MIN - ETP_PRI_MIN; |
|
|
516 | if (req->pri > ETP_PRI_MAX - ETP_PRI_MIN) req->pri = ETP_PRI_MAX - ETP_PRI_MIN; |
|
|
517 | |
|
|
518 | X_LOCK (reqlock); |
|
|
519 | ++nreqs; |
|
|
520 | ++nready; |
|
|
521 | reqq_push (&req_queue, req); |
|
|
522 | X_COND_SIGNAL (reqwait); |
|
|
523 | X_UNLOCK (reqlock); |
|
|
524 | |
|
|
525 | etp_maybe_start_thread (); |
|
|
526 | } |
|
|
527 | |
|
|
528 | static void etp_set_max_poll_time (double nseconds) |
|
|
529 | { |
|
|
530 | if (WORDACCESS_UNSAFE) X_LOCK (reslock); |
|
|
531 | max_poll_time = nseconds; |
|
|
532 | if (WORDACCESS_UNSAFE) X_UNLOCK (reslock); |
|
|
533 | } |
|
|
534 | |
|
|
535 | static void etp_set_max_poll_reqs (unsigned int maxreqs) |
|
|
536 | { |
|
|
537 | if (WORDACCESS_UNSAFE) X_LOCK (reslock); |
|
|
538 | max_poll_reqs = maxreqs; |
|
|
539 | if (WORDACCESS_UNSAFE) X_UNLOCK (reslock); |
|
|
540 | } |
|
|
541 | |
|
|
542 | static void etp_set_max_idle (unsigned int nthreads) |
|
|
543 | { |
|
|
544 | if (WORDACCESS_UNSAFE) X_LOCK (reqlock); |
|
|
545 | max_idle = nthreads <= 0 ? 1 : nthreads; |
|
|
546 | if (WORDACCESS_UNSAFE) X_UNLOCK (reqlock); |
|
|
547 | } |
|
|
548 | |
|
|
549 | static void etp_set_min_parallel (unsigned int nthreads) |
|
|
550 | { |
|
|
551 | if (wanted < nthreads) |
|
|
552 | wanted = nthreads; |
|
|
553 | } |
|
|
554 | |
|
|
555 | static void etp_set_max_parallel (unsigned int nthreads) |
|
|
556 | { |
|
|
557 | if (wanted > nthreads) |
|
|
558 | wanted = nthreads; |
|
|
559 | |
|
|
560 | while (started > wanted) |
|
|
561 | etp_end_thread (); |
|
|
562 | } |
|
|
563 | |
|
|
564 | /*****************************************************************************/ |
|
|
565 | |
|
|
566 | static void grp_try_feed (eio_req *grp) |
|
|
567 | { |
|
|
568 | while (grp->size < grp->int2 && !EIO_CANCELLED (grp)) |
|
|
569 | { |
|
|
570 | int old_len = grp->size; |
|
|
571 | |
|
|
572 | EIO_FEED (grp); |
|
|
573 | |
|
|
574 | /* stop if no progress has been made */ |
|
|
575 | if (old_len == grp->size) |
|
|
576 | { |
|
|
577 | grp->feed = 0; |
|
|
578 | break; |
|
|
579 | } |
|
|
580 | } |
|
|
581 | } |
|
|
582 | |
|
|
583 | static int grp_dec (eio_req *grp) |
|
|
584 | { |
|
|
585 | --grp->size; |
|
|
586 | |
|
|
587 | /* call feeder, if applicable */ |
|
|
588 | grp_try_feed (grp); |
|
|
589 | |
|
|
590 | /* finish, if done */ |
|
|
591 | if (!grp->size && grp->int1) |
|
|
592 | return eio_finish (grp); |
|
|
593 | else |
|
|
594 | return 0; |
|
|
595 | } |
|
|
596 | |
|
|
597 | void eio_destroy (eio_req *req) |
|
|
598 | { |
|
|
599 | if ((req)->flags & EIO_FLAG_PTR1_FREE) free (req->ptr1); |
|
|
600 | if ((req)->flags & EIO_FLAG_PTR2_FREE) free (req->ptr2); |
|
|
601 | |
|
|
602 | EIO_DESTROY (req); |
|
|
603 | } |
|
|
604 | |
|
|
605 | static int eio_finish (eio_req *req) |
|
|
606 | { |
|
|
607 | int res = EIO_FINISH (req); |
|
|
608 | |
|
|
609 | if (req->grp) |
|
|
610 | { |
|
|
611 | int res2; |
|
|
612 | eio_req *grp = req->grp; |
|
|
613 | |
|
|
614 | /* unlink request */ |
|
|
615 | if (req->grp_next) req->grp_next->grp_prev = req->grp_prev; |
|
|
616 | if (req->grp_prev) req->grp_prev->grp_next = req->grp_next; |
|
|
617 | |
|
|
618 | if (grp->grp_first == req) |
|
|
619 | grp->grp_first = req->grp_next; |
|
|
620 | |
|
|
621 | res2 = grp_dec (grp); |
|
|
622 | |
|
|
623 | if (!res && res2) |
|
|
624 | res = res2; |
|
|
625 | } |
|
|
626 | |
|
|
627 | eio_destroy (req); |
|
|
628 | |
|
|
629 | return res; |
|
|
630 | } |
|
|
631 | |
|
|
632 | void eio_grp_cancel (eio_req *grp) |
|
|
633 | { |
|
|
634 | for (grp = grp->grp_first; grp; grp = grp->grp_next) |
|
|
635 | eio_cancel (grp); |
|
|
636 | } |
|
|
637 | |
|
|
638 | void eio_cancel (eio_req *req) |
|
|
639 | { |
|
|
640 | etp_cancel (req); |
|
|
641 | } |
|
|
642 | |
|
|
643 | void eio_submit (eio_req *req) |
|
|
644 | { |
|
|
645 | etp_submit (req); |
|
|
646 | } |
|
|
647 | |
|
|
648 | unsigned int eio_nreqs (void) |
|
|
649 | { |
|
|
650 | return etp_nreqs (); |
|
|
651 | } |
|
|
652 | |
|
|
653 | unsigned int eio_nready (void) |
|
|
654 | { |
|
|
655 | return etp_nready (); |
|
|
656 | } |
|
|
657 | |
|
|
658 | unsigned int eio_npending (void) |
|
|
659 | { |
|
|
660 | return etp_npending (); |
|
|
661 | } |
|
|
662 | |
|
|
663 | unsigned int eio_nthreads (void) |
|
|
664 | { |
|
|
665 | return etp_nthreads (); |
|
|
666 | } |
|
|
667 | |
|
|
668 | void eio_set_max_poll_time (double nseconds) |
|
|
669 | { |
|
|
670 | etp_set_max_poll_time (nseconds); |
|
|
671 | } |
|
|
672 | |
|
|
673 | void eio_set_max_poll_reqs (unsigned int maxreqs) |
|
|
674 | { |
|
|
675 | etp_set_max_poll_reqs (maxreqs); |
|
|
676 | } |
|
|
677 | |
|
|
678 | void eio_set_max_idle (unsigned int nthreads) |
|
|
679 | { |
|
|
680 | etp_set_max_idle (nthreads); |
|
|
681 | } |
|
|
682 | |
|
|
683 | void eio_set_min_parallel (unsigned int nthreads) |
|
|
684 | { |
|
|
685 | etp_set_min_parallel (nthreads); |
|
|
686 | } |
|
|
687 | |
|
|
688 | void eio_set_max_parallel (unsigned int nthreads) |
|
|
689 | { |
|
|
690 | etp_set_max_parallel (nthreads); |
|
|
691 | } |
|
|
692 | |
|
|
693 | int eio_poll (void) |
|
|
694 | { |
|
|
695 | return etp_poll (); |
487 | } |
696 | } |
488 | |
697 | |
489 | /*****************************************************************************/ |
698 | /*****************************************************************************/ |
490 | /* work around various missing functions */ |
699 | /* work around various missing functions */ |
491 | |
700 | |
… | |
… | |
621 | } |
830 | } |
622 | #endif |
831 | #endif |
623 | |
832 | |
624 | /* sendfile always needs emulation */ |
833 | /* sendfile always needs emulation */ |
625 | static ssize_t |
834 | static ssize_t |
626 | eio__sendfile (int ofd, int ifd, off_t offset, size_t count, worker *self) |
835 | eio__sendfile (int ofd, int ifd, off_t offset, size_t count, etp_worker *self) |
627 | { |
836 | { |
628 | ssize_t res; |
837 | ssize_t res; |
629 | |
838 | |
630 | if (!count) |
839 | if (!count) |
631 | return 0; |
840 | return 0; |
… | |
… | |
715 | return res; |
924 | return res; |
716 | } |
925 | } |
717 | |
926 | |
718 | /* read a full directory */ |
927 | /* read a full directory */ |
719 | static void |
928 | static void |
720 | eio__scandir (eio_req *req, worker *self) |
929 | eio__scandir (eio_req *req, etp_worker *self) |
721 | { |
930 | { |
722 | DIR *dirp; |
931 | DIR *dirp; |
723 | union |
932 | union |
724 | { |
933 | { |
725 | EIO_STRUCT_DIRENT d; |
934 | EIO_STRUCT_DIRENT d; |
… | |
… | |
792 | req->result = -1; \ |
1001 | req->result = -1; \ |
793 | break; \ |
1002 | break; \ |
794 | } \ |
1003 | } \ |
795 | } |
1004 | } |
796 | |
1005 | |
797 | X_THREAD_PROC (eio_proc) |
1006 | X_THREAD_PROC (etp_proc) |
798 | { |
1007 | { |
799 | eio_req *req; |
1008 | ETP_REQ *req; |
800 | struct timespec ts; |
1009 | struct timespec ts; |
801 | worker *self = (worker *)thr_arg; |
1010 | etp_worker *self = (etp_worker *)thr_arg; |
802 | |
1011 | |
803 | /* try to distribute timeouts somewhat randomly */ |
1012 | /* try to distribute timeouts somewhat randomly */ |
804 | ts.tv_nsec = ((unsigned long)self & 1023UL) * (1000000000UL / 1024UL); |
1013 | ts.tv_nsec = ((unsigned long)self & 1023UL) * (1000000000UL / 1024UL); |
805 | |
1014 | |
806 | for (;;) |
1015 | for (;;) |
807 | { |
1016 | { |
808 | ts.tv_sec = time (0) + IDLE_TIMEOUT; |
|
|
809 | |
|
|
810 | X_LOCK (reqlock); |
1017 | X_LOCK (reqlock); |
811 | |
1018 | |
812 | for (;;) |
1019 | for (;;) |
813 | { |
1020 | { |
814 | self->req = req = reqq_shift (&req_queue); |
1021 | self->req = req = reqq_shift (&req_queue); |
… | |
… | |
816 | if (req) |
1023 | if (req) |
817 | break; |
1024 | break; |
818 | |
1025 | |
819 | ++idle; |
1026 | ++idle; |
820 | |
1027 | |
|
|
1028 | ts.tv_sec = time (0) + IDLE_TIMEOUT; |
821 | if (X_COND_TIMEDWAIT (reqwait, reqlock, ts) == ETIMEDOUT) |
1029 | if (X_COND_TIMEDWAIT (reqwait, reqlock, ts) == ETIMEDOUT) |
822 | { |
1030 | { |
823 | if (idle > max_idle) |
1031 | if (idle > max_idle) |
824 | { |
1032 | { |
825 | --idle; |
1033 | --idle; |
… | |
… | |
830 | goto quit; |
1038 | goto quit; |
831 | } |
1039 | } |
832 | |
1040 | |
833 | /* we are allowed to idle, so do so without any timeout */ |
1041 | /* we are allowed to idle, so do so without any timeout */ |
834 | X_COND_WAIT (reqwait, reqlock); |
1042 | X_COND_WAIT (reqwait, reqlock); |
835 | ts.tv_sec = time (0) + IDLE_TIMEOUT; |
|
|
836 | } |
1043 | } |
837 | |
1044 | |
838 | --idle; |
1045 | --idle; |
839 | } |
1046 | } |
840 | |
1047 | |
… | |
… | |
934 | case EIO_GROUP: |
1141 | case EIO_GROUP: |
935 | case EIO_NOP: |
1142 | case EIO_NOP: |
936 | req->result = 0; |
1143 | req->result = 0; |
937 | break; |
1144 | break; |
938 | |
1145 | |
939 | case EIO_QUIT: |
1146 | case -1: |
940 | goto quit; |
1147 | goto quit; |
941 | |
1148 | |
942 | default: |
1149 | default: |
943 | req->result = -1; |
1150 | req->result = -1; |
944 | break; |
1151 | break; |
… | |
… | |
952 | |
1159 | |
953 | if (!reqq_push (&res_queue, req) && want_poll_cb) |
1160 | if (!reqq_push (&res_queue, req) && want_poll_cb) |
954 | want_poll_cb (); |
1161 | want_poll_cb (); |
955 | |
1162 | |
956 | self->req = 0; |
1163 | self->req = 0; |
957 | worker_clear (self); |
1164 | etp_worker_clear (self); |
958 | |
1165 | |
959 | X_UNLOCK (reslock); |
1166 | X_UNLOCK (reslock); |
960 | } |
1167 | } |
961 | |
1168 | |
962 | quit: |
1169 | quit: |
963 | X_LOCK (wrklock); |
1170 | X_LOCK (wrklock); |
964 | worker_free (self); |
1171 | etp_worker_free (self); |
965 | X_UNLOCK (wrklock); |
1172 | X_UNLOCK (wrklock); |
966 | |
1173 | |
967 | return 0; |
1174 | return 0; |
968 | } |
1175 | } |
969 | |
1176 | |
970 | /*****************************************************************************/ |
1177 | /*****************************************************************************/ |
971 | |
1178 | |
972 | static void eio_atfork_prepare (void) |
|
|
973 | { |
|
|
974 | X_LOCK (wrklock); |
|
|
975 | X_LOCK (reqlock); |
|
|
976 | X_LOCK (reslock); |
|
|
977 | #if !HAVE_PREADWRITE |
|
|
978 | X_LOCK (preadwritelock); |
|
|
979 | #endif |
|
|
980 | #if !HAVE_READDIR_R |
|
|
981 | X_LOCK (readdirlock); |
|
|
982 | #endif |
|
|
983 | } |
|
|
984 | |
|
|
985 | static void eio_atfork_parent (void) |
|
|
986 | { |
|
|
987 | #if !HAVE_READDIR_R |
|
|
988 | X_UNLOCK (readdirlock); |
|
|
989 | #endif |
|
|
990 | #if !HAVE_PREADWRITE |
|
|
991 | X_UNLOCK (preadwritelock); |
|
|
992 | #endif |
|
|
993 | X_UNLOCK (reslock); |
|
|
994 | X_UNLOCK (reqlock); |
|
|
995 | X_UNLOCK (wrklock); |
|
|
996 | } |
|
|
997 | |
|
|
998 | static void eio_atfork_child (void) |
|
|
999 | { |
|
|
1000 | eio_req *prv; |
|
|
1001 | |
|
|
1002 | while (prv = reqq_shift (&req_queue)) |
|
|
1003 | eio_destroy (prv); |
|
|
1004 | |
|
|
1005 | while (prv = reqq_shift (&res_queue)) |
|
|
1006 | eio_destroy (prv); |
|
|
1007 | |
|
|
1008 | while (wrk_first.next != &wrk_first) |
|
|
1009 | { |
|
|
1010 | worker *wrk = wrk_first.next; |
|
|
1011 | |
|
|
1012 | if (wrk->req) |
|
|
1013 | eio_destroy (wrk->req); |
|
|
1014 | |
|
|
1015 | worker_clear (wrk); |
|
|
1016 | worker_free (wrk); |
|
|
1017 | } |
|
|
1018 | |
|
|
1019 | started = 0; |
|
|
1020 | idle = 0; |
|
|
1021 | nreqs = 0; |
|
|
1022 | nready = 0; |
|
|
1023 | npending = 0; |
|
|
1024 | |
|
|
1025 | eio_atfork_parent (); |
|
|
1026 | } |
|
|
1027 | |
|
|
1028 | int eio_init (void (*want_poll)(void), void (*done_poll)(void)) |
1179 | int eio_init (void (*want_poll)(void), void (*done_poll)(void)) |
1029 | { |
1180 | { |
1030 | want_poll_cb = want_poll; |
1181 | etp_init (want_poll, done_poll); |
1031 | done_poll_cb = done_poll; |
|
|
1032 | |
|
|
1033 | #ifdef _WIN32 |
|
|
1034 | X_MUTEX_CHECK (wrklock); |
|
|
1035 | X_MUTEX_CHECK (reslock); |
|
|
1036 | X_MUTEX_CHECK (reqlock); |
|
|
1037 | X_MUTEX_CHECK (reqwait); |
|
|
1038 | X_MUTEX_CHECK (preadwritelock); |
|
|
1039 | X_MUTEX_CHECK (readdirlock); |
|
|
1040 | |
|
|
1041 | X_COND_CHECK (reqwait); |
|
|
1042 | #endif |
|
|
1043 | |
|
|
1044 | X_THREAD_ATFORK (eio_atfork_prepare, eio_atfork_parent, eio_atfork_child); |
|
|
1045 | } |
1182 | } |
1046 | |
1183 | |
1047 | static void eio_api_destroy (eio_req *req) |
1184 | static void eio_api_destroy (eio_req *req) |
1048 | { |
1185 | { |
1049 | free (req); |
1186 | free (req); |
… | |
… | |
1307 | /*****************************************************************************/ |
1444 | /*****************************************************************************/ |
1308 | /* misc garbage */ |
1445 | /* misc garbage */ |
1309 | |
1446 | |
1310 | ssize_t eio_sendfile_sync (int ofd, int ifd, off_t offset, size_t count) |
1447 | ssize_t eio_sendfile_sync (int ofd, int ifd, off_t offset, size_t count) |
1311 | { |
1448 | { |
1312 | worker wrk; |
1449 | etp_worker wrk; |
1313 | |
1450 | |
1314 | wrk.dbuf = 0; |
1451 | wrk.dbuf = 0; |
1315 | |
1452 | |
1316 | eio__sendfile (ofd, ifd, offset, count, &wrk); |
1453 | eio__sendfile (ofd, ifd, offset, count, &wrk); |
1317 | |
1454 | |