MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / packet_receive

Function packet_receive

src/remote/inet.cpp:2950–3142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2948#endif
2949
2950static bool packet_receive(rem_port* port, UCHAR* buffer, SSHORT buffer_length, SSHORT* length)
2951{
2952/**************************************
2953 *
2954 * p a c k e t _ r e c e i v e
2955 *
2956 **************************************
2957 *
2958 * Functional description
2959 * Receive a packet and pass on it's goodness. If it's good,
2960 * return true and the reported length of the packet, and update
2961 * the receive sequence number. If it's bad, return false. If it's
2962 * a duplicate message, just ignore it.
2963 *
2964 **************************************/
2965
2966 if (port->port_flags & PORT_disconnect) {
2967 return false;
2968 }
2969
2970 timeval timeout;
2971 timeout.tv_usec = 0;
2972 timeval* time_ptr = NULL;
2973
2974 if (port->port_protocol == 0)
2975 {
2976 // If the protocol is 0 we are still in the process of establishing
2977 // a connection. Add a time out to the wait.
2978 timeout.tv_sec = port->port_connect_timeout;
2979 time_ptr = &timeout;
2980 }
2981 else if (port->port_dummy_packet_interval > 0)
2982 {
2983 // Set the time interval for sending dummy packets to the client
2984 timeout.tv_sec = port->port_dummy_packet_interval;
2985 time_ptr = &timeout;
2986 }
2987
2988 // On Linux systems (and possibly others too) select will eventually
2989 // change timout values so save it here for later reuse.
2990 // Thanks to Brad Pepers who reported this bug FSG 3 MAY 2001
2991 const timeval savetime = timeout;
2992
2993 const SOCKET ph = port->port_handle;
2994 if (ph == INVALID_SOCKET)
2995 {
2996 const bool releasePort = (port->port_flags & PORT_server);
2997 if (!(port->port_flags & PORT_disconnect) && releasePort)
2998 inet_error(true, port, "invalid socket in packet_receive", isc_net_read_err, EINVAL);
2999
3000 return false;
3001 }
3002
3003 // Unsed to send a dummy packet, but too big to be defined in the loop.
3004 PACKET packet;
3005
3006 int n = 0;
3007 int inetErrNo;

Callers 2

packet_receive2Function · 0.85
REMOTE_inflateFunction · 0.85

Calls 12

inet_errorFunction · 0.85
inet_debug_timerFunction · 0.85
fflushFunction · 0.85
raiseFunction · 0.85
packet_printFunction · 0.85
selectMethod · 0.80
bumpPhysStatsMethod · 0.80
send_fullFunction · 0.70
setMethod · 0.45
getCountMethod · 0.45
decryptMethod · 0.45
getStateMethod · 0.45

Tested by

no test coverage detected