--- /dev/null
+Bottom: e29033309f04a8a0c29c9cd63ce2469c6ffee724
+Top: a7432c74d251e27d95c7a5f69686c4e25967c6d4
+Author: U-AMR\MSHEFTY <MSHEFTY@mshefty-MOBL2.amr.corp.intel.com>
+Date: 2010-01-06 09:23:08 -0800
+
+Refresh of cm_listen_handler
+
+---
+
+diff --git a/trunk/core/al/kernel/al_cm.c b/trunk/core/al/kernel/al_cm.c
+index 955985a..1f64cdb 100644
+--- a/trunk/core/al/kernel/al_cm.c
++++ b/trunk/core/al/kernel/al_cm.c
+@@ -77,28 +77,51 @@ cm_cep_handler(const ib_al_handle_t h_al, const net32_t cid)
+ void *context;\r
+ net32_t new_cid;\r
+ ib_mad_element_t *mad;\r
+- iba_cm_id *id, *listen_id;\r
++ iba_cm_id *id;\r
+ iba_cm_event event;\r
+ NTSTATUS status;\r
+ \r
+ while (al_cep_poll(h_al, cid, &context, &new_cid, &mad) == IB_SUCCESS) {\r
+ \r
+- if (new_cid == AL_INVALID_CID) {\r
+- id = (iba_cm_id *) context;\r
+- } else {\r
+- listen_id = (iba_cm_id *) context;\r
++ ASSERT(new_cid == AL_INVALID_CID);\r
++ id = (iba_cm_id *) context;\r
++ kal_cep_format_event(h_al, id->cid, mad, &event);\r
++\r
++ status = id->callback(id, &event);\r
++ if (!NT_SUCCESS(status)) {\r
++ kal_cep_config(h_al, new_cid, NULL, NULL, NULL);\r
++ kal_cep_destroy(h_al, id->cid, status);\r
++ cm_free_id(id);\r
++ }\r
++ ib_put_mad(mad);\r
++ }\r
++}\r
++\r
++static void\r
++cm_listen_handler(const ib_al_handle_t h_al, const net32_t cid)\r
++{\r
++ void *context;\r
++ net32_t new_cid;\r
++ ib_mad_element_t *mad;\r
++ iba_cm_id *id, *listen_id;\r
++ iba_cm_event event;\r
++ NTSTATUS status;\r
++\r
++ while (al_cep_poll(h_al, cid, &context, &new_cid, &mad) == IB_SUCCESS) {\r
+ \r
+- id = cm_alloc_id(listen_id->callback, listen_id);\r
+- if (id == NULL) {\r
+- kal_cep_destroy(h_al, new_cid, STATUS_NO_MORE_ENTRIES);\r
+- ib_put_mad(mad);\r
+- continue;\r
+- }\r
++ ASSERT(new_cid != AL_INVALID_CID);\r
++ listen_id = (iba_cm_id *) context;\r
+ \r
+- kal_cep_config(h_al, new_cid, cm_cep_handler, id, cm_destroy_handler);\r
+- id->cid = new_cid;\r
++ id = cm_alloc_id(listen_id->callback, listen_id);\r
++ if (id == NULL) {\r
++ kal_cep_destroy(h_al, new_cid, STATUS_NO_MORE_ENTRIES);\r
++ ib_put_mad(mad);\r
++ continue;\r
+ }\r
+ \r
++ kal_cep_config(h_al, new_cid, cm_cep_handler, id, cm_destroy_handler);\r
++ id->cid = new_cid;\r
++\r
+ kal_cep_format_event(h_al, id->cid, mad, &event);\r
+ status = id->callback(id, &event);\r
+ if (!NT_SUCCESS(status)) {\r
+@@ -157,6 +180,7 @@ cm_listen(iba_cm_id *p_id, net64_t service_id, void *p_compare_buf,
+ info.cmp_len = compare_len;\r
+ info.cmp_offset = compare_offset;\r
+ \r
++ kal_cep_config(gh_al, p_id->cid, cm_listen_handler, p_id, cm_destroy_handler);\r
+ ib_status = al_cep_listen(gh_al, p_id->cid, &info);\r
+ return ib_to_ntstatus(ib_status);\r
+ }