From patchwork Thu Jul 3 22:08:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hefty, Sean" X-Patchwork-Id: 4477511 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9ED239F3FF for ; Thu, 3 Jul 2014 22:09:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D1E272026F for ; Thu, 3 Jul 2014 22:09:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6D59C203B4 for ; Thu, 3 Jul 2014 22:09:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964867AbaGCWJC (ORCPT ); Thu, 3 Jul 2014 18:09:02 -0400 Received: from mga11.intel.com ([192.55.52.93]:26632 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965155AbaGCWJA (ORCPT ); Thu, 3 Jul 2014 18:09:00 -0400 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 03 Jul 2014 15:09:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,597,1400050800"; d="scan'208";a="564987443" Received: from cst-linux.jf.intel.com ([10.23.221.72]) by fmsmga002.fm.intel.com with ESMTP; 03 Jul 2014 15:08:59 -0700 From: sean.hefty@intel.com To: linux-rdma@vger.kernel.org Cc: Sean Hefty Subject: [PATCH 2/2] rsocket: Update correct rsocket keepalive time Date: Thu, 3 Jul 2014 15:08:44 -0700 Message-Id: <1404425324-20201-2-git-send-email-sean.hefty@intel.com> X-Mailer: git-send-email 1.7.3 In-Reply-To: <1404425324-20201-1-git-send-email-sean.hefty@intel.com> References: <1404425324-20201-1-git-send-email-sean.hefty@intel.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Sean Hefty When the keepalive time of an rsocket is updated, the updated information is forwarded to the keepalive service thread. However, the thread updates the time for the wrong service as shown: tcp_svc_timeouts[svc->cnt] = rs_get_time() + msg.rs->keepalive_time; The index into tcp_svc_timeouts should correspond to the rsocket being updated, not the last one in the list. Signed-off-by: Sean Hefty Tested-by: Hal Rosenstock --- src/rsocket.c | 37 ++++++++++++++++++++++++++----------- 1 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/rsocket.c b/src/rsocket.c index e9d12c7..b869d88 100644 --- a/src/rsocket.c +++ b/src/rsocket.c @@ -3941,19 +3941,28 @@ static int rs_svc_add_rs(struct rs_svc *svc, struct rsocket *rs) return 0; } -static int rs_svc_rm_rs(struct rs_svc *svc, struct rsocket *rs) +static int rs_svc_index(struct rs_svc *svc, struct rsocket *rs) { int i; for (i = 1; i <= svc->cnt; i++) { - if (svc->rss[i] == rs) { - svc->rss[i] = svc->rss[svc->cnt]; - memcpy(svc->contexts + i * svc->context_size, - svc->contexts + svc->cnt * svc->context_size, - svc->context_size); - svc->cnt--; - return 0; - } + if (svc->rss[i] == rs) + return i; + } + return -1; +} + +static int rs_svc_rm_rs(struct rs_svc *svc, struct rsocket *rs) +{ + int i; + + if ((i = rs_svc_index(svc, rs)) >= 0) { + svc->rss[i] = svc->rss[svc->cnt]; + memcpy(svc->contexts + i * svc->context_size, + svc->contexts + svc->cnt * svc->context_size, + svc->context_size); + svc->cnt--; + return 0; } return EBADF; } @@ -4197,6 +4206,7 @@ static uint32_t rs_get_time(void) static void tcp_svc_process_sock(struct rs_svc *svc) { struct rs_svc_msg msg; + int i; read(svc->sock[1], &msg, sizeof msg); switch (msg.cmd) { @@ -4215,8 +4225,13 @@ static void tcp_svc_process_sock(struct rs_svc *svc) msg.rs->opts &= ~RS_OPT_SVC_ACTIVE; break; case RS_SVC_MOD_KEEPALIVE: - tcp_svc_timeouts[svc->cnt] = rs_get_time() + msg.rs->keepalive_time; - msg.status = 0; + i = rs_svc_index(svc, msg.rs); + if (i >= 0) { + tcp_svc_timeouts[i] = rs_get_time() + msg.rs->keepalive_time; + msg.status = 0; + } else { + msg.status = EBADF; + } break; case RS_SVC_NOOP: msg.status = 0;