From patchwork Thu Sep 18 10:50:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sreedhar Kodali X-Patchwork-Id: 4930421 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 C8F429F2EC for ; Thu, 18 Sep 2014 10:50:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9A76B20142 for ; Thu, 18 Sep 2014 10:51:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7C0362011D for ; Thu, 18 Sep 2014 10:50:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756550AbaIRKu6 (ORCPT ); Thu, 18 Sep 2014 06:50:58 -0400 Received: from e9.ny.us.ibm.com ([32.97.182.139]:50272 "EHLO e9.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756501AbaIRKu6 (ORCPT ); Thu, 18 Sep 2014 06:50:58 -0400 Received: from /spool/local by e9.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 18 Sep 2014 06:50:57 -0400 Received: from d01dlp03.pok.ibm.com (9.56.250.168) by e9.ny.us.ibm.com (192.168.1.109) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 18 Sep 2014 06:50:55 -0400 Received: from b01cxnp23032.gho.pok.ibm.com (b01cxnp23032.gho.pok.ibm.com [9.57.198.27]) by d01dlp03.pok.ibm.com (Postfix) with ESMTP id 29531C90045 for ; Thu, 18 Sep 2014 06:50:46 -0400 (EDT) Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id s8IAosJN65732818 for ; Thu, 18 Sep 2014 10:50:54 GMT Received: from d01av01.pok.ibm.com (localhost [127.0.0.1]) by d01av01.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s8IAosJj018092 for ; Thu, 18 Sep 2014 06:50:54 -0400 Received: from ltcweb.rtp.raleigh.ibm.com (ltcweb.rtp.raleigh.ibm.com [9.37.210.204]) by d01av01.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id s8IAorPd018083; Thu, 18 Sep 2014 06:50:53 -0400 Received: from ltc.linux.ibm.com (localhost.localdomain [127.0.0.1]) by ltcweb.rtp.raleigh.ibm.com (Postfix) with ESMTP id CA51FC0103; Thu, 18 Sep 2014 06:50:53 -0400 (EDT) MIME-Version: 1.0 Date: Thu, 18 Sep 2014 16:20:53 +0530 From: Sreedhar Kodali To: sean.hefty@intel.com Cc: linux-rdma@vger.kernel.org, pradeeps@linux.vnet.ibm.com Subject: [PATCH v5 4/4] rsockets: Support calling listen multiple times on same rsocket Message-ID: <0a6a8d14f8b06bab2682dd4e555c315d@imap.linux.ibm.com> X-Sender: srkodali@linux.vnet.ibm.com User-Agent: Roundcube Webmail/1.0.1 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14091810-7182-0000-0000-0000007C4240 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_TVD_MIME_EPI, 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 Note: The modified fix from Sean is being resent for completeness of changes Also attached the patch file for convenience From: Sreedhar Kodali Date: Thu Sep 18 14:51:58 2014 +0530 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 --- commit 79d3f5cbfc92b48de33ad1cd22437aa6ce24cc52 Author: Sreedhar Kodali Date: Thu Sep 18 14:51:58 2014 +0530 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 --- diff --git a/src/rsocket.c b/src/rsocket.c index 16792cf..ae72a00 100644 --- a/src/rsocket.c +++ b/src/rsocket.c @@ -1179,9 +1179,15 @@ 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; } diff --git a/src/rsocket.c b/src/rsocket.c index 16792cf..ae72a00 100644 --- a/src/rsocket.c +++ b/src/rsocket.c @@ -1179,9 +1179,15 @@ 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; }