Netlink sockets are created as blocking sockets. So, we can't
afford to remove MSG_DONTWAIT for Linux.
drain_rcvbuf() is currently called from netlink-socket.c and
netdev-linux.c. As of now, I don't see it being used for Windows.
Bug #1200865.
Reported-by: Len Gao <leng@vmware.com>
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
Konstantin Khorenko khorenko@openvz.org
Kris zhang zhang.kris@gmail.com
Krishna Miriyala krishna@nicira.com
Konstantin Khorenko khorenko@openvz.org
Kris zhang zhang.kris@gmail.com
Krishna Miriyala krishna@nicira.com
Logan Rosen logatronico@gmail.com
Luca Falavigna dktrkranz@debian.org
Luiz Henrique Ozaki luiz.ozaki@gmail.com
Logan Rosen logatronico@gmail.com
Luca Falavigna dktrkranz@debian.org
Luiz Henrique Ozaki luiz.ozaki@gmail.com
/* Drain all the data currently in the receive queue of a datagram socket (and
* possibly additional data). There is no way to know how many packets are in
* the receive queue, but we do know that the total number of bytes queued does
/* Drain all the data currently in the receive queue of a datagram socket (and
* possibly additional data). There is no way to know how many packets are in
* the receive queue, but we do know that the total number of bytes queued does
* On other Unix-like OSes, MSG_TRUNC has no effect in the flags
* argument. */
char buffer[LINUX_DATAPATH ? 1 : 2048];
* On other Unix-like OSes, MSG_TRUNC has no effect in the flags
* argument. */
char buffer[LINUX_DATAPATH ? 1 : 2048];
- ssize_t n_bytes = recv(fd, buffer, sizeof buffer, MSG_TRUNC);
+ ssize_t n_bytes = recv(fd, buffer, sizeof buffer,
+ MSG_TRUNC | MSG_DONTWAIT);
if (n_bytes <= 0 || n_bytes >= rcvbuf) {
break;
}
if (n_bytes <= 0 || n_bytes >= rcvbuf) {
break;
}
/* Returns the size of socket 'sock''s receive buffer (SO_RCVBUF), or a
* negative errno value if an error occurs. */
/* Returns the size of socket 'sock''s receive buffer (SO_RCVBUF), or a
* negative errno value if an error occurs. */
int get_socket_rcvbuf(int sock);
int check_connection_completion(int fd);
int get_socket_rcvbuf(int sock);
int check_connection_completion(int fd);
int drain_rcvbuf(int fd);
int drain_rcvbuf(int fd);
void drain_fd(int fd, size_t n_packets);
#ifndef _WIN32
int make_unix_socket(int style, bool nonblock,
void drain_fd(int fd, size_t n_packets);
#ifndef _WIN32
int make_unix_socket(int style, bool nonblock,