From a8feef8d3647d25b3f5f572139acb1bab361055e Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 3 Jun 2005 13:20:45 +0000 Subject: r7228: use socket_pending() instead of the direct ioctl in the messaging code (This used to be commit ca3c4e961713ffd8952fca328e27196ba2ccc0c9) --- source4/lib/messaging/messaging.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'source4/lib/messaging') diff --git a/source4/lib/messaging/messaging.c b/source4/lib/messaging/messaging.c index eb526fd391..936e3b9515 100644 --- a/source4/lib/messaging/messaging.c +++ b/source4/lib/messaging/messaging.c @@ -166,21 +166,22 @@ static void messaging_recv_handler(struct messaging_context *msg) NTSTATUS status; DATA_BLOB packet; size_t msize; - int dsize=0; /* see how many bytes are in the next packet */ - if (ioctl(socket_get_fd(msg->sock), FIONREAD, &dsize) != 0) { - DEBUG(0,("FIONREAD failed in messaging - %s\n", strerror(errno))); + status = socket_pending(msg->sock, &msize); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0,("socket_pending failed in messaging - %s\n", + nt_errstr(status))); return; } - packet = data_blob_talloc(msg, NULL, dsize); + packet = data_blob_talloc(msg, NULL, msize); if (packet.data == NULL) { /* assume this is temporary and retry */ return; } - status = socket_recv(msg->sock, packet.data, dsize, &msize, 0); + status = socket_recv(msg->sock, packet.data, msize, &msize, 0); if (!NT_STATUS_IS_OK(status)) { data_blob_free(&packet); return; -- cgit