ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Linux-AIO/AIO.xs
(Generate patch)

Comparing Linux-AIO/AIO.xs (file contents):
Revision 1.21 by root, Fri Aug 6 17:18:08 2004 UTC vs.
Revision 1.22 by root, Wed Jun 29 15:22:36 2005 UTC

13 13
14typedef void *InputStream; /* hack, but 5.6.1 is simply toooo old ;) */ 14typedef void *InputStream; /* hack, but 5.6.1 is simply toooo old ;) */
15typedef void *OutputStream; /* hack, but 5.6.1 is simply toooo old ;) */ 15typedef void *OutputStream; /* hack, but 5.6.1 is simply toooo old ;) */
16typedef void *InOutStream; /* hack, but 5.6.1 is simply toooo old ;) */ 16typedef void *InOutStream; /* hack, but 5.6.1 is simply toooo old ;) */
17 17
18#define STACKSIZE 1024 /* yeah */ 18#define STACKSIZE (128 * sizeof (long)) /* yeah */
19 19
20enum { 20enum {
21 REQ_QUIT, 21 REQ_QUIT,
22 REQ_OPEN, REQ_CLOSE, REQ_READ, REQ_WRITE, 22 REQ_OPEN, REQ_CLOSE, REQ_READ, REQ_WRITE,
23 REQ_STAT, REQ_LSTAT, REQ_FSTAT, REQ_UNLINK 23 REQ_STAT, REQ_LSTAT, REQ_FSTAT, REQ_UNLINK
62 aio_thread *thr; 62 aio_thread *thr;
63 63
64 New (0, thr, 1, aio_thread); 64 New (0, thr, 1, aio_thread);
65 65
66 if (clone (aio_proc, 66 if (clone (aio_proc,
67 &(thr->stack[STACKSIZE]), 67 &(thr->stack[STACKSIZE - sizeof (long)]),
68 CLONE_VM|CLONE_FS|CLONE_FILES, 68 CLONE_VM|CLONE_FS|CLONE_FILES,
69 thr) >= 0) 69 thr) >= 0)
70 started++; 70 started++;
71 else 71 else
72 Safefree (thr); 72 Safefree (thr);
88{ 88{
89 nreqs++; 89 nreqs++;
90 req->next = 0; 90 req->next = 0;
91 91
92 if (qe) 92 if (qe)
93 {
93 qe->next = req; 94 qe->next = req;
95 qe = req;
96 }
94 else 97 else
95 qe = qs = req; 98 qe = qs = req;
96 99
97 send_reqs (); 100 send_reqs ();
98} 101}
154 req->callback = SvREFCNT_inc (callback); 157 req->callback = SvREFCNT_inc (callback);
155 158
156 send_req (req); 159 send_req (req);
157} 160}
158 161
162static void
163poll_wait ()
164{
165 fd_set rfd;
166 FD_ZERO(&rfd);
167 FD_SET(respipe[0], &rfd);
168
169 select (respipe[0] + 1, &rfd, 0, 0, 0);
170}
171
159static int 172static int
160poll_cb (pTHX) 173poll_cb (pTHX)
161{ 174{
162 dSP; 175 dSP;
163 int count = 0; 176 int count = 0;
164 aio_req req; 177 aio_req req;
165 178
166 while (read (respipe[0], (void *)&req, sizeof (req)) == sizeof (req)) 179 while (read (respipe[0], (void *)&req, sizeof (req)) == sizeof (req))
167 { 180 {
181 nreqs--;
182
168 if (req->type == REQ_QUIT) 183 if (req->type == REQ_QUIT)
169 { 184 {
170 Safefree (req->thread); 185 Safefree (req->thread);
171 started--; 186 started--;
172 } 187 }
199 214
200 if (req->callback) 215 if (req->callback)
201 SvREFCNT_dec (req->callback); 216 SvREFCNT_dec (req->callback);
202 217
203 errno = errorno; 218 errno = errorno;
204 nreqs--;
205 count++; 219 count++;
206 } 220 }
207 221
208 Safefree (req); 222 Safefree (req);
209 } 223 }
361 cur--; 375 cur--;
362 } 376 }
363 377
364 while (started > nthreads) 378 while (started > nthreads)
365 { 379 {
366 fd_set rfd; 380 poll_wait ();
367 FD_ZERO(&rfd);
368 FD_SET(respipe[0], &rfd);
369
370 select (respipe[0] + 1, &rfd, 0, 0, 0);
371 poll_cb (aTHX); 381 poll_cb (aTHX);
372 } 382 }
373 383
374void 384void
375aio_open(pathname,flags,mode,callback) 385aio_open(pathname,flags,mode,callback)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines