BUGFIX of non-blocking send_recv

During receiving of reply, unexpected message type can come.
by Michal V.
diff --git a/src/mod_netconf.c b/src/mod_netconf.c
index 22d213d..fa8fbe1 100644
--- a/src/mod_netconf.c
+++ b/src/mod_netconf.c
@@ -375,7 +375,17 @@
 	if (msgid == NULL) {
 		return ret;
 	}
-	ret = nc_session_recv_reply(session, timeout, reply);
+	do {
+		ret = nc_session_recv_reply(session, timeout, reply);
+		if (ret == NC_MSG_HELLO) {
+			ERROR("<hello> received instead reply, it will be lost.");
+			nc_reply_free(*reply);
+		}
+		if (ret == NC_MSG_WOULDBLOCK) {
+			ERROR("Timeout for receiving RPC reply expired.");
+			break;
+		}
+	} while (ret == NC_MSG_HELLO || ret == NC_MSG_NOTIFICATION);
 	return ret;
 }