From patchwork Thu Sep 4 18:38:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hefty, Sean" X-Patchwork-Id: 4847621 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 70DBFC0338 for ; Thu, 4 Sep 2014 18:38:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A689A20211 for ; Thu, 4 Sep 2014 18:38:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7AC2E2020E for ; Thu, 4 Sep 2014 18:38:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754825AbaIDSie (ORCPT ); Thu, 4 Sep 2014 14:38:34 -0400 Received: from mga01.intel.com ([192.55.52.88]:50722 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754254AbaIDSie (ORCPT ); Thu, 4 Sep 2014 14:38:34 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 04 Sep 2014 11:38:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,467,1406617200"; d="scan'208";a="586389535" Received: from cst-linux.jf.intel.com ([10.23.221.72]) by fmsmga001.fm.intel.com with ESMTP; 04 Sep 2014 11:38:33 -0700 From: sean.hefty@intel.com To: linux-rdma@vger.kernel.org Cc: Sean Hefty Subject: [PATCH] rsockets: Support calling listen multiple times on same rsocket Date: Thu, 4 Sep 2014 11:38:29 -0700 Message-Id: <1409855909-28819-1-git-send-email-sean.hefty@intel.com> X-Mailer: git-send-email 1.7.3 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-8.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 Standard sockets allows an application to call listen() multiple times on the same socket without error. This allows a multi-threaded app to call listen from all threads. rsockets will fail the second listen call. Modify the behavior to match standard sockets. Problem reported by: Sreedhar Kodali Signed-off-by: Sean Hefty --- src/rsocket.c | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/rsocket.c b/src/rsocket.c index 00d9a18..4833810 100644 --- a/src/rsocket.c +++ b/src/rsocket.c @@ -1174,9 +1174,14 @@ int rlisten(int socket, int backlog) rs = idm_lookup(&idm, socket); if (!rs) return ERR(EBADF); - ret = rdma_listen(rs->cm_id, backlog); - if (!ret) - rs->state = rs_listening; + + if (rs->state != rs_listening) { + ret = rdma_listen(rs->cm_id, backlog); + if (!ret) + rs->state = rs_listening; + } else { + ret = 0; + } return ret; }