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.8 by root, Thu Aug 16 02:43:46 2001 UTC vs.
Revision 1.10 by root, Thu Aug 30 03:11:06 2001 UTC

8#include <signal.h> 8#include <signal.h>
9#include <sched.h> 9#include <sched.h>
10 10
11#define STACKSIZE 1024 /* yeah */ 11#define STACKSIZE 1024 /* yeah */
12 12
13enum { REQ_QUIT, REQ_READ, REQ_WRITE, REQ_OPEN }; 13enum { REQ_QUIT, REQ_READ, REQ_WRITE, REQ_OPEN, REQ_CLOSE };
14 14
15typedef struct { 15typedef struct {
16 char stack[STACKSIZE]; 16 char stack[STACKSIZE];
17} aio_thread; 17} aio_thread;
18 18
167 167
168static int 168static int
169aio_proc(void *thr_arg) 169aio_proc(void *thr_arg)
170{ 170{
171 aio_thread *thr = thr_arg; 171 aio_thread *thr = thr_arg;
172 int sig; 172 aio_req req;
173 int errno; 173 int errno;
174 aio_req req;
175 174
176 sigprocmask (SIG_SETMASK, &fullsigset, 0); 175 sigprocmask (SIG_SETMASK, &fullsigset, 0);
177 176
178 /* we rely on gcc's ability to create closures. */ 177 /* we rely on gcc's ability to create closures. */
179 _syscall3(int,lseek,int,fd,off_t,offset,int,whence); 178 _syscall3(int,lseek,int,fd,off_t,offset,int,whence);
180 _syscall3(int,read,int,fd,char *,buf,off_t,count); 179 _syscall3(int,read,int,fd,char *,buf,off_t,count);
181 _syscall3(int,write,int,fd,char *,buf,off_t,count); 180 _syscall3(int,write,int,fd,char *,buf,off_t,count);
182 _syscall3(int,open,char *,pathname,int,flags,mode_t,mode); 181 _syscall3(int,open,char *,pathname,int,flags,mode_t,mode);
182 _syscall1(int,close,int,fd);
183 183
184 /* then loop */ 184 /* then loop */
185 while (read (reqpipe[0], (void *)&req, sizeof (req)) == sizeof (req)) 185 while (read (reqpipe[0], (void *)&req, sizeof (req)) == sizeof (req))
186 { 186 {
187 req->thread = thr; 187 req->thread = thr;
199 } 199 }
200 else if (req->type == REQ_OPEN) 200 else if (req->type == REQ_OPEN)
201 { 201 {
202 req->result = open (req->dataptr, req->fd, req->mode); 202 req->result = open (req->dataptr, req->fd, req->mode);
203 } 203 }
204 else if (req->type == REQ_CLOSE)
205 {
206 req->result = close (req->fd);
207 }
204 else 208 else
205 { 209 {
206 write (respipe[1], (void *)&req, sizeof (req)); 210 write (respipe[1], (void *)&req, sizeof (req));
207 break; 211 break;
208 } 212 }
217MODULE = Linux::AIO PACKAGE = Linux::AIO 221MODULE = Linux::AIO PACKAGE = Linux::AIO
218 222
219BOOT: 223BOOT:
220{ 224{
221 sigfillset (&fullsigset); 225 sigfillset (&fullsigset);
226 sigdelset (&fullsigset, SIGTERM);
227 sigdelset (&fullsigset, SIGQUIT);
228 sigdelset (&fullsigset, SIGABRT);
229 sigdelset (&fullsigset, SIGINT);
222 230
223 if (pipe (reqpipe) || pipe (respipe)) 231 if (pipe (reqpipe) || pipe (respipe))
224 croak ("unable to initialize request or result pipe"); 232 croak ("unable to initialize request or result pipe");
225 233
226 if (fcntl (respipe[0], F_SETFL, O_NONBLOCK)) 234 if (fcntl (respipe[0], F_SETFL, O_NONBLOCK))
291 req->mode = mode; 299 req->mode = mode;
292 req->callback = SvREFCNT_inc (callback); 300 req->callback = SvREFCNT_inc (callback);
293 301
294 send_req (req); 302 send_req (req);
295 303
304void
305aio_close(fh,callback)
306 PerlIO * fh
307 SV * callback
308 PROTOTYPE: $
309 CODE:
310 aio_req req;
311
312 New (0, req, 1, aio_cb);
313
314 if (!req)
315 croak ("out of memory during aio_req allocation");
316
317 req->type = REQ_CLOSE;
318 req->fd = PerlIO_fileno (fh);
319 req->callback = SvREFCNT_inc (callback);
320
321 send_req (req);
322
296int 323int
297poll_fileno() 324poll_fileno()
298 PROTOTYPE: 325 PROTOTYPE:
299 CODE: 326 CODE:
300 RETVAL = respipe[0]; 327 RETVAL = respipe[0];

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines