317 |
case DEVICE_TYPE_DISK: |
case DEVICE_TYPE_DISK: |
318 |
|
|
319 |
fns = &disk_fns; |
fns = &disk_fns; |
320 |
/*rw_blocking = False; */ |
rw_blocking = False; |
321 |
break; |
break; |
322 |
|
|
323 |
case DEVICE_TYPE_SCARD: |
case DEVICE_TYPE_SCARD: |
736 |
DEVICE_FNS *fns; |
DEVICE_FNS *fns; |
737 |
struct async_iorequest *iorq; |
struct async_iorequest *iorq; |
738 |
struct async_iorequest *prev; |
struct async_iorequest *prev; |
739 |
|
uint32 req_size = 0; |
740 |
|
|
741 |
if (timed_out) |
if (timed_out) |
742 |
{ |
{ |
748 |
prev = NULL; |
prev = NULL; |
749 |
while (iorq != NULL) |
while (iorq != NULL) |
750 |
{ |
{ |
|
|
|
751 |
if (iorq->fd != 0) |
if (iorq->fd != 0) |
752 |
{ |
{ |
753 |
switch (iorq->major) |
switch (iorq->major) |
758 |
/* Read the data */ |
/* Read the data */ |
759 |
fns = iorq->fns; |
fns = iorq->fns; |
760 |
|
|
761 |
|
req_size = |
762 |
|
(iorq->length - iorq->partial_len) > |
763 |
|
8192 ? 8192 : (iorq->length - |
764 |
|
iorq->partial_len); |
765 |
/* never read larger chunks than 8k - chances are that it will block */ |
/* never read larger chunks than 8k - chances are that it will block */ |
766 |
status = fns->read(iorq->fd, |
status = fns->read(iorq->fd, |
767 |
iorq->buffer + iorq->partial_len, |
iorq->buffer + iorq->partial_len, |
768 |
(iorq->length - |
req_size, 0, &result); |
|
iorq->partial_len) > |
|
|
8192 ? 8192 : (iorq->length - |
|
|
iorq-> |
|
|
partial_len), 0, |
|
|
&result); |
|
769 |
iorq->partial_len += result; |
iorq->partial_len += result; |
770 |
|
|
771 |
#if WITH_DEBUG_RDP5 |
#if WITH_DEBUG_RDP5 |
772 |
DEBUG(("RDPDR: %d bytes of data read\n", result)); |
DEBUG(("RDPDR: %d bytes of data read\n", result)); |
773 |
#endif |
#endif |
774 |
/* only delete link if all data has been transfered */ |
/* only delete link if all data has been transfered */ |
775 |
if (iorq->partial_len == iorq->length) |
/* or if result was 0 and status success - EOF */ |
776 |
|
if ((iorq->partial_len == iorq->length) || |
777 |
|
(result == 0)) |
778 |
{ |
{ |
779 |
|
#if WITH_DEBUG_RDP5 |
780 |
|
DEBUG(("RDPDR: AIO total %u bytes read of %u\n", iorq->partial_len, iorq->length)); |
781 |
|
#endif |
782 |
/* send the data */ |
/* send the data */ |
783 |
status = STATUS_SUCCESS; |
status = STATUS_SUCCESS; |
784 |
rdpdr_send_completion(iorq->device, |
rdpdr_send_completion(iorq->device, |
785 |
iorq->id, status, |
iorq->id, status, |
786 |
iorq->length, |
iorq->partial_len, |
787 |
iorq->buffer, result); |
iorq->buffer, |
788 |
|
iorq->partial_len); |
789 |
xfree(iorq->buffer); |
xfree(iorq->buffer); |
790 |
iorq->fd = 0; |
iorq->fd = 0; |
791 |
if (prev != NULL) |
if (prev != NULL) |
808 |
/* Write data. */ |
/* Write data. */ |
809 |
fns = iorq->fns; |
fns = iorq->fns; |
810 |
|
|
811 |
|
req_size = |
812 |
|
(iorq->length - iorq->partial_len) > |
813 |
|
8192 ? 8192 : (iorq->length - |
814 |
|
iorq->partial_len); |
815 |
|
|
816 |
/* never write larger chunks than 8k - chances are that it will block */ |
/* never write larger chunks than 8k - chances are that it will block */ |
817 |
status = fns->write(iorq->fd, |
status = fns->write(iorq->fd, |
818 |
iorq->buffer + |
iorq->buffer + |
819 |
iorq->partial_len, |
iorq->partial_len, req_size, 0, |
|
(iorq->length - |
|
|
iorq->partial_len) > |
|
|
8192 ? 8192 : (iorq->length - |
|
|
iorq-> |
|
|
partial_len), 0, |
|
820 |
&result); |
&result); |
821 |
iorq->partial_len += result; |
iorq->partial_len += result; |
822 |
#if WITH_DEBUG_RDP5 |
#if WITH_DEBUG_RDP5 |
824 |
result)); |
result)); |
825 |
#endif |
#endif |
826 |
/* only delete link if all data has been transfered */ |
/* only delete link if all data has been transfered */ |
827 |
if (iorq->partial_len == iorq->length) |
/* or we couldn't write */ |
828 |
|
if ((iorq->partial_len == iorq->length) |
829 |
|
|| (result == 0)) |
830 |
{ |
{ |
831 |
|
#if WITH_DEBUG_RDP5 |
832 |
|
DEBUG(("RDPDR: AIO total %u bytes written of %u\n", iorq->partial_len, iorq->length)); |
833 |
|
#endif |
834 |
/* send a status success */ |
/* send a status success */ |
835 |
status = STATUS_SUCCESS; |
status = STATUS_SUCCESS; |
836 |
rdpdr_send_completion(iorq->device, |
rdpdr_send_completion(iorq->device, |
837 |
iorq->id, status, |
iorq->id, status, |
838 |
iorq->length, "", 1); |
iorq->partial_len, "", |
839 |
|
1); |
840 |
|
|
841 |
xfree(iorq->buffer); |
xfree(iorq->buffer); |
842 |
iorq->fd = 0; |
iorq->fd = 0; |