From patchwork Wed Nov 11 16:15:08 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Or Gerlitz X-Patchwork-Id: 59351 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nABGFJRb016970 for ; Wed, 11 Nov 2009 16:15:19 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754658AbZKKQPM (ORCPT ); Wed, 11 Nov 2009 11:15:12 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754807AbZKKQPM (ORCPT ); Wed, 11 Nov 2009 11:15:12 -0500 Received: from fwil.voltaire.com ([193.47.165.2]:41382 "EHLO exil.voltaire.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754658AbZKKQPL (ORCPT ); Wed, 11 Nov 2009 11:15:11 -0500 Received: from bitan-450980b21 ([172.25.5.15]) by exil.voltaire.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 11 Nov 2009 18:15:08 +0200 Date: Wed, 11 Nov 2009 18:15:08 +0200 (IST) From: Or Gerlitz To: Sean Hefty cc: linux-rdma Subject: [PATCH] librdmacm/mckey: add notifications on events Message-ID: MIME-Version: 1.0 X-OriginalArrivalTime: 11 Nov 2009 16:15:08.0475 (UTC) FILETIME=[232188B0:01CA62EA] Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Index: librdmacm/examples/mckey.c =================================================================== --- librdmacm.orig/examples/mckey.c +++ librdmacm/examples/mckey.c @@ -62,6 +62,7 @@ struct cmatest_node { struct cmatest { struct rdma_event_channel *channel; + pthread_t cmathread; struct cmatest_node *nodes; int conn_index; int connects_left; @@ -319,6 +320,30 @@ static int cma_handler(struct rdma_cm_id return ret; } +static void *cma_thread(void *arg) +{ + struct rdma_cm_event *event; + int ret; + + while (1) { + ret = rdma_get_cm_event(test.channel, &event); + if (ret) { + perror("rdma_get_cm_event"); + exit(ret); + } + switch (event->event) { + case RDMA_CM_EVENT_MULTICAST_ERROR: + case RDMA_CM_EVENT_ADDR_CHANGE: + printf("mckey: event: %s, status: %d\n", + rdma_event_str(event->event), event->status); + break; + default: + break; + } + rdma_ack_cm_event(event); + } +} + static void destroy_node(struct cmatest_node *node) { if (!node->cma_id) @@ -475,6 +500,7 @@ static int run(void) if (ret) goto out; + pthread_create(&test.cmathread, NULL, cma_thread, NULL); /* * Pause to give SM chance to configure switches. We don't want to * handle reliability issue in this simple test program.