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

Comparing IO-AIO/AIO.xs (file contents):
Revision 1.57 by root, Mon Oct 23 18:38:15 2006 UTC vs.
Revision 1.58 by root, Mon Oct 23 18:48:08 2006 UTC

83 int type; 83 int type;
84 int fd, fd2; 84 int fd, fd2;
85 int errorno; 85 int errorno;
86 STRLEN dataoffset; 86 STRLEN dataoffset;
87 mode_t mode; /* open */ 87 mode_t mode; /* open */
88 unsigned char pri;
88 unsigned char cancelled; 89 unsigned char flags;
89} aio_cb; 90} aio_cb;
91
92enum {
93 FLAG_CANCELLED = 0x01,
94};
90 95
91typedef aio_cb *aio_req; 96typedef aio_cb *aio_req;
92typedef aio_cb *aio_req_ornot; 97typedef aio_cb *aio_req_ornot;
93 98
94static int started, wanted; 99static int started, wanted;
130 return mg ? (aio_req)mg->mg_ptr : 0; 135 return mg ? (aio_req)mg->mg_ptr : 0;
131} 136}
132 137
133static void aio_grp_feed (aio_req grp) 138static void aio_grp_feed (aio_req grp)
134{ 139{
135 while (grp->length < grp->fd2 && !grp->cancelled) 140 while (grp->length < grp->fd2 && !(grp->flags & FLAG_CANCELLED))
136 { 141 {
137 int old_len = grp->length; 142 int old_len = grp->length;
138 143
139 if (grp->fh2 && SvOK (grp->fh2)) 144 if (grp->fh2 && SvOK (grp->fh2))
140 { 145 {
191static void req_invoke (aio_req req) 196static void req_invoke (aio_req req)
192{ 197{
193 dSP; 198 dSP;
194 int errorno = errno; 199 int errorno = errno;
195 200
196 if (req->cancelled || !SvOK (req->callback)) 201 if (req->flags & FLAG_CANCELLED || !SvOK (req->callback))
197 return; 202 return;
198 203
199 errno = req->errorno; 204 errno = req->errorno;
200 205
201 ENTER; 206 ENTER;
321 Safefree (req); 326 Safefree (req);
322} 327}
323 328
324static void req_cancel (aio_req req) 329static void req_cancel (aio_req req)
325{ 330{
326 req->cancelled = 1; 331 req->flags |= FLAG_CANCELLED;
327 332
328 if (req->type == REQ_GROUP) 333 if (req->type == REQ_GROUP)
329 { 334 {
330 aio_req sub; 335 aio_req sub;
331 336
786 791
787 pthread_mutex_unlock (&reqlock); 792 pthread_mutex_unlock (&reqlock);
788 793
789 errno = 0; /* strictly unnecessary */ 794 errno = 0; /* strictly unnecessary */
790 795
791 if (!req->cancelled) 796 if (!(req->flags & FLAG_CANCELLED))
792 switch (type = req->type) /* remember type for QUIT check */ 797 switch (type = req->type) /* remember type for QUIT check */
793 { 798 {
794 case REQ_READ: req->result = pread (req->fd, req->dataptr, req->length, req->offset); break; 799 case REQ_READ: req->result = pread (req->fd, req->dataptr, req->length, req->offset); break;
795 case REQ_WRITE: req->result = pwrite (req->fd, req->dataptr, req->length, req->offset); break; 800 case REQ_WRITE: req->result = pwrite (req->fd, req->dataptr, req->length, req->offset); break;
796 801

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines