38 |
#include <sys/time.h> |
#include <sys/time.h> |
39 |
#include <dirent.h> /* opendir, closedir, readdir */ |
#include <dirent.h> /* opendir, closedir, readdir */ |
40 |
#include <time.h> |
#include <time.h> |
41 |
|
#include <errno.h> |
42 |
#include "rdesktop.h" |
#include "rdesktop.h" |
43 |
|
|
44 |
#define IRP_MJ_CREATE 0x00 |
#define IRP_MJ_CREATE 0x00 |
61 |
extern DEVICE_FNS parallel_fns; |
extern DEVICE_FNS parallel_fns; |
62 |
extern DEVICE_FNS disk_fns; |
extern DEVICE_FNS disk_fns; |
63 |
extern FILEINFO g_fileinfo[]; |
extern FILEINFO g_fileinfo[]; |
64 |
|
|
65 |
static VCHANNEL *rdpdr_channel; |
static VCHANNEL *rdpdr_channel; |
66 |
|
|
67 |
/* If select() times out, the request for the device with handle g_min_timeout_fd is aborted */ |
/* If select() times out, the request for the device with handle g_min_timeout_fd is aborted */ |
815 |
iorq = g_iorequest; |
iorq = g_iorequest; |
816 |
while (iorq != NULL) |
while (iorq != NULL) |
817 |
{ |
{ |
818 |
/* We need to test that the fd is still valid */ |
if (iorq->fd != 0) |
|
if ((iorq->fd != 0) && (read(iorq->fd, &c, 0) == 0)) |
|
819 |
{ |
{ |
820 |
switch (iorq->major) |
switch (iorq->major) |
821 |
{ |
{ |
822 |
case IRP_MJ_READ: |
case IRP_MJ_READ: |
823 |
|
/* Is this FD valid? FDs will |
824 |
|
be invalid when |
825 |
|
reconnecting. FIXME: Real |
826 |
|
support for reconnects. */ |
827 |
|
|
828 |
|
if ((read(iorq->fd, &c, 0) != 0) && (errno == EBADF)) |
829 |
|
break; |
830 |
|
|
831 |
FD_SET(iorq->fd, rfds); |
FD_SET(iorq->fd, rfds); |
832 |
|
*n = MAX(*n, iorq->fd); |
833 |
|
|
834 |
// Check if io request timeout is smaller than current (but not 0). |
// Check if io request timeout is smaller than current (but not 0). |
835 |
if (iorq->timeout |
if (iorq->timeout |
843 |
tv->tv_usec = (select_timeout % 1000) * 1000; |
tv->tv_usec = (select_timeout % 1000) * 1000; |
844 |
*timeout = True; |
*timeout = True; |
845 |
} |
} |
846 |
|
|
847 |
break; |
break; |
848 |
|
|
849 |
case IRP_MJ_WRITE: |
case IRP_MJ_WRITE: |
850 |
|
/* FD still valid? See above. */ |
851 |
|
if ((write(iorq->fd, &c, 0) != 0) && (errno == EBADF)) |
852 |
|
break; |
853 |
|
|
854 |
FD_SET(iorq->fd, wfds); |
FD_SET(iorq->fd, wfds); |
855 |
|
*n = MAX(*n, iorq->fd); |
856 |
break; |
break; |
857 |
|
|
858 |
} |
} |
859 |
*n = MAX(*n, iorq->fd); |
|
860 |
} |
} |
861 |
|
|
862 |
iorq = iorq->next; |
iorq = iorq->next; |