| 1943 | |
| 1944 | |
| 1945 | static bool_t xnet_read(RemoteXdr* xdrs) |
| 1946 | { |
| 1947 | /************************************** |
| 1948 | * |
| 1949 | * x n e t _ r e a d |
| 1950 | * |
| 1951 | ************************************** |
| 1952 | * |
| 1953 | * Functional description |
| 1954 | * Read a buffer full of data. |
| 1955 | * |
| 1956 | **************************************/ |
| 1957 | rem_port* port = xdrs->x_public; |
| 1958 | const bool portServer = (port->port_flags & PORT_server); |
| 1959 | XCC xcc = port->port_xcc; |
| 1960 | XCH xch = xcc->xcc_recv_channel; |
| 1961 | XPM xpm = xcc->xcc_xpm; |
| 1962 | XPS xps = (XPS) xcc->xcc_mapped_addr; |
| 1963 | |
| 1964 | if (xnet_shutdown) |
| 1965 | return FALSE; |
| 1966 | |
| 1967 | if (!SetEvent(xcc->xcc_event_recv_channel_empted)) |
| 1968 | { |
| 1969 | xnet_error(port, isc_net_read_err, ERRNO); |
| 1970 | return FALSE; |
| 1971 | } |
| 1972 | |
| 1973 | while (!xnet_shutdown) |
| 1974 | { |
| 1975 | if (!portServer && (xpm->xpm_flags & XPMF_SERVER_SHUTDOWN)) |
| 1976 | { |
| 1977 | if (!(xcc->xcc_flags & XCCF_SERVER_SHUTDOWN)) |
| 1978 | { |
| 1979 | xcc->xcc_flags |= XCCF_SERVER_SHUTDOWN; |
| 1980 | xnet_error(port, isc_lost_db_connection, 0); |
| 1981 | } |
| 1982 | return FALSE; |
| 1983 | } |
| 1984 | |
| 1985 | const DWORD wait_result = |
| 1986 | WaitForSingleObject(xcc->xcc_event_recv_channel_filled, XNET_RECV_WAIT_TIMEOUT); |
| 1987 | |
| 1988 | if (port->port_flags & PORT_disconnect) |
| 1989 | return FALSE; |
| 1990 | |
| 1991 | if (wait_result == WAIT_OBJECT_0) |
| 1992 | { |
| 1993 | // Client has written some data for us (server) to read |
| 1994 | |
| 1995 | port->bumpPhysStats(rem_port::RECEIVE, xch->xch_length); |
| 1996 | port->bumpLogBytes(rem_port::RECEIVE, xch->xch_length); // XNET not calls REMOTE_inflate |
| 1997 | |
| 1998 | xdrs->x_handy = xch->xch_length; |
| 1999 | xdrs->x_private = xdrs->x_base; |
| 2000 | |
| 2001 | return TRUE; |
| 2002 | } |
no test coverage detected