From b8facaa06ddbc1b59e00d4aa16d76a06feaf65e6 Mon Sep 17 00:00:00 2001 From: Bogdan Pintea Date: Fri, 18 Jan 2008 02:04:19 +0000 Subject: [PATCH] bug fix: make sure that received binrpc reply is for the sent request git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@609 8eb893ce-cfd4-0310-b710-fb5ebe64c474 --- core/plug-in/binrpcctrl/BrpcCtrlInterface.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/core/plug-in/binrpcctrl/BrpcCtrlInterface.cpp b/core/plug-in/binrpcctrl/BrpcCtrlInterface.cpp index f1aa6873..3fa6634e 100644 --- a/core/plug-in/binrpcctrl/BrpcCtrlInterface.cpp +++ b/core/plug-in/binrpcctrl/BrpcCtrlInterface.cpp @@ -646,8 +646,16 @@ brpc_t *BrpcCtrlInterface::rpcExecute(brpc_t *req) brpc_finish(req); req = NULL; } - - if (! (rpl = brpc_recvfrom(serFd, &from, RX_TIMEOUT))) { + + /* receive from queue until empty, if IDs do not match */ + while ((rpl = brpc_recvfrom(serFd, &from, RX_TIMEOUT))) { + if (req->id == rpl->id) + break; + ERROR("received reply's ID (#%d) doesn't match request's - discarded (%d)", + brpc_id(rpl), brpc_id(req)); + brpc_finish(rpl); + } + if (! rpl) { ERROR("failed to get reply: %s [%d].\n", brpc_strerror(), brpc_errno); closeSock(&serFd, &sndAddr); goto end;